I use vim every day on every platform I work, Linux, Windows, Mac, FreeBSD and all flavours of Unices

Someone can think I am a masochist, because there are a lot of visual editors more convenient than vim, but at this point my familiarity with him is huge, and I feel at home when I use it!

vim

In the last years I tried to write a configuration file for vim which I can use on every operating system, and here you are the result:

set nocompatible
" vim configuration file
" " www.xappsoftware.com


" Tell vim to remember certain things when we exit
" '10 : marks will be remembered for up to 10 previously edited files
" "100 : will save up to 100 lines for each register
" :20 : up to 20 lines of command-line history will be remembered
" % : saves and restores the buffer list
 " n… : where to save the viminfo files
 set viminfo='10,\"100,:20,%,n~/.viminfo
 
 if has("autocmd")
 filetype plugin indent on
 endif
 syntax on
 set nu
 set hlsearch
 set incsearch
 set smartindent
 set shiftwidth=4
 set ts=4
 set mouse=a
 set autoindent

If you want to restore the last position of the cursor when you re-open a file, you can add the following code

set nocompatible
augroup JumpCursorOnEdit
   au!
   autocmd BufReadPost *
            \ if expand("<afile>:p:h") !=? $TEMP |
            \   if line("'\"") > 1 && line("'\"") <= line("$") |
            \     let JumpCursorOnEdit_foo = line("'\"") |
            \     let b:doopenfold = 1 |
            \     if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) |
            \        let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 |
            \        let b:doopenfold = 2 |
            \     endif |
            \     exe JumpCursorOnEdit_foo |
            \   endif |
            \ endif
   " Need to postpone using "zv" until after reading the modelines.
   autocmd BufWinEnter *
            \ if exists("b:doopenfold") |
            \   exe "normal zv" |
            \   if(b:doopenfold > 1) |
            \       exe  "+".1 |
            \   endif |
            \   unlet b:doopenfold |
            \ endif
augroup END

 

 

It works fine on Linux, windows with cygwin and Mac Os X. But if you are using Mac OS X, the mouse integration (set mouse=a) doesn't work fine with the Terminal.app, you can do alt+click to set the mouse position in the row+column you want but the mouse wheel doesn't work. If you want "set mouse=a" fully working you have to download iTerm2.

To better understand this configuration file take a look at the related posts.

In this version I've added lines 21 and 22 to better indent my C code 😉

Gg1