Created
July 4, 2012 12:23
-
-
Save jraregris/3047055 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" VUNDLE VUNDLE VUNDLE :F | |
set nocompatible | |
filetype off | |
set rtp+=~/.vim/bundle/vundle/ | |
call vundle#rc() | |
Bundle 'gmarik/vundle' | |
Bundle 'jpalardy/vim-slime' | |
filetype plugin indent on | |
" VUNDLE OFF | |
" Author: Lars Storjord | |
" Contact: lstor at simula.no | |
" Available From: http://folk.uio.no/larsstor/.vimrc | |
" Last Changed: 08.03.2011 | |
" | |
" Note: If you get an error message about swapfiles or backup files, make sure | |
" the directories ~/.vim/backup and ~/.vim/tmp exist. See set directory and set | |
" backupdir. | |
" | |
" | |
" Plugins: | |
" - snipMate - snippet insertion | |
" - NERDtree - file browser | |
" - taglist - tag browser | |
" - OmniCppComplete - C++ omnicompletion | |
" - pythoncomplete - Python omnicompletion | |
" - speeddating - quick date/time increment/decrement etc. | |
" - surround - manipulation of brackets and other surroundings | |
" - codepad - automatic paste to codepad.org | |
" - tComment - comment toggling | |
" - MRU - most recently used files | |
" - surround - handle surrounding brackets / tags | |
" - matchit - '%' matches html tags | |
" - fuzzyfinder - advanced file finder | |
" - repeat - help plugin to make other plugins work with '.' | |
" - abolish - toggle naming scheme, among other things | |
" - unimpaired - convenience for various commands (RTFM) | |
" | |
" | |
" Changelog: | |
" 1.1.3: Python code now only runs if compiled with +python. | |
" 1.1.2: Added various plugins, @i makro in C/C++ converts a single-line if to | |
" multi-line. Added some spellchecking. | |
" 1.1.1: Added :UioEdit shortcut, removed F1-4 fold bindings | |
" 1.1.0: Statusline major change, syntax update, misc. fixes | |
" 1.0.9: Added python binding to automatically generate runtime example | |
" 1.0.8: Added arrow key bindings for NERDTree, Tlist and next/prev file | |
" 1.0.7: Some restructuring, added a lot of settings | |
" 1.0.6: Added \f / \F for finding next/previous digit on this line | |
" 1.0.5: Added \i for #include and \u for using | |
" 1.0.4: Added :D20 and :Maybe :-) | |
" 1.0.3: Added cpp-omnicomplete configuration | |
" 1.0.2: Added command for opening/closing JavaDoc folds | |
" 1.0.1: Added shortcut for '<dfn>' JavaDoc comment | |
" 1.0.0: Start of versioning: Added credit and 'Last changed:' commands | |
" version mapping -- VVV (the triple Vs are for searching) | |
nmap \l :echoerr " .vimrc 1.1.3 by Lars Storjord"<CR> | |
nmap \L :echo " 1.1.3: Python code now only runs if compiled with +python."<CR> | |
set nocompatible " vim is 'vi improved' for a reason... | |
" ** SETTINGS ** | |
" ************** | |
" Colorscheme tango2 is available from http://folk.uio.no/larsstor/tango2.vim | |
set t_Co=256 " use 256 colors | |
colorscheme tango2 " 256-colored color scheme | |
"colorscheme desert " best non-256 color scheme | |
syntax on " use syntax highlighting | |
filetype plugin indent on " use file specific plugins and indents | |
"set shortmess=a0stT | |
set autochdir " cd to dir of current file | |
set autoindent " indenting | |
set autoread " automatically re-read when file is changed | |
set backspace=indent,eol,start " smart backspacing | |
set backup " don't make backup | |
set backupdir=~/.vim/backup " directory for backups | |
set bg=dark " used with color scheme | |
set cc=+1 " color column (right margin) | |
set cindent " indenting | |
set clipboard+=unnamed " share windows clipboard | |
set cpoptions=aABceFsq " compatibility options, rtfm | |
set directory=~/.vim/tmp " directory for swapfiles | |
set expandtab " convert tabs to spaces | |
set foldenable " not quite sure... | |
set foldlevel=20 " don't have anything folded at the beginning | |
set foldmethod=manual " manual folding | |
set foldnestmax=2 " maximum of n nested folds | |
set formatoptions+=ro | |
set history=50 " remember 50 commands | |
set hlsearch " highlight search | |
set ignorecase " case insensitive | |
set incsearch " search while typing | |
set infercase " case inferred | |
set laststatus=2 " if == 2, use status bar | |
set lazyredraw " lazy screen redraw (faster) | |
set linespace=0 " no extra space between lines | |
set list " show chars indicated by listchars | |
set listchars=tab:><B7>,trail:<B7> " show tabs and trailing whitespace | |
set magic " use default escaping of search chars | |
set matchpairs=(:),{:},[:],<:> " matching pairs for use with % (see matchit) | |
set matchtime=2 " tenths of a second to show matching brackets | |
set mouse=a " enable mouse | |
set nocopyindent " follow previous indent level | |
set nocursorcolumn " highlight current column | |
set nocursorline " underline the current line | |
set noerrorbells " no noise, please | |
set noexrc " use local version of .(g)vimrc, .exrc | |
set novisualbell " blink on error | |
set nowrap " wrap text around | |
set number " line numbers | |
set report=0 " report changes via :... | |
set ruler " status bar | |
set scrolloff=5 " scroll at this distance from top/bottom | |
set shiftround " be clever with tabs | |
set shiftwidth=2 " used with autoindenting | |
set showbreak= " dont indicate long lines | |
set showcmd " show current command | |
set showmatch " show matching parenthesis | |
set showmode " show current mode (insert etc.) | |
set sidescrolloff=0 " scroll at this distance from left/right (?) | |
set smartcase " ignore case except when.. uh, :help smartcase | |
set smartindent " indenting | |
set smarttab " indenting | |
set softtabstop=2 " insert four spaces when I hit tab | |
set splitright " new split windows appear on the right | |
set startofline " automatically move cursor to start of line | |
set statusline=%#Time#%{strftime(\"\%a\ \%d\ \%b\ \%H:\%M\ \ \",localtime())}\ %#Filepath#[\%F]%#Filetype#\ %y%#Flags#\ %M\ \ %r\ %h\ %w\ %=%L\ lines\ \ \ %#Percentage#[%p%%]%#Positions#\ %6l,%4c%V\ \ \ | |
set tabstop=8 " an actual tab is eight spaces | |
set textwidth=79 " generate newline at col 79 | |
set wildignore=.dll,.o,.obj, " do not list these file extensions | |
\.bak,.exe,.pyc,.jpg,.gif,.png,.wmv,.pdf,.avi,.mpg, | |
\.divx,.so,.a | |
set wildmenu " command line completion wild style | |
"set wildmode=list:longest | |
set wildmode=longest:full,full | |
set wmh=0 " window minimum height is 0, rather than 1 line | |
" Unused: | |
"set foldnestmax=5 " maximum nested folds | |
"set foldcolumn=4 " use a column (like nu) to indicate folds | |
" Use CSS and XHTML with :TOhtml | |
let html_use_css=1 | |
let use_xhtml=1 | |
" Options for taglist | |
let Tlist_Auto_Open=0 | |
let Tlist_Close_On_Select=1 | |
let Tlist_Compact_Format=1 | |
let Tlist_Ctags_Cmd='/usr/bin/ctags' | |
let Tlist_Display_Prototype=0 | |
let Tlist_Display_Tag_Scope=0 | |
let Tlist_Enable_Fold_Column=0 | |
let Tlist_Exist_OnlyWindow=1 | |
let Tlist_Exit_OnlyWindow=1 | |
let Tlist_File_Fold_Auto_Close=0 | |
let Tlist_File_Fold_Auto_Close=1 | |
let Tlist_GainFocus_On_ToggleOpen=1 | |
let Tlist_Show_One_File=0 | |
let Tlist_Sort_Type="name" | |
let Tlist_Use_Right_Window=1 | |
let Tlist_WinWidth=40 | |
" ** MAPPINGS ** | |
" ************** | |
" Map \- to show contents of cwd | |
" Map \_ to do the same without saving | |
map \- <Esc>:e .<CR> | |
map \_ <Esc>:e! .<CR> | |
" \s - substitute on this line | |
" \S - substitute all with confirmation | |
nmap \s :s///g<Left><Left><Left> | |
nmap \S :%s///gc<Left><Left><Left><Left> | |
" \g - global for entire file | |
" \G - global for visual area | |
nmap \g :%g//<Left> | |
nmap \G :'<,'>g//<Left> | |
" \h - nohls (remove search highlights) | |
" \H - hls (set search highlights) | |
nmap \h :nohls<Enter> | |
nmap \H :set hls<Enter> | |
" \T - Find TODO | |
" \F - Find FIXME | |
" \X - Find XXX | |
nmap \T /TODO<CR> | |
nmap \F /FIXME<CR> | |
nmap \X /XXX<CR> | |
" Comment lines with <F10> -- default is # because of shell scripts, configs etc. | |
map <F10> :s/^/#/<CR>:nohls<CR> | |
" Uncomment lines with <F11> | |
" Working with: // -- > # " % ! ; | |
map <F11> :s/^\/\/\\|^--\\|^> \\|^[#"%!;]//<CR>:nohls<CR> | |
" F9 - comment this line with JavaDoc comments | |
autocmd FileType c,cpp,java map <F8> :s:^\s*:&\/\*\* :<CR>:s:$: \*\/:<CR>:nohls<CR> | |
" F10 - uncomment FOLLOWING pair/block of C-style comments (and JavaDoc) | |
autocmd FileType c,cpp,java map <F9> :/\/\*/,/\*\//s:\/\*\*\= \=\\|\*\/\\|^\s*\*::g<CR>:nohls<CR> | |
" F9 - comment this line with HTML comments | |
autocmd FileType html map <F8> :s:^\s*:&<!-- :<CR>:s:$: -->:<CR>:nohls<CR> | |
" F10 - uncomment FOLLOWING pair/block of HTML comments | |
autocmd FileType html map <F9> :/<!--/,/-->/s:<!-- \=\\| \=-->::g<CR>:nohls<CR> | |
nnoremap <silent> <Left> :prev<CR> | |
nnoremap <silent> <Right> :next<CR> | |
nnoremap <silent> <Up> :TlistToggle<CR> | |
nnoremap <silent> <Down> :NERDTreeToggle<CR> | |
"inoremap <silent> <Left> <Esc>:prev<CR> | |
"inoremap <silent> <Right> <Esc>:next<CR> | |
"inoremap <silent> <Up> <Esc>:TlistToggle<CR> | |
"inoremap <silent> <Down> <Esc>:NERDTreeToggle<CR> | |
" Fold/unfold JavaDoc | |
nmap \j :g/\/\*\*/ foldo<CR>:nohls<CR> | |
nmap \J :g/\/\*\*/ foldc<CR>:nohls<CR> | |
" Find next/previous digit | |
nmap <silent> \f :call search("[0-9]", "", line("."))<CR> | |
nmap <silent> \F :call search("[0-9]", "b", line("."))<CR> | |
" Make space in normal mode go down a screenfull | |
nnoremap <space> <C-f> | |
" Let XX be like ZZ, but without saving -- NOTE: Overrides X (del prev. char.) | |
"nnoremap XX :q!<CR> | |
" Apply rot13 to entire file, in case you're writing something secret :-) | |
" Note: Uses mark n | |
map <F12> mnggVGg?`n | |
" <C-a> redo paste properly | |
inoremap <silent> <C-a> <ESC>u:set paste<CR>.:set nopaste<CR>gi | |
"inoremap ( ()<Left> | |
"inoremap (( ( | |
"inoremap () () | |
"inoremap { {}<Left> | |
"inoremap {{ { | |
"inoremap {} {} | |
"inoremap [ []<Left> | |
"inoremap [[ [ | |
"inoremap [] [] | |
" ** FILETYPE SPECIFIC ** | |
" *********************** | |
filetype on | |
augroup vimrc_filetype | |
autocmd! | |
autocmd FileType c,cpp,java,php map <F10> :s/^/\/\//<CR>:nohls<CR> | |
autocmd FileType vim map <F10> :s/^/\"/<CR>:nohls<CR> | |
autocmd FileType ruby,python map <F10> :s/^/#/<CR>:nohls<CR> | |
autocmd FileType xdefaults map <F10> :s/^/!/<CR>:nohls<CR> | |
autocmd FileType lisp,scheme map <F10> :s/^/;/<CR>:nohls<CR> | |
autocmd FileType haskell map <F10> :s/^/--/<CR>:nohls<CR> | |
autocmd FileType python map <F7> <S-F7><CR> | |
autocmd FileType python map <S-F7> :!echo -- Running %; python % | |
autocmd FileType python nmap <Home> <S-Home><CR> | |
autocmd FileType python nmap <S-Home> Go<CR><Esc>gI"""<CR>Runtime example:<CR><Esc>gI"""<Esc>O<Esc>:r !python % | |
autocmd FileType c,cpp map <F5> :make<CR> | |
" For simple compiling when a makefile isn't feasible | |
autocmd FileType c map <F6> :w<CR>:!echo -- Compiling %; gcc -o %< %<CR> | |
autocmd FileType cpp map <F6> :w<CR>:!echo -- Compiling %; g++ -o %< %<CR> | |
autocmd FileType c,cpp map <F7> <S-F7><CR> | |
autocmd FileType c,cpp map <S-F7> :!echo -- Running %<; ./%< | |
" Compiling Java | |
autocmd FileType java map <F6> :w<CR>:!echo -- Compiling %; javac %<CR> | |
autocmd FileType java map <F7> <S-F7><CR> | |
autocmd FileType java map <S-F7> :!echo -- Running %<; java %< | |
" Syntax-indenting for programming... | |
autocmd FileType c,cpp,java,php set foldmethod=syntax | |
autocmd FileType c,cpp,java,php inoremap {<CR> {<CR>}<Esc>O | |
" Java specific | |
autocmd FileType java abbr sopl System.out.println(" | |
autocmd FileType java abbr ipsm class <++> {<CR>public static void main(String[] args) {<CR> | |
autocmd FileType java imap \m ipsm<Esc> | |
autocmd FileType java imap \p sopl<Esc>a | |
autocmd FileType java nmap \m i\mgI<TAB><TAB> | |
autocmd FileType java nmap \p i\p | |
" C++ specific | |
autocmd FileType cpp abbr sopl cout << "" << endl; | |
autocmd FileType cpp abbr ipsm #include <iostream><CR><CR>int main(int argc, char* argv[])<CR>{<CR>using namespace std;<CR>cout << <CR><CR>return 0;<C-D> | |
autocmd FileType cpp abbr cldef class {<CR>public:<C-d><CR>protected:<C-d><CR>private:<C-d><CR>}; | |
autocmd FileType cpp abbr hdrg1 #ifndef HDRNM<CR>#define HDRNM<CR><CR> | |
autocmd FileType cpp abbr hdrg2 #endif // HDRNM | |
" autocmd FileType cpp imap \m ipsm<Esc> | |
" autocmd FileType cpp imap \p sopl<Esc>F"i | |
autocmd FileType cpp nmap \c icldef<Esc>jddkkkkf a | |
autocmd FileType cpp nmap \g ggihdrg1<Esc>Go<CR>hdrg2<CR><Esc>:%s/HDRNM//<Left> | |
autocmd FileType cpp,c nmap \i I#include <<Esc>A><Esc> | |
autocmd FileType cpp nmap \m iipsm<Esc>6GA<C-O>x | |
autocmd FileType cpp nmap \p isopl<Esc>F"i | |
autocmd FileType cpp nmap \u Iusing std::<Esc>A;<Esc> | |
autocmd FileType cpp nmap \t T istd::<Esc> | |
autocmd FileType cpp nmap \dfn i <dfn></dfn><Esc>hhhhhi | |
autocmd FileType cpp vmap \i :s/\(.*\)/#include <\1>/<CR>\h | |
autocmd FileType cpp vmap \u :s/\(.*\)/using std::\1;/<CR>\h | |
" The i makro register converts a single-line if to multi-line | |
autocmd FileType cpp,c let @i="ESC0%wi{^MESC0jf}lDkp==" | |
autocmd FileType c set syntax=c.doxygen | |
autocmd FileType cpp set syntax=cpp.doxygen | |
" ** OMNICOMPLETION ** | |
" ******************** | |
autocmd FileType python set omnifunc=pythoncomplete#Complete | |
" Tags: | |
autocmd FileType cpp set tags+=~/.vim/tags/stdcpp | |
autocmd FileType cpp set tags+=~/.vim/tags/boost_hpp | |
" Generate tags with Ctrl+F12 | |
autocmd FileType cpp map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR> | |
autocmd FileType cpp let OmniCpp_NamespaceSearch = 1 | |
autocmd FileType cpp let OmniCpp_GlobalScopeSearch = 1 | |
autocmd FileType cpp let OmniCpp_ShowAccess = 1 | |
autocmd FileType cpp let OmniCpp_MayCompleteDot = 1 | |
autocmd FileType cpp let OmniCpp_MayCompleteArrow = 1 | |
autocmd FileType cpp let OmniCpp_MayCompleteScope = 1 | |
autocmd FileType cpp let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"] | |
" automatically open and close the popup menu / preview window | |
autocmd FileType cpp au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif | |
autocmd FileType cpp set completeopt=menuone,menu,longest,preview | |
" autocmd BufWritePost *.sh :silent !chmod +x % | |
" autocmd BufWritePost *.pl !chmod +x % | |
" autocmd BufWritePost *.py !chmod +x % | |
autocmd BufWritePost ~/.vimrc :source % | |
augroup end | |
command! -nargs=1 UioEdit :e scp://[email protected]//uio/arkimedes/s27/larsstor/<args> | |
command! -nargs=1 ObEdit :e scp://[email protected]//usr/home/lstor/<args> | |
command! -nargs=0 Mks :exe "mksession! " . v:this_session | |
if has('python') | |
command! -nargs=+ Calc :py print <args> | |
command! -nargs=0 D20 :py print random.randint(1,21) | |
command! -nargs=0 Maybe :py maybe() | |
python << EOF | |
def maybe(): | |
maybe_var = random.randint(0,1); | |
if maybe_var == 0: | |
print "Yes!" | |
else: | |
print "No." | |
EOF | |
py from math import * | |
py import random | |
endif " has python | |
if has("gui_running") | |
set guioptions+=a | |
set guioptions+=c | |
set guioptions-=m | |
set guioptions-=b | |
set guioptions-=T | |
set guioptions-=r | |
set guioptions-=R | |
set guioptions-=l | |
set guioptions-=L | |
set guioptions-=f | |
set guioptions-=e | |
set guifont=Inconsolata\ Medium\ 14 | |
set mousehide | |
endif | |
if has("spell") | |
" turn spelling on by default | |
set nospell | |
" toggle spelling with F4 key | |
map <F4> :set spell!<CR><Bar>:echo "Spell Check: " . strpart("OffOn", 3 * &spell, 3)<CR> | |
" they were using white on white | |
highlight PmenuSel ctermfg=black ctermbg=lightgray | |
" limit it to just the top 10 items | |
set sps=best,10 | |
endif | |
" vim-slime | |
let g:slime_target = "tmux" " default is screen |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment