vim - What is in your .vimrc? -


vi , vim allow awesome customization, typically stored inside .vimrc file. typical features programmer syntax highlighting, smart indenting , on.

what other tricks productive programming have got, hidden in .vimrc?

i interested in refactorings, auto classes , similar productivity macros, c#.

you asked :-)

"{{{auto commands  " automatically cd directory file in autocmd bufenter * execute "chdir ".escape(expand("%:p:h"), ' ')  " remove trailing whitespace in file autocmd bufread,bufwrite * if ! &bin | silent! %s/\s\+$//ge | endif  " restore cursor position before 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 postpone using "zv" until after reading modelines.    autocmd bufwinenter *             \ if exists("b:doopenfold") |             \   exe "normal zv" |             \   if(b:doopenfold > 1) |             \       exe  "+".1 |             \   endif |             \   unlet b:doopenfold |             \ endif augroup end  "}}}  "{{{misc settings  " necesary  lots of cool vim things set nocompatible  " shows typing command.  love this! set showcmd  " folding stuffs set foldmethod=marker  " needed syntax highlighting , stuff filetype on filetype plugin on syntax enable set grepprg=grep\ -nh\ $*  " doesn't autoindent? set autoindent  " spaces better tab character set expandtab set smarttab  " wants 8 character tab?  not me! set shiftwidth=3 set softtabstop=3  " use english spellchecking, don't spellcheck default if version >= 700    set spl=en spell    set nospell endif  " real men use gcc "compiler gcc  " cool tab completion stuff set wildmenu set wildmode=list:longest,full  " enable mouse support in console set mouse=a  " got backspace? set backspace=2  " line numbers pwn! set number  " ignoring case fun trick set ignorecase  " , artificial intellegence! set smartcase  " totally awesome - remap jj escape in insert mode.  you'll never type jj anyway, it's great! inoremap jj <esc>  nnoremap jjjj <nop>  " incremental searching sexy set incsearch  " highlight things find search set hlsearch  " since use linux, want let g:clipbrddefaultreg = '+'  " when close tab, remove buffer set nohidden  " set off other paren highlight matchparen ctermbg=4 " }}}  "{{{look , feel  " favorite color scheme if has("gui_running")    colorscheme inkpot    " remove toolbar    set guioptions-=t    "terminus awesome    set guifont=terminus\ 9 else    colorscheme metacosm endif  "status line gnarliness set laststatus=2 set statusline=%f%m%r%h%w\ (%{&ff}){%y}\ [%l,%v][%p%%]  " }}}  "{{{ functions  "{{{ open url in browser  function! browser ()    let line = getline (".")    let line = matchstr (line, "http[^   ]*")    exec "!konqueror ".line endfunction  "}}}  "{{{theme rotating let themeindex=0 function! rotatecolortheme()    let y = -1    while y == -1       let colorstring = "inkpot#ron#blue#elflord#evening#koehler#murphy#pablo#desert#torte#"       let x = match( colorstring, "#", g:themeindex )       let y = match( colorstring, "#", x + 1 )       let g:themeindex = x + 1       if y == -1          let g:themeindex = 0       else          let themestring = strpart(colorstring, x + 1, y - x - 1)          return ":colorscheme ".themestring       endif    endwhile endfunction " }}}  "{{{ paste toggle let paste_mode = 0 " 0 = normal, 1 = paste  func! paste_on_off()    if g:paste_mode == 0       set paste       let g:paste_mode = 1    else       set nopaste       let g:paste_mode = 0    endif    return endfunc "}}}  "{{{ todo list mode  function! todolistmode()    e ~/.todo.otl    calendar    wincmd l    set foldlevel=1    tabnew ~/.notes.txt    tabfirst    " or 'norm! zmzr' endfunction  "}}}  "}}}  "{{{ mappings  " open url on line browser \w map <leader>w :call browser ()<cr>  " open project plugin <f2> nnoremap <silent> <f2> :project<cr>  " open project plugin nnoremap <silent> <leader>pal  :project .vimproject<cr>  " todo mode nnoremap <silent> <leader>todo :execute todolistmode()<cr>  " open taglist plugin <f3> nnoremap <silent> <f3> :tlist<cr>  " next tab nnoremap <silent> <c-right> :tabnext<cr>  " previous tab nnoremap <silent> <c-left> :tabprevious<cr>  " new tab nnoremap <silent> <c-t> :tabnew<cr>  " rotate color scheme <f8> nnoremap <silent> <f8> :execute rotatecolortheme()<cr>  " dos fools. nnoremap <silent> <f9> :%s/$//g<cr>:%s// /g<cr>  " paste mode!  dang! <f10> nnoremap <silent> <f10> :call paste_on_off()<cr> set pastetoggle=<f10>  " edit vimrc \ev nnoremap <silent> <leader>ev :tabnew<cr>:e ~/.vimrc<cr>  " edit gvimrc \gv nnoremap <silent> <leader>gv :tabnew<cr>:e ~/.gvimrc<cr>  " , down more logical g.. nnoremap <silent> k gk nnoremap <silent> j gj inoremap <silent> <up> <esc>gka inoremap <silent> <down> <esc>gja  " call benjie (r i) nnoremap <silent> <home> <esc>r nnoremap <silent> <end> <esc>r  " create blank newlines , stay in normal mode nnoremap <silent> zj o<esc> nnoremap <silent> zk o<esc>  " space toggle folds! nnoremap <space> za  " search mappings: these make going next 1 in " search center on line it's found in. map n nzz map n nzz  " testing set completeopt=longest,menuone,preview  inoremap <expr> <cr> pumvisible() ? "\<c-y>" : "\<c-g>u\<cr>" inoremap <expr> <c-n> pumvisible() ? "\<lt>c-n>" : "\<lt>c-n>\<lt>c-r>=pumvisible() ? \"\\<lt>down>\" : \"\"\<lt>cr>" inoremap <expr> <m-;> pumvisible() ? "\<lt>c-n>" : "\<lt>c-x>\<lt>c-o>\<lt>c-n>\<lt>c-p>\<lt>c-r>=pumvisible() ? \"\\<lt>down>\" : \"\"\<lt>cr>"  " swap ; , :  convenient. nnoremap ; : nnoremap : ;  " fix email paragraphs nnoremap <leader>par :%s/^>$//<cr>  "ly$o#{{{ "lpjjj_%a#}}}jjzajj  "}}}  "{{{taglist configuration let tlist_use_right_window = 1 let tlist_enable_fold_column = 0 let tlist_exit_onlywindow = 1 let tlist_use_singleclick = 1 let tlist_inc_winwidth = 0 "}}}  let g:rct_completion_use_fri = 1 "let g:tex_defaulttargetformat = "pdf" let g:tex_viewrule_pdf = "kpdf"  filetype plugin indent on syntax on 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -