set number <-- A must set ignorecase <-- quite useful set encoding=utf-8 set tabstop=4 set shiftwidth=4 <-- 8 is too much and annoying set expandtab <-- replace tabs with spaces. That makes layout independent of tab's setup. set foldmethod=indent <-- Ummm, depends on taste. Automatic folding based on indentation Once a file is open it may be better to change it to foldmethod=manul set cursorline <-- Visual help (cursorcolumn is useful sometimes) syntax off <-- Syntax highlighting never works to me. set cindent <-- C indent rules set smartindent <-- Make vim smart about indentation set autoindent <-- Enable autoindent
" associate file extension (lp) with syntax (lua)
au BufNewFile,BufRead *.lp setlocal ft=lua
" shorcut for if-then-else in C-style languages ab ite \if () { \ \ } else if () { \ \ } else if () { \ \ } else { \ \ } end
" shorcut for if-then-else in lua ab itel \if () then -- { \ \ elseif () then -- } { \ \ elseif () then -- } { \ \ else -- } { \ \ end -- }
"
fu! SaveSess()
execute '!mkdir .vim'
execute 'mksession! .vim/session.vim'
endfunction
fu! RestoreSess()
execute 'so .vim/session.vim'
if bufexists(1)
for l in range(1, bufnr('$'))
if bufwinnr(l) == -1
exec 'sbuffer ' . l
endif
endfor
endif
endfunction
autocmd VimLeave * call SaveSess()
autocmd VimEnter * call RestoreSess()
" indentation rules for FFmpeg set shiftwidth=4 set softtabstop=4 "set cindent < -- useful for C alike languages "set cinoptions=(0 < -- useful for C alike languages autocmd FileType make,automake set noexpandtab shiftwidth=8 softtabstop=8 < -- " Allow tabs in Makefiles. highlight ForbiddenWhitespace ctermbg=red guibg=red < -- hihglight forbidden Trailing whitespace and tabs match ForbiddenWhitespace /\s\+$\|\t/ autocmd InsertEnter * match ForbiddenWhitespace /\t\|\s\+\%#\@<!$/ < -- Do not highlight spaces at the end of line while typing on that line.
Update 2012-04: The RestoreSess/SaveSess (Grotty copy&paste from http://stackoverflow.com/questions/5142099/auto-save-vim-session-on-quit-and-auto-reload-session-on-start) is a really great addition. It saves and automatically restore all the vim session (open file, tabs, window layouts,...). One more reason to say Eclipse "Good Bye!".
Update 2014-05: Unashamedly copied Makefile related stuff from ffmpeg documentation project.
Update 2014-11: associating file extensions with language syntax and shorcuts for if-then-else.
No comments:
Post a Comment