Skip to content

Instantly share code, notes, and snippets.

@ivanov
Created July 1, 2010 05:39
Show Gist options
  • Save ivanov/459619 to your computer and use it in GitHub Desktop.
Save ivanov/459619 to your computer and use it in GitHub Desktop.
"my fugly .vimrc, as demanded by Justin and Matt at SciPy2010 -pi
set tw=0
set tabstop=4
set shiftwidth=4
set softtabstop=4
set guifont=Bitstream\ Vera\ Sans\ Mono\ 12
"allows inline settings at the beginning/end of file (e.g. :ai:ts=4:)
set modeline
"convert tabs to spaces
set expandtab
"visual bell
set vb
set fdm=marker
filetype plugin on
filetype indent on
set autoindent
"cindent gets annoying at times, so do :set nocindent if you want it off
set cindent
" indent based on {}
set smartindent
"turn on syntax highlighting
syn on
"highlight all search matches
set hlsearch
"search as you type
set incsearch
"have a save/ignore popup, instead of e.g. failing to quit a modified buffer
set confirm
"show matching parens
set showmatch
" show the line and column number of the cursor position
set ruler
" When switching buffers, do not warn if file is modified
set hidden
" Ignore case when searching
set ignorecase
" If pattern contains upper case characters, don't ignore case
set smartcase
" Show current mode at the bottom left corner
set showmode
" Make the backspace key wrap lines
set backspace=indent,eol,start
set title titlestring=%t\ (vim)
"\ (vim)
"set path+=/home/pi/code/sidd/**
"set path+=~/usr/local/lib/python2.5/site-packages/**
"set path+=~/code/neuropy/**
"set tags+=$HOME/.vim/tags/scipy.ctags
"set tags+=$HOME/.vim/tags/numpy.ctags
" XXX: i think this is slow in large projects!
" not even sure if this works, don't really use it
autocmd FileType python set omnifunc=pythoncomplete#Complete
" ctrl-space to omnicomplete
"inoremap <Nul> <C-x><C-o>
inoremap <Nul> <space>
set suffixesadd+=.c,.cpp,.h,.java,.l,.py,.cu,.rst,
"set background=dark
"let's see if this is any good
"set clipboard=unnamed
"filetype on
"filetype indent on
filetype plugin indent on
"colorscheme kate
"colorscheme wombat
colorscheme tortepi
colorscheme blue
"highlight Comment ctermbg=darkgreen guifg=darkgreen
set spelllang=en,ru
command! SpellCheck :set spell
command! Spell :!aspell -c "%"
command! T :Tlist
" don't use this anymore - use rubber instead
" command! Latex :set makeprg=latex\ %\ &&\ dvipdf\ %<.dvi
"iab ,b \begin{}<Esc>i
"iab ,e \end{}<Esc>i
"iab ,m $$ $$hh
"iab ., {}h
map <F8> :make<cr><cr>
map <F7> :w!<CR>:Spell<CR>:e! %<CR>
map <F6> :w!<CR>:!wc %<CR>
map <F2> :!sort -n<CR>
map <F4> :Todo<CR>
"speed up switching between splits
map <C-J> <C-W>j
map <C-K> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
"this allows gvim -v to work right in console mode
set mouse=a
set ttymouse=xterm2
set t_Co=256
"speed up moving around in insert mode
imap <C-j> <C-o>j
imap <C-k> <C-o>k
imap <C-l> <C-o>l
imap <C-g> <C-o>h
imap <C-a> <C-o>A
imap <C-s> <C-o>I
imap <C-b> <C-o>B
"imap <C-e> <C-o>f
"note there needs to be a space after f
"this only works properly in gvim
imap <A-j> <C-o>j
imap <A-k> <C-o>k
imap <A-l> <C-o>l
imap <A-h> <C-o>h
"imap <C-(> <C-o>(
"imap <C-)> <C-o>)
":iab <date> <C-R>=strftime("%Y-%m-%d")<CR> (Paul Ivanov)
"timestamp
"map <leader>s a<C-R>=strftime("%Y-%m-%d")<CR><Esc>
" Alt-D inserts a time stamp
imap <A-d> <C-R>=strftime("%Y-%m-%d ")<CR>
" execute this file
map <leader>r :!!<cr>
" run this file in python (ctrl-p or \-p)
map <C-p> :!python %<cr>
map <leader>p :!python %<cr>
"folding maps
map <leader>f :set invfoldenable<CR>
map <leader>ff :set foldenable<CR>:set fdc=5<cr>
map <leader>fs :set fdm=syntax<CR>
map <leader>fi :set fdm=indent<CR>
map <leader>fm :set fdm=marker fmr={{{,}}}<CR>
map <leader>fb :set fdm=marker fmr={,}<CR>
map <leader>fd :set nofen<cr>:set fdc=0<cr>
" quick log file access (now write to the end of the file
"map <leader>d :sb log<CR>Go<C-R>=strftime("%Y-%m-%d %H:%M")<CR><CR><CR><C-O>k
map <leader>d :sb CHANGES<CR>Go-
"map <leader>T :set wrap linebreak textwidth=78
"map <leader>t :set wrap nolinebreak textwidth=100000
map <leader>l :set invlinebreak showbreak=\.\.<CR>
map <leader>' :set invnu<CR>
map <leader>; :set invwrap<CR>
"list the buffers and await choice (either numbers or some substring, enter
"keeps you in the same buffer
map <leader>b :ls<cr>:buffer<space>
"go to the next buffer
map <leader>] :bn<CR>
"go to the previous buffer
map <leader>[ :bp<CR>
"kill the current buffer
map <leader>k :bd<CR>
"I gave in and got the minibufexplorer
map <C-n> :cn<CR>
"quick calls to make
"make and skip make's verbosity
map <leader>m :make<CR><CR><CR>
"just run make and view its output, before returning to vim
map <leader>M :make<CR>
"quicker exit
map <leader>q :q<CR>
"quicker save
map <leader>w :w<CR>
"call Project plugin
"map <leader>p :Project<CR>
"set cursorline "this highlights the entire current line
" move lines up and down
map <M-j> ddp
map <M-k> dd<Up>P
map <C-Down> ddp
map <C-Up> dd<Up>P
"trying to reduce my <leader> clutter
function! FancyStatus()
":set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\[HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
:set statusline=%F%m%r%h%w\ [TYPE=%Y]\ [ASCII=\%03.3b]\[HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
endfunction
function! MyCppSyntax ()
"indent k&r style
map <leader>k :!indent -kr %<CR>:e!<CR>
"indent bsd/allman style
"~/.indent.pro -nbad -bap -bbo -nbc -bli0 -c33 -cd33 -ncdb -nce -nlp -ci3 -cli0 -cp33 -cs -d0 -di1 -nfc1 -nfca -hnl -ts4 -i4 -ip0 -l75 -npcs -nprs -npsl -saf -sai -saw -nsc -nsob -nss
map <leader>i :!indent %<CR>:e!<CR>
"comments from c++ // to c /* */
"map <leader>c :!sed "s?//\(.*\)?/*\1 */?" %<cr>:e!<CR>
"map <leader>c :%s/\/\/\(.*\)/\/*\1\*\//<CR>
map <leader>c :%s:\v//(.*):/*\1*/:<CR>
"c to c++
"sed -e 's/\/\*/\/\//' -e 's/\*\///' entropy_fast.c > newfile.c
map <leader>C :%s/\/\*/\/\//<cr>:%s/\*\///<cr>
endfunction
hi clear VertSplit
"highlight todo, ignoring case
"syntax keyword cTodo contained SPEED
"hi def link myTodo Todo
let g:miniBufExplMapCTabSwitchBufs = 1
"let g:xml_syntax_folding = 1
au BufRead *.cu set ft=c
"au BufRead *.rhtml set syntax=html
"au BufRead *.rb set tabstop=2 shiftwidth=2
"set fdm=syntax
"au BufRead *.py syntax match MatchParen /\t/
map <leader>t :syntax match MatchParen /\ \ \ \ /<cr>:iab // #<cr>
map <leader>T :syntax match Normal /\ \ \ \ /<cr>:unab //<cr>
function! TODOFn ()
"syntax keyword Cursor 0
"syntax keyword MoreMsg 1
"syntax keyword LineNr 2
"syntax keyword WarningMsg 3 4
"syntax keyword Search 5
"syntax keyword Cursor 0 1
"syntax keyword Todo 2 3
"syntax keyword Search 4 5 6 7 8 9
"syntax match Cursor /^[4-9]\ /
"syntax match Todo /^[23]\ /
"syntax match Search /^[01]\ /
syntax match Cursor /^[01].*/
syntax match Todo /^[23].*/
"syntax keyword myTodo contained SPEED
"hi def link myTodo cTodo
syntax match Search /^[4-9].*/
syntax match VisualNos /CURRENT\|TODAY\|THIS\ WEEK\|REST/
highlight Cursor ctermfg=black
highlight Todo ctermfg=black
highlight Folded guibg=black
map <F4> :TodoUndo<CR>
"map <F3> :set tw=80 formatoptions+=a<CR>gggqG<CR>
endfunction
"remaps the single file commit and does a check-in instead (multiple files)
nmap <leader>sc <Plug>VCSCommit
"map <leader>sc :!svn ci<CR>
"I use svn no cvs, so making my commands start with s
nmap <Leader>sa <Plug>VCSAdd
nmap <Leader>sn <Plug>VCSAnnotate
nmap <Leader>sd <Plug>VCSDiff
nmap <Leader>sg <Plug>VCSGotoOriginal
nmap <Leader>sG <Plug>VCSGotoOriginal!
nmap <Leader>sl <Plug>VCSLog
nmap <Leader>sr <Plug>VCSRevert
nmap <Leader>ss <Plug>VCSStatus
nmap <Leader>su <Plug>VCSUpdate
nmap <Leader>sv <Plug>VCSVimDiff
nmap <Leader>sp :VCSVimDiff PREV<CR>
nmap <Leader>si <Plug>SVNInfo
function! TODOUndoFn ()
"colorscheme torte
map <F4> :Todo<CR>
"syntax keyword Normal 0 1 2 3 4 5 6 7 8 9
"syntax match Normal /^\ [0-9]\ /
syntax match Normal /^[0-9].*/
syntax match Normal /CURRENT\|TODAY\|THIS\ WEEK\|REST/
endfunction
" :CD to directory of current file
command! CD :cd %:h
command! Todo call TODOFn()
command! TodoUndo call TODOUndoFn()
command! FancyStatus call FancyStatusBar()
"command! GoGreen :hi Normal ctermfg=8
"command! GoWhite :hi Normal ctermfg=7
command! DOS :%s//\r/g
"command! Xml set fdm=syntax
"command! Rails set syntax=html
"highlight Folded guibg=black
" CD to directory containing the current file
command! CD :cd %:h
"insert mode abbreviation
iab zpi Paul Ivanov
" makes indentation work
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd BufRead *.tex set makeprg=rubber\ --pdf\ %
set gfn=Bitstream\ Vera\ Sans\ Mono\ 9
set go-=T "remove toolbar
set wildmenu
" Apparently there are a number of archivers who generate zip files that
" don't use the .zip extension (.jar, .xpi, etc). To handle such files,
" place a line in your <.vimrc> file: >
au BufReadCmd *.jar,*.xpi call zip#Browse(expand("<amatch>"))
"python << EOF
"import os
"import sys
"import vim
"for p in sys.path:
" if os.path.isdir(p):
" vim.command(r"set path+=%s" % (p.replace(" ", r"\ ")))
"EOF
command! PlayFast :!mplayer -vo gl -af scaletempo -speed 1.8 <cfile>
command! PlayNormal :!mplayer -af scaletempo "<cfile>"
command! PlayClip :!mplayer -vo gl -af scaletempo -speed 1.8 "
command! Sanitize :s/\"/\'/ge
command! Inbox call InboxCleaning()
function! InboxCleaning()
:e ~/maybe.txt
:e ~/notes
:e ~/books.txt
:e ~/entropy.txt
:e ~/brainsquiggles.txt
:e ~/albany_crc
:e ~/pythonstuff
:e ~/wikistuff
:e ~/inbox
map c :!wyrd
map a :Sanitizedd:!echo "MSG "" >> ~/.reminders
map s :Sanitizedd:!wyrd -a "" today"
map N :Sanitizedd:!wyrd -a "" `date --date='1 hour' +\%R,\%F`"
map S :Sanitizedd:!wyrd -a "" Sat"
map 1 :Sanitizedd:!wyrd -a "" Mon"
map 2 :Sanitizedd:!wyrd -a "" Tues"
map 3 :Sanitizedd:!wyrd -a "" Wed"
map 4 :Sanitizedd:!wyrd -a "" Thur"
map 5 :Sanitizedd:!wyrd -a "" Fri"
map 6 :Sanitizedd:!wyrd -a "" Sat"
map 7 :Sanitizedd:!wyrd -a "" Sun"
map <leader>t I0 dd:b todop
map <leader>T I3 dd:b todop
map <leader>l I4 dd:b todop
map <leader>L I6 dd:b todop
map <leader>c A @albany @crcdd:b albanyp
map <leader>A A @albany @crcdd:b albanyp
map <leader>w I2 A @wikidd:b wikistuffp
map <leader>W I2 A @whetstonedd:b todop
map <leader>s I0 A @eeg @sciencedd:b brainsqup
map <leader>e I0 A @entropy @sciencedd:b entropyp
map <leader>S I2 A @securitydd:b todop
map <leader>p I2 A @pythondd:b pythonstuffp
map <leader>P I2 A @puppetdd:b notesggp
map <leader>m I0 dd:b maybep
map <leader>b A@booksdd:b booksp
map <leader>B I0 A @bugdd:b maybep
map <leader>j A @blogdd:b notesgg/blogp
map <leader>n A @randomnotedd:b notesggp
map <leader>N I0 A @n800 dd:b maybeggp
map <leader>a A @people @addressbookdd:b notesggp
map <leader>r I2 A @recreationdd:b todop
map <leader>r yy:b remin GpIMSG %"A%" %b
map <leader>r A @holdddggpI- 
"yy:b remindersGoMSG %"pi%":e #
endfunction
function! PlayerProps()
:set isf+=&,32
map <leader>p :PlayFast<CR><cr>
map <C-p> :PlayFast<CR><cr>
map <C-f> :PlayFast<CR><cr>
"map <C-F> :!mplayer -vo gl -af scaletempo -speed 1.8 <cfile><cr><cr>
map <C-n> :PlayNormal<CR><cr>
command! MakePlayer call NoPlayerProps()
endfunction
function! NoPlayerProps()
:set isf-=&,32
unmap <leader>p
unmap <C-p>
unmap <C-f>
unmap <C-n>
command! MakePlayer call PlayerProps()
endfunction
command! MakePlayer call PlayerProps()
function! SetPiAbbreviations()
ab ogo ongoing oscillations
ab ns natural scenes
endfunction
au BufReadPost * if getline(1) =~ "pi_ab" | call SetPiAbbreviations() | endif
"got this one off stackoverflow
"Will allow you to use :w!! to write to a file using sudo if you forgot to "sudo vim file" (it will prompt for sudo password when writing)
cmap w!! %!sudo tee > /dev/null %
map <leader>c ct{\cite$r}
map <leader>x :!grep -o \\\\nocite\{[^}]*\}<CR>
"get rid of the menu in gvim
set guioptions-=m
" from http://svn.python.org/projects/python/trunk/Misc/Vim/vimrc
"================================================================
" vimrc file for following the coding standards specified in PEP 7 & 8.
"
" To use this file, source it in your own personal .vimrc file (``source
" <filename>``) or, if you don't have a .vimrc file, you can just symlink to it
" (``ln -s <this file> ~/.vimrc``). All options are protected by autocmds
" (read below for an explanation of the command) so blind sourcing of this file
" is safe and will not affect your settings for non-Python or non-C files.
"
"
" All setting are protected by 'au' ('autocmd') statements. Only files ending
" in .py or .pyw will trigger the Python settings while files ending in *.c or
" *.h will trigger the C settings. This makes the file "safe" in terms of only
" adjusting settings for Python and C files.
"
" Only basic settings needed to enforce the style guidelines are set.
" Some suggested options are listed but commented out at the end of this file.
" Number of spaces to use for an indent.
" This will affect Ctrl-T and 'autoindent'.
" Python: 4 spaces
" C: 8 spaces (pre-existing files) or 4 spaces (new files)
au BufRead,BufNewFile *.py,*pyw set shiftwidth=4
au BufRead *.c,*.h set shiftwidth=8
au BufNewFile *.c,*.h set shiftwidth=4
" Number of spaces that a pre-existing tab is equal to.
" For the amount of space used for a new tab use shiftwidth.
" Python: 8
" C: 8
au BufRead,BufNewFile *py,*pyw,*.c,*.h set tabstop=8
" Replace tabs with the equivalent number of spaces.
" Also have an autocmd for Makefiles since they require hard tabs.
" Python: yes
" C: no
" Makefile: no
au BufRead,BufNewFile *.py,*.pyw set expandtab
au BufRead,BufNewFile *.c,*.h set noexpandtab
au BufRead,BufNewFile Makefile* set noexpandtab
" Use the below highlight group when displaying bad whitespace is desired
highlight BadWhitespace ctermbg=red guibg=red
" Display tabs at the beginning of a line in Python mode as bad.
au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
" Make trailing whitespace be flagged as bad.
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
" Wrap text after a certain number of characters
" Python: 79
" C: 79
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h set textwidth=79
" Turn off settings in 'formatoptions' relating to comment formatting.
" - c : do not automatically insert the comment leader when wrapping based on
" 'textwidth'
" - o : do not insert the comment leader when using 'o' or 'O' from command mode
" - r : do not insert the comment leader when hitting <Enter> in insert mode
" Python: not needed
" C: prevents insertion of '*' at the beginning of every line in a comment
au BufRead,BufNewFile *.c,*.h set formatoptions-=c formatoptions-=o formatoptions-=r
" Use UNIX (\n) line endings.
" Only used for new files so as to not force existing files to change their
" line endings.
" Python: yes
" C: yes
au BufNewFile *.py,*.pyw,*.c,*.h set fileformat=unix
"set filetype to be puppet
"au BufRead,BufNewFile *.pp setfiletype puppet
" ----------------------------------------------------------------------------
" The following section contains suggested settings. While in no way required
" to meet coding standards, they are helpful.
" Set the default file encoding to UTF-8: ``set encoding=utf-8``
" Puts a marker at the beginning of the file to differentiate between UTF and
" UCS encoding (WARNING: can trick shells into thinking a text file is actually
" a binary file when executing the text file): ``set bomb``
" For full syntax highlighting:
"``let python_highlight_all=1``
"``syntax on``
" Automatically indent based on file type: ``filetype indent on``
" Keep indentation level from previous line: ``set autoindent``
" Folding based on indentation: ``set foldmethod=indent``
" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" The following changes the default filetype back to 'tex':
let g:tex_flavor='latex'
" add these to .vim/ftplugin/tex.vim
" this is mostly a matter of taste. but LaTeX looks good with just a bit
" " of indentation.
" set sw=2
" " TIP: if you write your \label's as \label{fig:something}, then if you
" " type in \ref{fig: and press <C-n> you will automatically cycle through
" " all the figure labels. Very useful!
" set iskeyword+=:
set runtimepath+=/usr/share/vim/addons/
autocmd FileType mail set spell
autocmd FileType tex map <c-c> <f5>
autocmd FileType tex imap <c-c> <f5>
" 2010-05-11
"set cursorline
set cursorcolumn
let twitvim_count=200
set laststatus=2
set statusline=%f\ %#Error#(%{GitBranch()})%#StatusNo#
hi def link GitBranchHL Status
set statusline=%<%f%h%m%r%=%l,%c%V%#GitBranchHL#(%{GitBranch()})%#Status#\ %P
set statusline=%<%f%h%m%r%=%b\ 0x%B\ \ %l,%c%V%#GitBranchHL#(%{GitBranch()})%#Status#\ %P
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment