Global (all users) vim configuration, i.e. enabling autocomplete and syntax highlighting
In Linux, the global vim configuration is generally in /etc/vim/. For instance, while you might want to configure some options for yourself in ~/.vimrc, global options that you wish to apply for all users go into /etc/vim/vimrc (no ‘dot’). Your vim installation directory, something like /usr/share/vim/vim70/ has folders autoload/, syntax/, and plugin/, but altering these is not a good idea, since you could lose your modifications when vim is upgraded. Creating the same directories under /etc/vim/ is safer and more correct. /etc/vim/autoload/* will execute automatically, just like the autoload scripts in the installation dirs and the autoload scripts under ~/.vim/autoload/.
Below is the /etc/vim/vimrc file as it exists on two of our development servers. Please consult the vim documentation or :help for full explanation of any of these directives. In bold are the directives for syntax highlighting and autocomplete:
set nocompatible set autoindent set smartindent set ruler set incsearch set tabstop=4 set shiftwidth=4 syntax on color elflord set backspace=indent,eol,start "PDV vim plugin - ctrl-P on any line "will document that line outamatically in PHPdoc syntax au FileType php source /etc/vim/plugin/php-doc.vim au FileType php inoremap <C-P> <ESC>:call PhpDocSingle()<CR>i au FileType php nnoremap <C-P> :call PhpDocSingle()<CR> au FileType php vnoremap <C-P> :call PhpDocRange()<CR> "Enable autocomplete via ctrl-x ctrl-o setlocal omnifunc=syntaxcomplete#Complete " Javascript didnt seem to register correctly with the setlocal " command above autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS " Make it a little easier to autocomplete (ctrl-J instead of ctrl-X, ctrl-O) " Ctrl-J is the same as the enter key by default, so it's harmless to remap " it to the autocomplete command sequence to make it home-row friendly. inoremap <C-J> <C-X><C-O>





January 5th, 2009 at 12:21 am
Adding “set smartindent” to the global vimrc is a very bad idea because “filetype indent on” is generally a better option. Especially for languages like Perl, Ruby, and Python that use # for comments–smartindent and cindent move lines start with # to column 0.