call pathogen#infect() let mapleader = "\" set nocompatible set nomodeline set viminfo='1000,f1,:1000,/1000 set history=1000 set updatetime=100 scriptencoding utf-8 set encoding=utf-8 "------ Visual Options ------ syntax on set number set nowrap set vb set ruler set statusline=%<%f\ %h%m%r%=%{fugitive#statusline()}\ \ %-14.(%l,%c%V%)\ %P " New splits open to right and bottom set splitbelow set splitright " Toggle whitespace visibility with ,s nmap s :set list! set listchars=tab:>\ ,trail:·,extends:»,precedes:«,nbsp:× :set list " Enable by default " L = Toggle line numbers map L :set invnumber " The search for the perfect color scheme... map x :RandomColorScheme "------ Generic Behavior ------ set tabstop=4 set shiftwidth=4 set hidden filetype indent on filetype plugin on set autoindent "allow deletion of previously entered data in insert mode set backspace=indent,eol,start " Allow saving of files as sudo when I forgot to start vim using sudo. cmap w!! %!sudo tee > /dev/null % " Edit and Reload .vimrc files nmap ev :e $MYVIMRC nmap es :so $MYVIMRC " When pressing cd switch to the directory of the open buffer map ,cd :cd %:p:h "------ Disable Annoying Features ------ " Wtf is Ex Mode anyways? nnoremap Q " Annoying window map q: :q " Accidentally pressing Shift K will no longer open stupid man entry noremap K "------ Clipboard ------ " Allow Shift+Insert to paste map map! " set clipboard=unnamedplus " Copy filename :nmap yY :let @" = expand("%") " Copy file path :nmap yZ :let @" = expand("%:p") " F2 = Paste Toggle (in insert mode, pasting indented text behavior changes) set pastetoggle= "------ Text Navigation ------ " Prevent cursor from moving to beginning of line when switching buffers set nostartofline " Keep the cursor in place while joining lines nnoremap J mzJ`z " yyp / yyP will retain column number " https://vi.stackexchange.com/questions/18116/p-paste-but-keep-cursor-same-column function! Pcol(...) abort let a:above = get(a:, 1, 0) let l:col = virtcol('.') execute 'normal!' a:above ? 'P' : 'p' call cursor('.', l:col) endfunction nnoremap p :call Pcol(0) nnoremap P :call Pcol(1) " H = Home, L = End noremap H ^ noremap L $ vnoremap L g_ "------ Split Navigation ------ " hljk = Move between splits nnoremap h h nnoremap l l nnoremap j j nnoremap k k "------ Buffer Navigation ------ " Ctrl+h & Ctrl+l cycle between buffers in the current split noremap :bprev noremap :bnext " q Closes the current buffer nnoremap q :Bclose " Q Closes the current window nnoremap Q c " Ctrl+q Force Closes the current buffer nnoremap :Bclose! "------ Searching ------ set incsearch set ignorecase set smartcase set hlsearch " Clear search highlights when pressing b nnoremap b :nohlsearch " http://www.vim.org/scripts/script.php?script_id=2572 " a will open a prmompt for a term to search for noremap a :Ack " A will close the Ack split noremap A jcl let g:ackprg="ag --vimgrep --column" " CtrlP will load from the CWD, makes it easier with all these nested repos let g:ctrlp_working_path_mode = '' " CtrlP won't show results from node_modules let g:ctrlp_custom_ignore = '\v[\/](node_modules|coverage|target|dist)|(\.(swp|ico|git|svn|png|jpg|gif|ttf))$' "type S, then type what you're looking for, a /, and what to replace it with nmap S :%s//g vmap S :s//g "------ NERDTree Options ------ let NERDTreeIgnore=['CVS','\.dSYM$', '.git', '.DS_Store', '\.swp$', '\.swo$'] "setting root dir in NT also sets VIM's cd (useful for switching projects) let NERDTreeChDirMode=2 " Toggle visibility using n noremap n :NERDTreeToggle " Focus on NERDTree using m noremap m :NERDTreeFocus " Focus on NERDTree with the currently opened file with M noremap M :NERDTreeFind " These prevent accidentally loading files while focused on NERDTree autocmd FileType nerdtree noremap autocmd FileType nerdtree noremap " Open NERDTree if we're executing vim without specifying a file to open autocmd vimenter * if !argc() | NERDTree | endif " Hides "Press ? for help" let NERDTreeMinimalUI=1 " Shows invisibles let g:NERDTreeShowHidden=1 "------ NERDCommenter Options ------ " Visual select text then use 'Leader c Leader' to comment the selection let g:NERDSpaceDelims = 1 let g:NERDDefaultAlign = 'left' "------ Fugitive Plugin Options ------ "https://github.com/tpope/vim-fugitive nnoremap gs :Gstatus nnoremap gr :Gremove nnoremap gl :Glog nnoremap gb :Gblame nnoremap gm :Gmove nnoremap gp :Ggrep nnoremap gR :Gread nnoremap gg :Git nnoremap gd :Gdiff "------ Text Editing Utilities ------ " T = Delete all Trailing space in file map T :%s/\s\+$// " U = Deletes Unwanted empty lines map U :g/^$/d " R = Converts tabs to spaces in document map R :retab "------ JSON Filetype Settings ------ au BufRead,BufNewFile *.json set filetype=json let g:vim_json_syntax_conceal = 0 nmap =j :%!python -m json.tool:setfiletype json autocmd BufNewFile,BufRead *.webapp set filetype=json autocmd BufNewFile,BufRead *.jshintrc set filetype=json autocmd BufNewFile,BufRead *.eslintrc set filetype=json "------ Flow Filetype Settings ------ let g:javascript_plugin_flow = 1 au BufNewFile,BufRead *.flow set filetype=javascript "------ Markdown Settings ------ let g:vim_markdown_folding_disabled = 1 autocmd FileType markdown setlocal spell " spell check markdown files "------ Lightline Settings ------ let g:lightline = { \ 'active': { \ 'left': [ [ 'mode', 'paste' ], \ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ] \ }, \ 'component_function': { \ 'gitbranch': 'fugitive#statusline' \ }, \ } "------ Text File Settings ------ :autocmd! BufNewFile,BufRead * setlocal nowrap :autocmd! BufNewFile,BufRead *.txt,*.md,*.tex setlocal wrap let g:signify_realtime = 1 "------ GUI Options ------ if has("gui_running") " Hides toolbar and scrollbars and File menu set guioptions=gt colorscheme hybrid " Ctrl+A select all map ggVG " Ctrl+C OS clipboard copy vmap "+y " Ctrl+B OS Clipboard paste map "*p imap "*p " Highlights the current line background set cursorline " Open VIM in fullscreen window " ...Unless you have dualscreens, then it's bigger than a screen... "set lines=200 columns=500 set lines=60 columns=200 " Build all help tags (slower launch, but I run GUI vim like once per day) call pathogen#helptags() " Set default starting directory to ~/Projects or ~/projects silent! cd $HOME/Projects silent! cd $HOME/projects if has("gui_macvim") " OS X set guifont=Monaco:h10 set noantialias "set transparency=15 " Swipe to move between buffers map :bprev map :bnext " Cmd+P = CtrlP " TODO: This doesn't actually work, still opens Print dialog macmenu File.Print key= nnoremap :CtrlP " Damn you scrollwheel paste nnoremap nnoremap <2-MiddleMouse> nnoremap <3-MiddleMouse> nnoremap <4-MiddleMouse> inoremap inoremap <2-MiddleMouse> inoremap <3-MiddleMouse> inoremap <4-MiddleMouse> elseif has("gui_gtk") " Linux " set guifont=monospace\ 9 set guifont=ProggyCleanTT\ 12 let g:NERDTreeDirArrowExpandable = '+' let g:NERDTreeDirArrowCollapsible = '~' endif else " Inside of a terminal set t_Co=256 colorscheme ir_black set mouse=a endif "------ Local Overrides ------ if filereadable($HOME.'/.vim/local.vimrc') source $HOME/.vim/local.vimrc endif