" VIM user interface """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set so=2 " Show at least 2 lines around cursors when moving vertically set ruler "Always show current position set cmdheight=1 "The commandbar height " Set backspace config set backspace=eol,start,indent set whichwrap+=<,>,h,l " tab, spacing, wrapping set expandtab set shiftwidth=4 set tabstop=4 set smarttab set ai set si set nowrap set autoread set ignorecase "Ignore case when searching set smartcase set hlsearch "Highlight search things set incsearch "Make search act like search in modern browsers set nolazyredraw "Don't redraw while executing macros 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= set tm=500 " Colors and Fonts """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set encoding=utf8 try lang en_US catch endtry set ffs=unix,dos,mac "Default file types " General """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Sets how many lines of history VIM has to remember set history=700 " Enable filetype plugin filetype plugin on filetype indent on " With a map leader it's possible to do extra key combinations " like w saves the current file let mapleader = "," let g:mapleader = "," " Fast saving nnoremap w :w! " Close buffer nnoremap q :bdelete " Fast buffer switching nnoremap , :bprev nnoremap . :bnext " Fast editing of the .vimrc nnoremap e :e! ~/.vimrc " When vimrc is edited, reload it autocmd! bufwritepost .vimrc source ~/.vimrc " key mappings " nnoremap :noh " smarter moving around map j map k map h map l " Statusline """""""""""""""""""""""""""""" " Always hide the statusline set laststatus=1 " Format the statusline set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c function! HasPaste() if &paste return 'PASTE MODE ' else return '' endif endfunction " Remove the Windows ^M - when the encodings gets messed up noremap m mmHmt:%s///ge'tzt'm noremap t :%s/\t/ /ge " Remove any trailing whitespace that is in the file autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif " Restore cursor position to where it was before augroup JumpCursorOnEdit au! autocmd BufReadPost * \ if expand(":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 to postpone using "zv" until after reading the 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 for lots of cool vim things set nocompatible " This shows what you are typing as a command. I love this! set showcmd " Folding Stuffs set foldmethod=marker " Needed for Syntax Highlighting and stuff filetype on filetype plugin on syntax enable set grepprg=grep\ -nH\ $* " Cool tab completion stuff set wildmenu set wildmode=list:longest,full " Line Numbers PWN! set number " This is totally awesome - remap jj to escape in insert mode. You'll never type jj anyway, so it's great! inoremap jj nnoremap JJJJ " Incremental searching is sexy " set incsearch "{{{ 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 echo "Paste ON" else set nopaste let g:paste_mode = 0 echo "Paste OFF" endif return endfunc "}}} nnoremap p :call Paste_on_off() " Up and down are more logical with g.. nnoremap k gk nnoremap j gj inoremap gka inoremap gja " Create Blank Newlines and stay in Normal mode nnoremap zj o nnoremap zk O " Space will toggle folds! nnoremap za " Search mappings: These will make it so that going to the next one in a " search will center on the line it's found in. map N Nzz map n nzz " Testing set completeopt=longest,menuone,preview " Swap ; and : Convenient. nnoremap ; : nnoremap : ; " removing selectmode set selectmode= colorscheme default set background=light " easier copy/paste into system clipboard set mouse= " to enable right-click paste noremap y "*y noremap p "*p noremap Y "+y noremap P "+p