{codewalker}<=Sat Mar 10-11:31 PM=>
==>~<==
=>$cat /tmp/vimrc
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ Maintainer: amix the lucky stiff
“ http://amix.dk - amix@amix.dk
“
“ Version: 3.3 - 21/01/10 01:05:46
“
“ Blog_post:
“ http://amix.dk/blog/post/19486#The-ultimate-vim-configuration-vimrc
“ Syntax_highlighted:
“ http://amix.dk/vim/vimrc.html
“ Raw_version:
“ http://amix.dk/vim/vimrc.txt
“
“ How_to_Install:
“ $ mkdir ~/.vim_runtime
“ $ svn co svn://orangoo.com/vim ~/.vim_runtime
“ $ cat ~/.vim_runtime/install.sh
“ $ sh ~/.vim_runtime/install.sh
“
“
“ How_to_Upgrade:
“ $ svn update ~/.vim_runtime
“
“ Sections:
“ -> General
“ -> VIM user interface
“ -> Colors and Fonts
“ -> Files and backups
“ -> Text, tab and indent related
“ -> Visual mode related
“ -> Command mode related
“ -> Moving around, tabs and buffers
“ -> Statusline
“ -> Parenthesis/bracket expanding
“ -> General Abbrevs
“ -> Editing mappings
“
“ -> Cope
“ -> Minibuffer plugin
“ -> Omni complete functions
“ -> Python section
“ -> JavaScript section
“
“ Plugins_Included:
“ > minibufexpl.vim - http://www.vim.org/scripts/script.php?script_id=159
“ Makes it easy to get an overview of buffers:
“ info -> :e ~/.vim_runtime/plugin/minibufexpl.vim
“
“ > bufexplorer - http://www.vim.org/scripts/script.php?script_id=42
“ Makes it easy to switch between buffers:
“ info -> :help bufExplorer
“
“ > yankring.vim - http://www.vim.org/scripts/script.php?script_id=1234
“ Emacs’s killring, useful when using the clipboard:
“ info -> :help yankring
“
“ > surround.vim - http://www.vim.org/scripts/script.php?script_id=1697
“ Makes it easy to work with surrounding text:
“ info -> :help surround
“
“ > snipMate.vim - http://www.vim.org/scripts/script.php?script_id=2540
“ Snippets for many languages (similar to TextMate’s):
“ info -> :help snipMate
“
“ > fuzzyfinder - http://www.vim.org/scripts/script.php?script_id=1984
“ Find files fast (similar to TextMate’s feature):
“ info -> :help fuzzyfinder@en
“
“ Revisions:
“ > 3.3: Added syntax highlighting for Mako mako.vim
“ > 3.2: Turned on python_highlight_all for better syntax
“ highlighting for Python
“ > 3.1: Added revisions ;) and bufexplorer.vim
“
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ => General
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ Sets how many lines of history VIM has to remember
set history=300
“ Enable filetype plugin
filetype plugin on
filetype indent on
“ Set to auto read when a file is changed from the outside
set autoread
“ With a map leader it’s possible to do extra key combinations
“ like
let mapleader = “,”
let g:mapleader = “,”
“ Fast saving
nmap
“ Fast editing of the .vimrc
map
“ When vimrc is edited, reload it
autocmd! bufwritepost vimrc source ~/.vim_runtime/vimrc
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ => VIM user interface
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ Set 7 lines to the curors - when moving vertical..
set so=7
set wildmenu “Turn on WiLd menu
set ruler “Always show current position
set cmdheight=2 “The commandbar height
set hid “Change buffer - without saving
“ Set backspace config
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set ignorecase “Ignore case when searching
set hlsearch “Highlight search things
set incsearch “Make search act like search in modern browsers
set magic “Set magic on, for regular expressions
set showmatch “Show matching bracets when text indicator is over them
set mat=2 “How many tenths of a second to blink
“ No sound on errors
set noerrorbells
set novisualbell
set t_vb=
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ => Colors and Fonts
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
syntax enable “Enable syntax hl
if has(“gui_running”)
set guioptions-=T
set background=dark
set t_Co=256
set background=dark
colorscheme peaksea
set nu
else
colorscheme zellner
set background=dark
set nonu
endif
set encoding=utf8 fileencodings=ucs-bom,utf-8,cp936,latin1
try
lang en_US
catch
endtry
set ffs=unix,dos,mac “Default file types
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ => Files and backups
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ Turn backup off, since most stuff is in SVN, git anyway…
set nobackup
set nowb
set noswapfile
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ => Text, tab and indent related
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
set expandtab
set shiftwidth=4
set tabstop=4
set smarttab
set lbr
set tw=500
set ai “Auto indent
set si “Smart indet
set wrap “Wrap lines
map
map
map
“”””””””””””””””””””””””””””””
“ => Visual mode related
“”””””””””””””””””””””””””””””
“ Really useful!
“ In visual mode when you press * or # to search for the current selection
vnoremap
vnoremap
“ When you press gv you vimgrep after the selected text
vnoremap
map
elseif a:direction == ‘f’
execute “normal /“ . l:pattern . “^M”
endif
let @/ = l:pattern
let @” = l:saved_reg
endfunction
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ => Command mode related
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ Smart mappings on the command line
cno $h e ~/
cno $d e ~/Desktop/
cno $j e ./
cno $c e
“ $q is super useful when browsing on the command line
cno $q
“ Bash like keys for the command line
cnoremap
cnoremap
cnoremap
cnoremap
cnoremap
“ Useful on some European keyboards
map ½ $
imap ½ $
vmap ½ $
cmap ½ $
func! Cwd()
let cwd = getcwd()
return “e “ . cwd
endfunc
func! DeleteTillSlash()
let g:cmd = getcmdline()
if MySys() == “linux” || MySys() == “mac”
let g:cmd_edited = substitute(g:cmd, “(.[/]).“, “1”, “”)
else
let g:cmd_edited = substitute(g:cmd, “(.[\]).“, “1”, “”)
endif
if g:cmd == g:cmd_edited
if MySys() == “linux” || MySys() == “mac”
let g:cmd_edited = substitute(g:cmd, “(.[/])./“, “1”, “”)
else
let g:cmd_edited = substitute(g:cmd, “(.*[\]).*[\]“, “1”, “”)
endif
endif
return g:cmd_edited
endfunc
func! CurrentFileDir(cmd)
return a:cmd . “ “ . expand(“%:p:h”) . “/“
endfunc
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ => Moving around, tabs and buffers
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ Map space to / (search) and c-space to ? (backgwards search)
map
map
map
“ Smart way to move btw. windows
map
map
map
map
“ Close the current buffer
map
“ Close all the buffers
map
“ Use the arrows to something usefull
map
map
“ Tab configuration
map
map
map
map
“ When pressing
map
command! Bclose call
function!
let l:currentBufNum = bufnr(“%”)
let l:alternateBufNum = bufnr(“#”)
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr(“%”) == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute(“bdelete! “.l:currentBufNum)
endif
endfunction
“ Specify the behavior when switching between buffers
try
set switchbuf=usetab
set stal=2
catch
endtry
“”””””””””””””””””””””””””””””
“ => Statusline
“”””””””””””””””””””””””””””””
“ Always hide the statusline
set laststatus=2
“ Format the statusline
set statusline= %F%m%r%h %w CWD: %r%{CurDir()}%h Line: %l/%L:%c
function! CurDir()
let curdir = substitute(getcwd(), ‘/Users/amir/‘, “~/“, “g”)
return curdir
endfunction
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ => Parenthesis/bracket expanding
“”””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
vnoremap $1 >a)<esc>
<i(
vnoremap $2 >a\]<esc>
<i[
vnoremap $3 >a}<esc>
<i{
vnoremap $$ >a"<esc>
<i”
vnoremap $q >a'<esc>
<i’
vnoremap $e >a"<esc>
<i”
“ Map auto complete of (, “, ‘, [
inoremap $1 ()
inoremap $2 []
inoremap $3 {}
inoremap $4 {
inoremap $q ‘’
inoremap $e “”
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ => General Abbrevs
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
iab xdate
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ => Editing mappings
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“Remap VIM 0
map 0 ^
“Move a line of text using ALT+[jk] or Comamnd+[jk] on mac
nmap
nmap
vmap <my
>mzgv`yo`z
vmap >my
<mzgv`yo`z
“Delete trailing white space, useful for Python ;)
func! DeleteTrailingWS()
exe “normal mz”
%s/s+$//ge
exe “normal `z”
endfunc
autocmd BufWrite *.py :call DeleteTrailingWS()
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ => Cope
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ Do :help cope if you are unsure what cope is. It’s super useful!
map
map
map
“”””””””””””””””””””””””””””””
“ => bufExplorer plugin
“”””””””””””””””””””””””””””””
let g:bufExplorerDefaultHelp=0
let g:bufExplorerShowRelativePath=1
“”””””””””””””””””””””””””””””
“ => Minibuffer plugin
“”””””””””””””””””””””””””””””
let g:miniBufExplModSelTarget = 1
let g:miniBufExplorerMoreThanOne = 2
let g:miniBufExplModSelTarget = 0
let g:miniBufExplUseSingleClick = 1
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplVSplit = 25
let g:miniBufExplSplitBelow=1
let g:bufExplorerSortBy = “name”
autocmd BufRead,BufNew :call UMiniBufExplorer
map
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ => Omni complete functions
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ => Spell checking
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“Pressing ,ss will toggle and untoggle spell checking
map
“Shortcuts using
map
map
map
map
“”””””””””””””””””””””””””””””
“ => Python section
“”””””””””””””””””””””””””””””
au FileType python set nocindent
let python_highlight_all = 1
au FileType python syn keyword pythonDecorator True None False self
au BufNewFile,BufRead *.jinja set syntax=htmljinja
au BufNewFile,BufRead *.mako set ft=mako
au FileType python inoremap
au FileType python inoremap
au FileType python inoremap
au FileType python inoremap
au FileType python map
au FileType python map
au FileType python map
au FileType python map
“”””””””””””””””””””””””””””””
“ => JavaScript section
“””””””””””””””””””””””””””””””
au FileType javascript call JavaScriptFold()
au FileType javascript setl fen
au FileType javascript setl nocindent
au FileType javascript imap
au FileType javascript imap
au FileType javascript inoremap
au FileType javascript inoremap
function! JavaScriptFold()
setl foldmethod=syntax
setl foldlevelstart=1
syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend
function! FoldText()
return substitute(getline(v:foldstart), ‘{.*’, ‘{…}’, ‘’)
endfunction
setl foldtext=FoldText()
endfunction
“”””””””””””””””””””””””””””””
“ => Fuzzy finder
“”””””””””””””””””””””””””””””
try
call fuf#defineLaunchCommand(‘FufCWD’, ‘file’, ‘fnamemodify(getcwd(), ‘’%:p:h’’)’)
map
catch
endtry
“”””””””””””””””””””””””””””””
“ => Vim grep
“”””””””””””””””””””””””””””””
let Grep_Skip_Dirs = ‘RCS CVS SCCS .svn generated’
set grepprg=/bin/grep -nH
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ => MISC
“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””
“ Remove the Windows ^M - when the encodings gets messed up
noremap
“Quickly open a buffer for scripbble
map