" " Turn syntax-highlighting on, if supported set t_Co=256 "if &t_Co > 1 " syntax off "endif syntax on " allow backspacing over everything in insert mode set bs=2 " indent automatically after new blocks " (if, while, for and so on...) set nosmartindent set noautoindent autocmd FileType perl set smartindent autocmd FileType python set smartindent autocmd FileType shell set smartindent autocmd FileType c set smartindent " paste mode - this will avoid unexpected effects when you " cut or copy some text from one window and paste it in Vim. set pastetoggle= " sometimes smartindent is worsty, make it possible " to turn it off / on " these are for normal mode "nm aus :set nosmartindent "nm ein :set smartindent " and these for command mode (after the : ) "cm aus set nosmartindent "cm ein set smartindent " indent shifts 2 spaces to right set expandtab set shiftwidth=2 set softtabstop=2 " search is case insensitive set ignorecase set hlsearch " show cursor position in statusline set ruler " show matching bracket after typing a closing bracket set showmatch " show current mode in statusline set showmode " show status line set laststatus=2 " set xterm title to "VIM ", while is " the currently opened buffer set title " do not beep (doh!) set visualbell " don't ask for :x! set writeany " dont use for exmode map Q :q " 990503: I have to set the "term" explicitly " because the standard setups are broken. " set term=builtin_pcansi set term=xterm " using dark terminals always set background=dark " color scheme astronaut " http://vimcolorschemetest.googlecode.com/svn/colors/astronaut.vim color astronaut " dont bother set noswapfile " emacs emulation: " CTRL-UP scrolls one paragraph up " CTRL-DOWN scrolls one paragraph down " CTRL-RIGHT scrolls one word right " CTRL-LEFT scrolls one word left " Enter unrecognized controll keys with " inoremap " C-Down: leave insert mode, press }, enter insert mode inoremap Ob }i " C-Up: leave insert mode, press {, enter insert mode} inoremap Oa {i " same as above for normal mode nnoremap Ob } nnoremap Oa { " C-Right: leave insert mode, press w(jump one word right), enter insert mode) " in this case we send 2x the 'w' command, otherwise it doesnt move inoremap Oc wwi " C-Left: leave insert mode, press b(jump one word left), enter insert mode) inoremap Od bi " same as above for normal mode nnoremap Oc w nnoremap Od b " CTRL-ENTF: leave insert mode, press 'b' (one word back), press 'dw' (delete word), enter insert mode inoremap  bdwi " allow to leave a buffer while it is modified set hidden " CTRL-X opens a bufferlist on the left " uses plugin http://www.vim.org/scripts/script.php?script_id=1325 map  :call BufferList() " split helpers " ALT-S split horizontal " ALT-V split vertical " ALT-2 split horizontal " ALT-3 split vertical " ALT-1 no splits anymore " ALT-+ increase height " ALT-- decrease height " ALT-* increase height (ALT-SHIFT-+) " ALT-_ decrease height (ALT-SHIFT--) noremap s :split noremap v :vsplit noremap + :resize +1 noremap - :resize -1 noremap * > noremap _ < noremap o noremap 1 :only noremap 2 :split noremap 3 :vsplit " *scratch* buffer " will only opened if started without a file, otherwise " start it manually " uses plugin http://www.vim.org/scripts/script.php?script_id=664 let curbuf = bufname("%") if curbuf == '' autocmd VimEnter * Scratch endif " abbreviations " same as I use in emacs autocmd FileType perl iab if if( ) {} autocmd FileType perl iab elsif elsif( ) {} autocmd FileType perl iab else else {} autocmd FileType perl iab foreach foreach( ) {} autocmd FileType perl iab while while( ) {} " just to memoize: " CTRL-P same as CTRL-TAB = inner complete based on words of current file " CTRL-P finds previous match, CTRL-N next. CTRL-N might be enough " emulate emacs' behavior of indenting something by using anywhere on a line autocmd FileType perl inoremap =^i autocmd FileType shell inoremap =^i " same as CTRL-K: remove current line, aka D in vim but from anywhere within a line autocmd FileType perl inoremap cc autocmd FileType shell inoremap cc autocmd FileType python inoremap cc autocmd FileType perl nnoremap cc autocmd FileType shell nnoremap cc autocmd FileType python nnoremap cc " same as META-x indent-regiion, but with complete buffer " must start with uppercase letter, for what ever *cking reason... " " Note: enter visual mode with 'V', move cursor to mark lines, enter '=' to re-indent them, " which would be the same as intent-region. 'y' can be used to copy, and other commands " can be applied from there too. command! IndentBuffer exe "normal! gg=G" " CTRL-L moves window so that the current line ends up in the middle of the screen " for insert mode only, so in normal mode still does repaint the screen inoremap zzi