Perfect C setup for Vim

I am trying to create a fairly traditional Cim programming environment in Vim to get an idea of ​​this based on the IDE's graphical background. Currently my .vimrc file looks like this:

syntax on :filetype indent on 

This provides good syntax highlighting and some indentation. However, automatic indentation inserts 8 spaces. Is this standard among vim users? Is there a reason for this? It feels a bit ... spacious ... emanating from an environment where 4 spaces are the norm. I'm sure there is a way to change it, but should I?

I would also like for something to fill my brackets and parentheses like Eclipse. I heard about the AutoClose plugin. Is this a better route, or something a little easier?

Any other essentials?

+4
source share
1 answer

You should refuse : which is not needed in your ~/.vimrc , the correct line should be:

 filetype plugin indent on 

The plugin part loads additional plugins specific to file types, which often provide useful commands / mappings / settings.


8 characters are actually the universal and historical default width for <Tab> . If you want it to appear shorter (which I can understand), you will have to add these lines to your ~/.vimrc :

 set softtabstop=4 " see :h 'softtabstop' set shiftwidth=4 " see :h 'shiftwidth' 

Q :h 'tabstop' contains a comprehensive explanation.

Note that this does not change anything in the actual contents of the file.


I use DelimitMate, but there are many plugins with automatic closure. If you are satisfied with AutoClose and need this feature, there is no reason to change, I think. But you should know that a naive but working implementation of this concept can be achieved with a few user mappings, such as:

 inoremap ( ()<Left> 

This is the minimum ~/.vimrc that I put on every server I work on. It is small, but it installs a number of super useful options such as hidden or incsearch .

 set nocompatible filetype plugin indent on syntax on silent! runtime macros/matchit.vim set autochdir set backspace=indent,eol,start set foldenable set hidden set incsearch set laststatus=2 set ruler set switchbuf=useopen,usetab set tags=./tags,tags;/ set wildmenu nnoremap gb :buffers<CR>:sb<Space> 

To find out what each parameter does, just do :h 'option (with one quote) and add it to your ~/.vimrc only if you understand what it does and you really need it.

Generally, learning how to use documentation is key.

+12
source

All Articles