3

I have recently moved to a VIM environment for Python development. I learned the setup from John Anderson's outstanding web page on the subject. I am about to try and set up another VIM environment for C++. Is this even possible to do effectively? Or should I really have two accounts on my Linux box, one for Python, one for C++ development?

If anyone could outline their setup, either way, I would appreciate it greatly.

To further clarify the question, I am not asking "what is best way?" which is unanswerable. I am asking those VIM users who program both C++ and Python if they use one VIM environment, or two (perhaps on different accounts), and how they accomplish it either way.

(For Java, I am sticking with NetBeans and am pretty sure that is the right decision due to how well the build and Swing development tools are built into it, but am open to the idea of a VIM environment for all 3 languages if anyone has had success with it.)

Thanks much

Pete
  • 736
  • 4
  • 17

3 Answers3

5

If you need different settings for C and python, you can have them:

autocmd FileType python setlocal expandtab
autocmd FileType c setlocal noexpandtab
user16764
  • 3,583
  • 1
  • 25
  • 22
2

Stock Vim is pretty well suited to C++ already. Just enable OmniCPPComplete and install ctags-exuberant or cscope (and optionally a tab-complete script), and you'll get all of the completion features you'll need. As a C++ programmer, that's all I ever actually need. (Though I do have a rather long indentexpr.)

greyfade
  • 11,103
  • 2
  • 40
  • 43
1

I use same vim setting for coding C, C++ and Python (and other stuff too like bash, make ..). You can change settings based on file type. I have a blog post explaining how to change indentation settings for Python and C code automatically in vim.

The gist is

autocmd BufNewFile,BufEnter *.{py} call set_python_settings()
autocmd BufLeave *.{py} call unset_python_settings()

Write your own set_python_setting to change setting to python style and the defaults for vim is good enough for C/C++.

aufather
  • 4,449
  • 2
  • 26
  • 24