" Use Vim settings, rather then Vi settings (much better!). " This must be first, because it changes other options as a side effect. set nocompatible " my personal help fu! Helpme() echo " " echo " F1 - This help " echo " F2 - Toggle paste / nopaste" echo " F3 - Tag explorer - next split window" echo " F4 - Generate syntax colored HTML gw - swap current and next word" echo " F5 - Use Perltidy - split window upper" echo " F6 - Reload .vimrc - split window below" echo " F7 - Aun no hace nada - split window on the left" echo " F8 - Aun no hace nada - split window on the right" echo " F9 - Previous buffer \" - beautifies text" echo " F10 - Next buffer - maximize window" echo " F11 - Light / Dark background - make all windows equal size" echo " F12 - Number / Unumber lines - - line wrapping on / off" echo " < - decreases indentation by 4 spaces" echo " > - increases indentation by 4 spaces" echo " " endf map :exe Helpme() set pastetoggle= nnoremap :TagExplorer " generate syntax colored HTML map :runtime! syntax/2html.vim " Tide up Perl code using Perltidy (actually, a hacked Perltidy O:-) ) map :%!perltidy " Reload .vimrc (overrides previous options, but does not remove them) map :so $HOME/.vimrcecho "Reloaded .vimrc" if (has("perl")) perl << PERL use Text::Beautify; sub beautify { $_ = Text::Beautify::beautify($_); } PERL map " :perldo beautify($_) endif " has("perl") " next / previous file map :n map :N " dark / light background map :let &background = ( &background == "dark"? "light" : "dark" ) " numbering / unumbering lines map :set invnumberecho (&number ? "Showing" : "Not showing") "numbers" " line wrapping map - :set invwrapecho "value of wrap is" (&wrap ? "on" : "off") " map - :set invwrapset wrap? " pressing up in a long line gets you to the above line "in the screen", etc. noremap j gj noremap k gk noremap gk noremap gj inoremap gk inoremap gj " switching between windows in an easier way " (still need to map , or something like that) map map k map j map h map l " maximize a window map _:echo "Window maximized" " make all windows (almost) equally high and wide map =:echo "All windows equally sized" " reverse status bar colors (useful when working with several windows) :hi StatusLine ctermfg=white term=reverse cterm=reverse gui=reverse :hi StatusLineNC ctermfg=blue term=reverse cterm=reverse gui=reverse " make search results appear in the middle of the screen nmap n nzz nmap N Nzz nmap * *zz nmap # #zz nmap g* g*zz nmap g# g#zz " allow the . to execute once for each line of a visual selection "vnoremap . :normal . vnoremap . :execute "'<,'>g/^/norm!" . virtcol("'<") . "\|.":noh " type gw to swap the current word and the next one (english alphabet only) nmap gw "_yiw:s/\(\%#\w\+\)\(\W\+\)\(\w\+\)/\3\2\1/ " some definitions set backspace=2 " allow backspacing over everything in insert mode set history=1000 " keep 1000 lines of command line history set ruler " show the cursor position all the time set incsearch " do incremental searching set ic " ignore case in search patterns set scs " smart search (override 'ic' when pattern has uppers) set showcmd " display incomplete commands set nobackup " do not keep a backup file, use versions instead set laststatus=2 " always display the status line set nosol " cursor is kept in the same column (if possible) "set scr=5 " CTRL-U and CTRL-D scroll 5 lines at a time set sw=2 " indentation now takes just 2 spaces at a time set nrformats= " only decimal numbers will be considered for increment " Agregado por dk set background=dark set tabstop=4 set expandtab set ai set shiftwidth=4 set smarttab set showmatch "set mouse=a " Use the mouse to position, resize of splits, visual select and more :) " pressing < or > will let you indent/unident selected lines vnoremap < >gv " some common typos command! Qa qa command! Q q command! W w command! Wq wq " command! qq quit " selecting all text map 1GvG$ " removes highlight map :noh " syntax highlighting on, when the terminal has colors " also switch on highlighting the last used search pattern. if &t_Co > 2||has("gui_running") syntax on set hlsearch endif " Only do this part when compiled with support for autocommands. if has("autocmd") " Enable file type detection. " Use the default filetype settings, so that mail gets 'tw' set to 72, " 'cindent' is on in C files, etc. " Also load indent files, to automatically do language-dependent indenting. " filetype plugin indent on " For all text files set 'textwidth' to 78 characters. autocmd FileType text setlocal textwidth=78 " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$")| \ exe "normal g`\""| \ endif endif " has("autocmd") " test lines ab shpl #!/usr/bin/perl ab shrb #!/usr/bin/ruby ab shsh #!/bin/sh ab shpy #!/usr/bin/python " automatically give executable permissions based on file extension au BufWritePost *.\(?:sh\|py\|pl\|rb\) :silent !chmod a+x " Misc script header function fun! ScriptHeader(lang) call setline(1, "#!/usr/bin/" . a:lang) call append(1, "") endfun " Call header function on listed file types " XXX: could use BufNewFile if BufEnter is too inclusive au BufEnter *.py if getline(1) == "" | call s:ScriptHeader("python") | endif au BufEnter *.pl if getline(1) == "" | call s:ScriptHeader("perl") | endif au BufEnter *.rb if getline(1) == "" | call s:ScriptHeader("ruby") | endif " Shell header fun! ShellHeader() call setline(1, "#!/bin/sh") call append(1, "") endfun au BufEnter *.sh if getline(1) == "" | call s:ShellHeader() | endif " Seteo omnifunc para los que no tienen omni especifico if has("autocmd") && exists("+omnifunc") autocmd Filetype * \ if &omnifunc == "" | \ setlocal omnifunc=syntaxcomplete#Complete | \ endif endif