" Max's .vimrc """""""""""""""""""""" " Plugins """""""""""""""""""""" execute pathogen#infect() """""""""""""""""""""" " Basic editing config """""""""""""""""""""" set term=xterm-256color set nocompatible colorscheme maxbucknell " Leader let mapleader = "\" " Don't wrap lines set nowrap " Line numbering set relativenumber set number " Write before commands set autowrite " Open splits in better places set splitbelow set splitright " Quicker window movement nnoremap j nnoremap k nnoremap h nnoremap l " Set editor shell to bash, for Syntastic compatibility set shell=bash " Find files nnoremap t :call PickFile() nnoremap b :call PickBuffer() nnoremap n :call PickFileVerticalSplit() " Tab config options set expandtab set tabstop=2 set shiftwidth=2 set softtabstop=2 set autoindent " So done with this set nobackup set nowritebackup set noswapfile " What the hell is ex mode nnoremap Q " Faster highlight removal than ;noh nnoremap / :noh " I am lazy and I don't like holding shift. noremap ; : noremap ;; ; "Remove caps for dash cnoremap dash Dash " Gain root privs when writing cnoremap w!! w !sudo tee % > /dev/null " Paste! noremap v "*gp noremap V "*gP noremap c "*y noremap C "*Y " Quick exit insert mode inoremap hh inoremap hhh h inoremap " Bad arrow keys inoremap inoremap inoremap inoremap noremap noremap noremap noremap " Move lines up and down noremap - ddp noremap _ ddkP " Uppercase an entire word with nnoremap u viwU " Show me when my lines are too long " I wish to limit my lines to 80 characters long. However, Vim creates " the n+1th character when you have n characters in a line. Hence, when " my line is 80 characters long, I see the red line. So, this is set to " 82, meaning that I only see the line when my lines actually are too long. call matchadd('ColorColumn', '\%82v', 100) " Prevent K from being annoying noremap K " Edit and Reload .vimrc files nmap ev :e $MYVIMRC nmap es :so $MYVIMRC " Search options " Show partial matches while searching set incsearch " Highlight other matches in the file set hlsearch " Show the next search result. " By Damian Conway. " " This rewires n and N to do the highlighing... nnoremap n n:call HLNext(0.2) nnoremap N N:call HLNext(0.2) " Blink the next match function! HLNext (blinktime) let [bufnum, lnum, col, off] = getpos('.') let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/)) let target_pat = '\c\%#'.@/ let ring = matchadd('MBSearchNext', target_pat, 101) redraw exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm' call matchdelete(ring) redraw endfunction " Disable match-paren " It has really bad colours and it displays terribly. set noshowmatch " Make searches case sensitive only if an upper case character has been typed set ignorecase smartcase " Prevent Vim from clobbering the scrollback buffer. See " http://www.shallowsky.com/linux/noaltscreen.html set t_ti= t_te= " Highlight current line set cursorline " Ensure that the cursor never touches top or bottom of screen set scrolloff=10 " Allow backspacing over everything in insert mode set backspace=indent,eol,start " display incomplete commands set showcmd " Allow hidden buffers set hidden " Enable highlighting for syntax syntax on " Enable file type detection. " Use the default filetype settings, so that mail gets 'tw' set to 72, " 'cindent' is on in C files, etc. " Also load indent files, to automatically do language-dependent indenting. filetype plugin indent on " Insert only one space when joining lines that contain sentence-terminating " punctuation like `.`. set nojoinspaces " If a file is changed outside of vim, automatically reload it without asking set autoread " Show trailing whitespace, since it's a crime set list set listchars=trail:·,tab:‣\ " Turn off code folding set foldmethod=manual set nofoldenable let g:vim_markdown_folding_disabled=1 " Always show status bar set laststatus=2 " Pastetoggle to let Vim paste things without auto stuff set pastetoggle= """"""""""""""""" " Custom autocmds """"""""""""""""" augroup vimrcEx " Clear all autocmds in the group autocmd! autocmd FileType text setlocal textwidth=78 " Jump to last cursor position unless it's invalid or in an event handler autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif " Language whitespace settings autocmd FileType json,c,xml,java,php,python setlocal shiftwidth=4 softtabstop=4 autocmd FileType ruby,haml,eruby,yaml,html,javascript,sass,cucumber setlocal ai sw=2 sts=2 et autocmd FileType make setlocal noet sw=8 sts=8 ts=8 " Hard wrap prose autocmd FileType markdown setlocal tw=80 fo=t1 " Create files when opened autocmd BufNewFile * write augroup END """"""""""""" " STATUS LINE """"""""""""" " set statusline=%<[%n]:\ %f\ %5l,%3c\ (%{&ft}) set statusline=[%f] " filename set statusline+=\ [%l,\ %c] "line and column number set statusline+=\ %y " filetype set statusline+=\ %{SyntasticStatuslineFlag()} " syntastic errors """"""""""""""""""""" " Configure Syntastic """"""""""""""""""""" let g:syntastic_enable_signs = 0 let g:syntastic_javascript_checkers = ['eslint'] let g:syntastic_stl_format='[%t errors, first: %F]' """"""""""""""" " MISC KEY MAPS """"""""""""""" noremap y "*y nnoremap " Move around splits with nnoremap j nnoremap k nnoremap h nnoremap l """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " MULTIPURPOSE TAB KEY " Indent if we're at the beginning of a line. Else, do completion. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" function! InsertTabWrapper() let col = col('.') - 1 if !col || getline('.')[col - 1] !~ '\k' return "\" else return "\" endif endfunction " inoremap =InsertTabWrapper() " inoremap " I don't like the quote concealing let g:vim_json_syntax_conceal = 0 " Show syntax highlighting groups for word under cursor nmap \ :call SynStack() function! SynStack() if !exists("*synstack") return endif echo map(synstack(line('.'), col('.')), 'synIDattr(v:val,"name")') endfunc