" vim: set syntax=vim: " must be first line if has('vim_starting') set nocompatible " required set runtimepath+=~/.vim/bundle/neobundle.vim/ endif " required call neobundle#begin(expand('~/.vim/bundle/')) " let NeoBundle manage Neobundle " required: NeoBundleFetch 'Shougo/neobundle.vim' "NeoBundle 'kien/ctrlp.vim' NeoBundle 'Shougo/unite.vim' NeoBundle 'Shougo/vimproc.vim' " cd ~/.vim/bundle/vimproc.vim && make -f make_cygwin.mak NeoBundle 'maxbrunsfeld/vim-yankstack' NeoBundle 'Shougo/neomru.vim' NeoBundle 'tsukkee/unite-help' NeoBundle 'scrooloose/nerdtree' NeoBundle 'altercation/vim-colors-solarized' NeoBundle 'tpope/vim-surround' NeoBundle 'spf13/vim-autoclose' NeoBundle 'terryma/vim-multiple-cursors' NeoBundle 'Lokaltog/vim-easymotion' NeoBundle 'jistr/vim-nerdtree-tabs' NeoBundle 'mbbill/undotree' NeoBundle 'nathanaelkane/vim-indent-guides' NeoBundle 'mhinz/vim-signify' NeoBundle 'reedes/vim-litecorrect' NeoBundle 'scrooloose/syntastic' NeoBundle 'tpope/vim-fugitive' NeoBundle 'scrooloose/nerdcommenter' NeoBundle 'godlygeek/tabular' NeoBundle 'elzr/vim-json' NeoBundle 'groenewege/vim-less' NeoBundle 'pangloss/vim-javascript' NeoBundle 'briancollins/vim-jst' NeoBundle 'kchmck/vim-coffee-script' NeoBundle 'amirh/HTML-AutoCloseTag' NeoBundle 'hail2u/vim-css3-syntax' NeoBundle 'gorodinskiy/vim-coloresque' NeoBundle 'tpope/vim-haml' "NeoBundle 'fatih/vim-go' NeoBundle 'tpope/vim-markdown' NeoBundle 'spf13/vim-preview' NeoBundle 'ervandew/supertab' NeoBundle 'mattn/emmet-vim' NeoBundle 'majutsushi/tagbar' NeoBundle 'rking/ag.vim' if (has("python") || has("python3")) NeoBundle 'bling/vim-airline' endif " NeoBundles goes here call neobundle#end() " Remap fast jj to escape inoremap jj " use Ctrl-S for saving, also in insert mode " make sure to set these two lines in ~/.bash_profile and ~/.zshrc " bind -r '\C-s' " stty -ixon nmap :w imap :wa imap " reselect what was just pasted nnoremap v V`] silent function! OSX() return has('macunix') endfunction silent function! LINUX() return has('unix) && !has('macunix) && !has('win32unix) endfunction silent function! WINDOWS() return (has('win16') || has('win32') || has('win64')) endfunction silent function! CYGWIN() return has('win32unix') endfunction if CYGWIN() " block cursors in cygwin vim " http://superuser.com/a/634327 let &t_ti.="\e[1 q" let &t_SI.="\e[5 q" let &t_EI.="\e[1 q" let &t_te.="\e[0 q" endif set background=dark " Assume a dark background colorscheme solarized filetype plugin indent on " Automatically detect file types. syntax on " Syntax highlighting set mouse=a " Automatically enable mouse usage set mousehide " Hide the mouse cursor while typing scriptencoding utf-8 set enc=utf-8 set fenc=utf-8 set termencoding=utf-8 " mouse resize splits using vim under tmux http://superuser.com/a/550482 if &term =~ '^screen' " tmux knows the extended mouse mode set ttymouse=xterm2 endif if has('clipboard') if has('unnamedplus') " When possible use + register for copy paste set clipboard=unnamedplus else set clipboard=unnamed endif endif " copy cut and paste settings for clipboard vmap "+y vmap "+c vmap c"+p imap + " set autowrite " Automatically write a file when " leaving a modified buffer set viewoptions=folds,options,cursor,unix,slash " Better unix / windows compatibility set virtualedit=onemore " Allow for cursor beyond last character set history=1000 " Allow for cursor beyond last character set spell " Spell checking on set hidden " Allow buffer switching without saving " Setting up the directories set backup if has('persistent_undo') set undofile " So is persistent undo ... set undolevels=1000 " Maximum number of changes that can be undone set undoreload=1000 " Maximum number lines to save for undo on a buffer reload endif set tabpagemax=15 " Only show 15 tabs set showmode " Display current mode set cursorline " Highlight current line highlight clear SignColumn " SignColumn should match background highlight clear LineNr " Current line number row will have same background color in relative mode set backspace=indent,eol,start " Backspace for dummies set linespace=0 " No extra spaces between rows set nu " Line numbers on set showmatch " Show matching brackets/parenthesis set incsearch " Find as you type search set hlsearch " Highlight search terms set winminheight=0 " Windows can be 0 line height set ignorecase " Case insensitive search set smartcase " Case sensitive when uc present set wildmenu " Show list instead of just completing set wildmode=list:longest,full " Command completion, list matches, then longest common part, then all. set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too set scrolljump=5 " Lines to scroll when cursor leaves screen set scrolloff=3 " Minimum lines to keep above and below cursor set foldenable " Auto fold code set list set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace set nowrap " Do not wrap long lines set autoindent " Indent at the same level of the previous line set shiftwidth=4 " Use indents of 4 spaces set expandtab " Tabs are spaces, not tabs set tabstop=4 " An indentation every four columns set softtabstop=4 " Let backspace delete indent set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J) set splitright " Puts new vertical split windows to the right of the current set splitbelow " Puts new split windows to the bottom of the current set pastetoggle= " paste toggle (sane indentation pastes) autocmd FileType c,cpp,cs,java,go,php,javascript,python,twig,xml,yml autocmd BufWritePre call StripTrailingWhitespace() autocmd FileType haskell setlocal expandtab shiftwidth=2 softtabstop=2 autocmd BufNewFile,BufRead *.coffee set filetype=coffee let mapleader = ',' let maplocalleader = '_' " Easier moving in tabs and windows " The lines conflict with the default digraph mapping of map j_ map k_ map l_ map h_ " Wrapped lines goes down/up to next row, rather than next line in file. noremap j gj noremap k gk " Stupid shift key fixes if has("user_commands") command! -bang -nargs=* -complete=file E e command! -bang -nargs=* -complete=file W w command! -bang -nargs=* -complete=file Wq wq command! -bang -nargs=* -complete=file WQ wq command! -bang Wa wa command! -bang WA wa command! -bang Q q command! -bang QA qa command! -bang Qa qa endif cmap Tabe tabe " Yank from the cursor to the end of the line, to be consistent with C and D. noremap Y y$ " Clear current search highlighting by fast // nmap // :nohlsearch " Find merge conflict markers map fc /\v^[<\|=>]{7}( .*\|$) " Shortcuts " Change working Directory to that of the current file cmap cwd lcd %:p:h cmap cd. lcd %:p:h " Visual shifting (does not exit Visual mode) vnoremap < >gv " Allowing using the repeat operator with a visual selection (!) "http://stackoverflow.com/a/8064607/127816 vnoremap . :normal . " For when you forget to sudo.. Really Write the file. cmap w!! w !sudo tee % >/dev/null function! StripTrailingWhitespace() " Preparation: save last search, cursor position. let _s=@/ let l = line(".") let c = col(".") " do the business: %s/\s\+$//e " clean up: restore previous search history, and cursor position let @/=_s call cursor(l, c) endfunction function! InitializeDirectories() let parent = $HOME let prefix = 'vim' let dir_list = { \ 'backup': 'backupdir', \ 'views': 'viewdir', \ 'swap': 'directory' } if has('persistent_undo') let dir_list['undo'] = 'undodir' endif let common_dir = parent . '/.' . prefix for [dirname, settingname] in items(dir_list) let directory = common_dir . dirname . '/' if exists("*mkdir") if !isdirectory(directory) call mkdir(directory) endif endif if !isdirectory(directory) echo "Warning: Unable to create backup directory: " . directory echo "Try: mkdir -p " . directory else let directory = substitute(directory, " ", "\\\\ ", "g") exec "set " . settingname . "=" . directory endif endfor endfunction call InitializeDirectories() " Plugins setup goes here " NerdTree map NERDTreeTabsToggle map e :NERDTreeFind nmap nt :NERDTtreeFind let NERDTreeShowBookmarks=1 let NERDTreeIgnore=['\.pyc', '\~$', '\.swo$', '\.swp$', '\.git', '\.hg', '\.svn', '\.bzr'] let NERDTreeChDirMode=0 let NERDTreeQuitOnOpen=0 let NERDTreeMouseMode=2 let NERDTreeShowHidden=1 let NERDTreeKeepTreeinNewTab=1 " Tabularize nmap a& :Tabularize /& vmap a& :Tabularize /& nmap a= :Tabularize /= vmap a= :Tabularize /= nmap a: :Tabularize /: vmap a: :Tabularize /: nmap a:: :Tabularize /:\zs vmap a:: :Tabularize /:\zs nmap a, :Tabularize /, vmap a, :Tabularize /, nmap a,, :Tabularize /,\zs vmap a,, :Tabularize /,\zs nmap a :Tabularize / vmap a :Tabularize / "" ctrlp "let g:ctrlp_working_path_mode = 'ra' "nnoremap :CtrlP "nnoremap :CtrlPMRU "let g:ctrlp_custom_ignore = { "\ 'dir': '\.git$\|\.hg$\|\.svn$', "\ 'file': '\.exe$\|\.so$\|\.dll$\|\.pyc$' } "" On Windows use "dir" as fallback command. "if executable('ag') "let s:ctrlp_fallback = 'ag %s --nocolor -l -g ""' "elseif executable('ack') "let s:ctrlp_fallback = 'ack %s --nocolor -f' "elseif WINDOWS() "let s:ctrlp_fallback = 'dir %s /-n /b /s /a-d' "else "let s:ctrlp_fallback = 'find %s -type f' "endif "let g:ctrlp_user_command = { "\ 'types': { "\ 1: ['.git', 'cd %s && git ls-files . --cached --exclude-standard --others'], "\ 2: ['.hg', 'hg --cwd %s locate -I .'], "\ }, "\ 'fallback': s:ctrlp_fallback "\ } " Fugitive nnoremap gs :Gstatus nnoremap gd :Gdiff nnoremap gc :Gcommit nnoremap gb :Gblame nnoremap gl :Glog nnoremap gp :Git push nnoremap gr :Gread nnoremap gw :Gwrite nnoremap ge :Gedit " Mnemonic _interactive nnoremap gi :Git add -p % nnoremap gg :SignifyToggle " Undotree nnoremap u :UndotreeToggle " if undotree is opened, it is likely one wants to interact let g:undotree_SetFocusWhenToggle=1 " indent_guides let g:indent_guides_start_level=2 let g:indent_guides_guide_size=1 let g:indent_guides_enable_on_vim_startup=1 " syntastic let g:syntastic_enable_signs = 1 let g:syntastic_error_symbol = '✗' let g:syntastic_warning_symbol = '!' let g:syntastic_check_on_open = 1 " vim-airline set laststatus=2 let g:airline_powerline_fonts=1 " unite.vim call unite#filters#matcher_default#use(['matcher_fuzzy']) call unite#filters#sorter_default#use(['sorter_rank']) call unite#set_profile('files', 'smartcase', 1) call unite#custom#source('line,outline','matchers','matcher_fuzzy') " replacing unite with ctrl-p let g:unite_data_directory='~/.vim/.cache/unite' let g:unite_enable_start_insert=1 let g:unite_split_rule = 'botright' let g:unite_source_history_yank_enable=1 let g:unite_prompt='» ' if executable('ag') let g:unite_source_grep_command='ag' let g:unite_source_grep_default_opts='--nocolor --nogroup -S -C4' let g:unite_source_grep_recursive_opt='' elseif executable('ack') let g:unite_source_grep_command='ack' let g:unite_source_grep_default_opts='--no-heading --no-color -C4' let g:unite_source_grep_recursive_opt='' endif nmap [unite] nnoremap [unite] "if WINDOWS() "nnoremap [unite] :Unite -toggle -auto-resize -buffer-name=mixed file_rec:! buffer file_mru bookmark "nnoremap [unite]f :Unite -toggle -auto-resize -buffer-name=files file_rec:! "else nnoremap [unite] :Unite -toggle -auto-resize -buffer-name=mixed file_rec/async:! buffer file_mru bookmark nnoremap [unite]f :Unite -toggle -auto-resize -buffer-name=files file_rec/async:! nnoremap :Unite -toggle -auto-resize -buffer-name=files file_rec/async:! "endif nnoremap [unite]e :Unite -buffer-name=recent file_mru nnoremap [unite]y :Unite -buffer-name=yanks history/yank nnoremap [unite]l :Unite -auto-resize -buffer-name=line line nnoremap [unite]b :Unite -auto-resize -buffer-name=buffers buffer nnoremap [unite]/ :Unite -no-quit -buffer-name=search grep:. nnoremap [unite]m :Unite -auto-resize -buffer-name=mappings mapping nnoremap [unite]s :Unite -quick-match buffer nnoremap [unite]h :Unite -start-insert help "nnoremap < C - h > : < C - u > Unite - start - insert help < CR >