" Todo: " don't count capitilization errors as spelling errors? " tab for snippets and indentation and auto-completion? " visual repeat setup " octodown instead of livedown " http://smalltalk.gnu.org/blog/bonzinip/emacs-ifying-vims-autoindent " instead of autochdir? " autocmd BufReadPost * if &ft != 'help' | silent! cd %:p:h | endif " Plugins: " https://github.com/gelguy/Cmd2.vim " skybison and vim-swoop " https://github.com/mhinz/vim-startify " https://github.com/t9md/vim-transform " Wishes: " listchars working with linebreak " W13 fix " async linter update; async git singify update " decent repl integration with new terminal in neovim " real-time visualization of block editing (not that important) " Notes: " see https://gist.github.com/romainl/9ecd7b09a693816997ba " to check what is setting certain mappings and settings- " :verbose map " :verbose set " Insert prefixes: . and , (as usually followed by a space; can cause problems) " chord would be better.. " having a ~/.vimrc turns off compatable; :h 'cp'; with -u can use -N " fixes complaining about undefined tcomment variable set runtimepath+=~/.vim/bundle/tcomment_vim " #============================== " # Experimental {{{ " #============================== " Arpeggio {{{ " otherwise vim complains autocmd VimEnter * call s:arpeggio_maps() " works great with low timeout except during lag (due to neocomplete mostly) function! s:arpeggio_maps() Arpeggio inoremap st Arpeggio inoremap ie Arpeggio inoremap ne Arpeggio inoremap se " Arpeggio inoremap wf + endfunction let g:arpeggio_timeoutlen=11 " }}} " better text file long line nav (use with lazy redraw); up and down between wraps inoremap gj inoremap gk " not viable due to vim abbrevs expanding even with letters before them " and sometimes even when have typed stuff before the abbrev " letter symbols; short letter abbrevs {{{ " " don't use a, x, y, z, i (for several reasons), or j " inoreabbr e = " inoreabbr pe += " inoreabbr r & " inoreabbr rr && " inoreabbr c : " inoreabbr q ? " " plus, time*, modulo " inoreabbr p + " inoreabbr t * " inoreabbr m % " " e.g. dollar operator " inoreabbr d $ " " e.g.type t/ to get ~/ " inoreabbr t ~ " " comparison " inoreabbr ee == " inoreabbr g > " inoreabbr ge >= " inoreabbr l < " inoreabbr le <= " problems so far: " if backspace and then type one of these sequences will expand; may be better to use only in program files and not in config files either (because of mappings) " e.g. " inoreabbr eg e.g. " }}} " make a submode for this... " nnoremap w zj " nnoremap b zk augroup sCustom au! " move by paragraph (empty line) au FileType * nnoremap s }|nnoremap S { " move by sentence au FileType doto,text,mkd nmap s (textobj-sentence-move-n)|nmap S (texobj-sentence-move-p):call repeat#set("\(textobj-sentence-move-p)", v:count) augroup END nmap r nnoremap cd r if has("gui_running") " WM Experimentation {{{ nnoremap :silent !bspc window -f left && xsendkey p && bspc window -f last " "r" is Redraw {{{ " worskpace/Destkop switch {{{ nnoremap ra :silent !wm_action inpw ra nnoremap rr :silent !wm_action inpw rr nnoremap rs :silent !wm_action inpw rs nnoremap rt :silent !wm_action inpw rt nnoremap rd :silent !wm_action inpw rd nnoremap rh :silent !wm_action inpw rh " nnoremap rn :silent !wm_action dsel 7 " nnoremap re :silent !wm_action dsel 8 nnoremap rn :silent !wm_action inpw rn nnoremap re :silent !wm_action inpw re nnoremap ri :silent !wm_action inpw ri nnoremap ro :silent !wm_action inpw ro " }}} " move to destkop {{{ nnoremap Ra :silent !wm_action inpw Ra nnoremap Rr :silent !wm_action inpw Rr nnoremap Rs :silent !wm_action inpw Rs nnoremap Rt :silent !wm_action inpw Rt nnoremap Rd :silent !wm_action inpw Rd nnoremap Rh :silent !wm_action inpw Rh nnoremap Rn :silent !wm_action inpw Rn nnoremap Re :silent !wm_action inpw Re nnoremap Ri :silent !wm_action inpw Ri nnoremap Ro :silent !wm_action inpw 0Ro " }}} " moving windows within desktop {{{ " move to biggest nnoremap rcm :silent !wm_action inpw rcm " directions nnoremap rch :silent !wm_action inpw rch nnoremap rcn :silent !wm_action inpw rcn nnoremap rce :silent !wm_action inpw rce nnoremap rci :silent !wm_action inpw rci " circulate nnoremap r. :silent !wm_action inpw r. nnoremap r, :silent !wm_action inpw r, " }}} " resize {{{ nnoremap rmh :silent !wm_action inpw rmh nnoremap rmn :silent !wm_action inpw rmn nnoremap rme :silent !wm_action inpw rme nnoremap rmi :silent !wm_action inpw rmi " }}} " take from old s bindings {{{ " last window nnoremap ru :silent !wm_action inpw ru " monocle toggle nnoremap rk :silent !wm_action inpw rk nnoremap rf :silent !wm_action inpw rf nnoremap ry :silent !wm_action inpw ry " }}} " last destkop nnoremap rl :silent !wm_action inpw rl " close window nnoremap rx :silent !wm_action inpw rx " }}} "}}} else " Tmux Experimentation {{{ " "r" is Redraw {{{ " window switching {{{ nnoremap ra :silent !wm_action inpt ra:redraw! nnoremap rr :silent !wm_action inpt rr:redraw! nnoremap rs :silent !wm_action inpt rs:redraw! nnoremap rt :silent !wm_action inpt rt:redraw! nnoremap rd :silent !wm_action inpt rd:redraw! nnoremap rh :silent !wm_action inpt rh:redraw! nnoremap rn :silent !wm_action inpt rn:redraw! nnoremap re :silent !wm_action inpt re:redraw! nnoremap ri :silent !wm_action inpt ri:redraw! nnoremap ro :silent !wm_action inpt ro:redraw! " }}} " resize panes {{{ nnoremap rmh :silent !wm_action inpt rmh nnoremap rmn :silent !wm_action inpt rmn nnoremap rme :silent !wm_action inpt rme nnoremap rmi :silent !wm_action inpt rmi " }}} " circulate " previous nnoremap r, :silent !wm_action inpt r, " next nnoremap r. :silent !wm_action inpt r. " new window nnoremap rc :silent !wm_action inpt rc:redraw! " kill pane nnoremap rx :silent !wm_action inpt rx " last window nnoremap rl :silent !wm_action inpt rl:redraw! " split windows nnoremap r/ :silent !wm_action inpt r/:redraw! nnoremap r- :silent !wm_action inpt r-:redraw! " break pane nnoremap r! :silent !wm_action inpt rbang " take from old s bindings {{{ " last pane nnoremap ru :silent !wm_action inpt ru:redraw! " zoomed pane toggle nnoremap rk :silent !wm_action inpt rk " fullscreen nnoremap rf :silent !wm_action inpt rf " sticky nnoremap ry :silent !wm_action inpt ry:redraw! " main-vertical layout nnoremap rv :silent !wm_action inpt rv:redraw! " }}} " }}} " }}} endif " }}} " #============================== " # General/ Vim Settings {{{ " #============================== " General General {{{ " utf8 as default encoding set encoding=utf8 " 2000 lines of command line history. set history=2000 " keep buffer contents in memory (e.g. undo history doesn't go away if change buffers and not saving undo history to disk) set hidden " no rodent set mouse=c " automatically cd to dir current file is in set autochdir " default; :%s/// replaces one; /g replace all; /gg replace one set nogdefault " can select past eol in visual block if one line is longer set virtualedit=block " default for vim; read "vim: settings:" in files set modeline " allow backspacing over autoindent, linebreaks, and start of insert (2) set backspace=indent,eol,start " default; when do things like gg, will move cursor to sol set startofline " turn off timeout; default is 1000 " fix airline mode changes without screwing up remaps of default letter keys (without this, using escape to exit insert mode won't change airline to display normal mode immediately in the terminal) " ttimeout only applies to keycodes (so changes to default vim keys that can't be unmapped won't be a problem, e.g. using r in multikey/prefix bindings) set notimeout ttimeout ttimeoutlen=10 " generally use marker folds set foldmethod=marker set foldcolumn=2 " open folds when jumping to marks set foldopen+=mark set splitright nosplitbelow " Text Formatting {{{ " default; disable automatic insertion of newline characters set textwidth=0 wrapmargin=0 " :h fo-table " get rid of tc; no auto hardwrap (insert newline) of comments or text based on textwidth " having textwidth set overrides having tc in formatoptions " a - automatic formatting of paragraphs (e.g. if at eol with trailing whitespace, will join the lines) " j- remove comment char when joining lines " l- don't break lines in insert mode " r - insert comment after enter while in insert " q - allow formatting of comments with gq " w - trailing whitespace indicates a paragraph continues on the next line " o - adds comment char on o when line (above) is commented set formatoptions=ljrq " don't add two spaces when joining a line that ends with.,?, or ! set nojoinspaces " }}} " return to/restore last edit position when opening files " http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session augroup resCur au! au BufReadPost * call setpos(".", getpos("'\""))|normal! zv augroup END " }}} " Backup, Swap, Undo Settings {{{ " // to avoid collisions (files with same name will be named based on path) " set directory=~/.vim/swap// " swapfiles are annoying set noswapfile " persistent undo history (even if close buffer) " Save undo's after file closes set undofile " where to save undo histories set undodir=~/.vim/undo// " How many undos set undolevels=2000 " save whole buffer for undo on reload if number of lines is smaller than set undoreload=10001 " backup before overwriting file and keep backup file set writebackup backup " backup dir does not have // :( set backupdir=~/.vim/tmp set backupcopy=auto " my important text files are under git; not worried about losing old versions set backupskip+=*EDITMSG,*.txt augroup keepSomeBackups au! " changes backup extension before writing file so old backup isn't deleted if has been a minute au BufWritePre * call NewInitBex() " delete files older than two days " http://askubuntu.com/questions/413529/delete-files-older-than-one-year-on-linux " if put .vim/tmp/*, wouldn't match dot files au BufWritePost * silent !find ~/.vim/tmp* -mtime +2 -delete & augroup END " http://vim.wikia.com/wiki/Keep_incremental_backups_of_edited_files function! NewInitBex() let &bex = '-' . strftime("(%m_%d)-{%H_%M}~") endfunction " https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc#cl-207 " make folders automatically if they don't already exist if !isdirectory(expand(&undodir)) call mkdir(expand(&undodir), "p") endif if !isdirectory(expand(&backupdir)) call mkdir(expand(&backupdir), "p") endif " if !isdirectory(expand(&directory)) " call mkdir(expand(&directory), "p") " endif " }}} " Writing/Saving Settings {{{ " save buffer if changed when using various commands (switching buffers, quit, exit, etc.) set autowriteall " don't autoreload a file when changed outside of vim; prompt set noautoread " auto save all changed buffers augroup autoSave au! au InsertLeave,FocusLost,BufEnter * silent! wa augroup END " }}} " Command Mode {{{ " when tab completing from command line will show set wildmenu " https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc#cl-153 set wildignore+=.hg,.git,.svn " Version control set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files set wildignore+=*.spl " compiled spelling word lists set wildignore+=*.pyc " Python byte code " changes tab behaviour in command line (i.e. list makes every possible choice popup) set wildmode:full " }}} " Searching {{{ " highlight search time set hlsearch " fine I'll incsearch set incsearch " go back to beginning of buffer once reach end set wrapscan " when searching lower case, will match any case " won't ignore case if search with upper case set ignorecase smartcase " }}} " Auto-Sourcing .vimrc {{{ " https://github.com/bling/vim-airline/issues/539 function! RefreshUI() if exists(':AirlineRefresh') AirlineRefresh else " Clear & redraw the screen, then redraw all statuslines. redraw! redrawstatus! endif endfunction " from vim wiki augroup autoReloadVimRC au! " automatically reload vimrc when it's saved au BufWritePost ~/dotfiles/vim/.vimrc so ~/.vimrc | call RefreshUI() augroup END " }}} " }}} " #============================== " # Specific Filetype/Indentation Settings {{{ " #============================== " Indentation " will use settings in path_to_vim_install/indent/.vim " don't set smartindent or cindent with; can set autoindent though filetype plugin indent on " use previous line's indentation with , o, O set autoindent " Notes {{{ " :retab for conversion from tabs to spaces; :retab! for spaces to tabs " see help and http://vim.wikia.com/wiki/Indenting_source_code " expandtab - replace tab with spaces (noexpandtab is default) " tabstop - how many columns a tab counts for visually " softtabstop - how many columns vim uses when you hit Tab in insert mode (default: 0/off); if not set, the tabstop value is used " shiftwidth - how many columns text is indented with <<, >>, and == and with automatic indentation " smarttab -use shiftwidth instead of softtabtop forwhen determining what to do with and at the start of line and insert; it repurposes softtabstop (or tabstop, if softtabstop is 0) to be used for determining number of spaces to insert/delete elsewhere (not at sol) " also, setting softtabstop to negative values with smarttab seems to mess up the behaviour instead of using the shiftwidth value; none of this is confusing " http://tedlogan.com/techblog3.html " "If softtabstop is less than tabstop and expandtab is not set, vim will use a combination of tabs and spaces to make up the desired spacing. If softtabstop equals tabstop and expandtab is not set, vim will always use tabs. When expandtab is set, vim will always use the appropriate number of spaces." " Example: if tabstop is 8, softtabstop is 4 and noexpandtab and nosmarttab are set, " the first tab will insert 4 spaces, second will make a tab that is visually 8 columns " if shiftwidth is also 4, >> from start of line will first create 4 spaces then a tab of visual length 8 " now, if smarttab is set, shiftwidth will be used for and at the start of the line, and softtabstop will be used elsewhere " }}} set shiftwidth=4 tabstop=4 softtabstop=4 set noexpandtab set smarttab " Filetype Specific " default commentstring (will be used by tcomment) set commentstring=#\ %s " pentadactyl augroup pentadactyl au! au BufNewFile,BufRead *.pentadactylrc,*penta setlocal filetype=pentadactyl augroup END " for vim-dotoo augroup orgdotoo au! au BufEnter,BufNewFile,BufRead *.org setlocal filetype=dotoo augroup END " See: " ./.vim/after/ftplugin " ./.vim/after/syntax " }}} " #============================== " # Encryption Related {{{ " #============================== " Edit gpg Files {{{ " http://vim.wikia.com/wiki/Edit_gpg_encrypted_files set backupskip+=*.gpg augroup gpg_encrypted au! " Disable swap files, and set binary file format before reading the file " To avoid that parts of the file is saved to .viminfo when yanking or " deleting, empty the 'viminfo' option. au BufReadPre,FileReadPre *.gpg \ setlocal noswapfile noundofile noshelltemp history=0 viminfo= bin " Decrypt the contents after reading the file, reset binary file format " and run any BufReadPost autocmds matching the file name without the .gpg " extension au BufReadPost,FileReadPost *.gpg \ execute "'[,']!gpg --decrypt --default-recipient-self" | \ setlocal nobin | \ execute "doautocmd BufReadPost " . expand("%:r") " Set binary file format and encrypt the contents before writing the file au BufWritePre,FileWritePre *.gpg \ setlocal bin | \ '[,']!gpg --encrypt --default-recipient-self " After writing the file, do an :undo to revert the encryption in the " buffer, and reset binary file format au BufWritePost,FileWritePost *.gpg \ silent u | \ setlocal nobin augroup END " }}} " Vault Files (password storage) {{{ " have switched primarily to using pass (http://www.passwordstore.org/) " see vpass alias in ~/.zshrc; using .encrypted_vimrc, not this (no loading of plugins); I guess this is useful if I somehow accidentally open a file in another vim session " no backup or writebackup for vault files set backupskip+=*.vault augroup vaultEncrypted au! " disable swap files, saving to disk of undo history, writing to disk of commands, and saving thigns to .viminfo au BufReadPre,FileReadPre,BufEnter *.vault \ setlocal noswapfile cm=blowfish noundofile noshelltemp viminfo= history=0 " yanking pass au BufEnter *.vault nnoremap yy yiB augroup END " }}} " }}} " #============================== " # Appearance {{{ " #============================== syntax on augroup rainbowParens au! au FileType c,cpp call rainbow#load() augroup END " Gvim v. Vim Settings if has("gui_running") " Slow down cursor blinking speed set guicursor=a:blinkon1200-blinkoff800 " ultra anxiety... " set guicursor=a:blinkon100-blinkoff50 colorscheme gruvbox " colorscheme molokai " colorscheme badwolf set guifont=Inconsolata\ 11 " remove menubar (m), toolbar (t), gui tabs (e), and scrollbars " c use console dialogues instead of popups for simple choices " a automatically puts visually selected text to primary (*) set guioptions=ca " kind of fixes white bar appearing at bottom; seems to work.. a bit " also see ./.gtkrc-2.0.mine set guiheadroom=0 else colorscheme seoul256 endif " (G)vim Settings {{{ " default; no screen flashes/beeps set noerrorbells "relative numbers except current line (rnu); using numbers vim plugin as well set number relativenumber " set titlestring based on file set title " default; show mode; show keys in bottom right set showcmd showmode " highlight matching brackets, parens, etc. set showmatch " Make < and > as well as match pairs. https://github.com/EHartC/dot-vimrc/blob/master/vim%20config/styling.vim set matchpairs+=<:> " won't redraw while executing macros, registers, and commands that have not been typed (not default) " for example, stops flickering when have up and down mapped to c-o gk and gj in insert set lazyredraw " don't highlight past certain length; slows down vim on long lines set synmaxcol=750 " at least 5 lines shown below and above cursor set scrolloff=5 " filler lines to keep text position; start diff with vertical splits; don't ignore changes in case and whitespace set diffopt=filler,vertical " http://vim.wikia.com/wiki/Word_wrap_without_line_breaks " softwrap lines visually when reach the edge set wrap " display tabs and certain whitespace set list " ☬⚛⚜⚡☥☣ set listchars=tab:\!\ ,nbsp:☣,eol:¬,extends:❯,precedes:❮ " don't indent wrapped lines set nobreakindent " set showbreak=↪\ " show trailing whitespace in normal mode " https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc#cl-141 augroup trailing au! " listchars doesn't work with linebreak (which fucking sucks) " http://stackoverflow.com/questions/6496778/vim-run-autocmd-on-all-filetypes-except let blacklist = ['text', 'tex'] au InsertEnter * if index(blacklist, &ft) < 0 | set listchars-=trail:⌴ au InsertLeave * if index(blacklist, &ft) < 0 | set listchars+=trail:⌴ augroup END " }}} " Airline theme {{{ " https://github.com/bling/vim-airline/issues/539 " statusline always present set laststatus=2 " http://stackoverflow.com/questions/114431/fast-word-count-function-in-vim " also see http://naperwrimo.org/wiki/index.php?title=Vim_for_Writers function! WordCount() let s:old_status = v:statusmsg let position = getpos(".") exe ":silent normal g\" let stat = v:statusmsg let s:word_count = 0 if stat != '--No lines in buffer--' let s:word_count = str2nr(split(v:statusmsg)[11]) let v:statusmsg = s:old_status end call setpos('.', position) return s:word_count endfunction au VimEnter * call s:airline_sections_custom() function! s:airline_sections_custom() " add current session name to statusline "http://stackoverflow.com/questions/11374047/adding-the-current-session-filename-in-the-statusline add current session name to statusline let g:airline_section_x = airline#section#create(['filetype', ' %{fnamemodify(v:this_session, ":t")}']) " let g:airline_section_z = airline#section#create(["%{noscrollbar#statusline(20,' ','▓',['▐'],['▌'])}", '%02p%% : %l: %c', ' %{WordCount()}w']) let g:airline_section_z = airline#section#create(['%02p%% : %l: %c', ' %{WordCount()}w']) endfunction " my custom combination theme: let g:airline_theme='darkfox' " powerline symbols let g:airline_left_sep = '' " let g:airline_left_alt_sep = '' let g:airline_right_sep = '' " let g:airline_right_alt_sep = '' if !exists('g:airline_symbols') let g:airline_symbols = {} endif let g:airline_powerline_fonts = 1 let g:airline_symbols.branch = '' let g:airline_symbols.readonly = '' " turn off mixed indent, trailing space let g:airline_section_warning = '' " nrrwrgn integration let g:airline#extensions#nrrwrgn#enabled = 1 " vcs integration let g:airline#extensions#branch#enabled = 1 " show summary of changed hunks (gitgutter and vim-signify) let g:airline#extensions#hunks#enabled = 1 " syntastic integration let g:airline#extensions#syntastic#enabled = 1 " tabline w/ taboo integration let g:airline#extensions#tabline#enabled = 1 let g:airline#extensions#taboo#enabled = 1 " show tab number instead of number of splits let g:airline#extensions#tabline#tab_nr_type = 1 " }}} " }}} " #============================== " # General Mappings/ Bindings {{{ " #============================== " _Colemak/Navigation Mappings/Improvements {{{ " make colemak t more useful let g:mapleader = "t" " modified from here: " https://github.com/bunnyfly/dotfiles/blob/master/vimrc " http://forum.colemak.com/viewtopic.php?id=1808 " My changes: " .keep i and don't have a dedicated right " .l for 'last' instead of line " up/down, including softwraps noremap n gj|noremap e gk|nnoremap gn j|nnoremap ge k " get back default gn nnoremap gk gn xnoremap gk gn " keep in visual xnoremap n j|xnoremap e k " High/Low/Mid. " I never use gm or select mode; would rather have go to middle of window not line noremap gh H|noremap gm M|noremap gl L " l for last nnoremap l zvzz nnoremap L zvzz " Keep the cursor in place while joining lines nnoremap j mzJ`z " https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc#cl-398 " Split line (sister to [J]oin lines); normal use of S is covered by cc nnoremap S i^mwgk:silent! s/\v +$//:noh`w nmap S " quickfix nav augroup quickfix au! au FileType qf call s:qf_settings() augroup END function! s:qf_settings() nnoremap n j nnoremap e k endfunction " Fold Navigation/Creation {{{ " put comment char at sol (before text) with zf and add space between comment char and marker " fix this " xnoremap zf zf$3hr:TComment mode=Kzo]za[zzc " swapping folds with tommcdo's exchange and kana's fold text object nmap zE vazXzkvazX nmap zN vazXzjvazX " jump nnoremap ze zk:silent! call repeat#set("zk", v:count) nnoremap zn zj:silent! call repeat#set("zj", v:count) nnoremap fe zk:silent! call repeat#set("zk", v:count) nnoremap fn zj:silent! call repeat#set("zj", v:count) nnoremap fu ]z:silent! call repeat#set("]z", v:count) nnoremap fd [z:silent! call repeat#set("[z", v:count) " open/close nnoremap za nnoremap fh zmzz:silent! call repeat#set("zmzz", v:count) nnoremap fi zrzz:silent! call repeat#set("zrzz", v:count) nnoremap fo zRzz:silent! call repeat#set("zRzz", v:count) nnoremap fk zMzz:silent! call repeat#set("ZMzz", v:count) " https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc#cl-651 " put current line at center and close surrounding folds nnoremap zl mzzMzvzz`z " }}} " Search {{{ " noremap k nzozz|noremap K Nzozz nmap k (Oblique-n) nmap K (Oblique-N) " get rid of visual mode mappings for n xmap Qq (Oblique-n) xmap QQ (Oblique-N) " map k to do visual star instead xmap k (Oblique-*) xmap K (Oblique-#) augroup oblique au! " center and open enough folds after search, star, and repeat au User Oblique normal! zvzz au User ObliqueStar normal! zvzz au User ObliqueRepeat normal! zvzz augroup END " }}} " }}} " Modified Defaults {{{ " commandline " I never really need , and ; nnoremap ; : xnoremap ; : nnoremap ; q:i xnoremap ; q:i augroup cmdwin au! " use escape in "normal" to exit cmdwin: au CmdwinEnter * nnoremap c " enter in "normal" to execute command under cursor and re-enter q: au CmdwinEnter * nnoremap q: augroup END " using sneak, so unecessary " this, uncommented, is also annoying with nmaps/plugs (e.g. can't nmap (something):somecommand) " nnoremap : ; " Y like D nnoremap Y y$ " http://hashrocket.com/blog/posts/8-great-vim-mappings " yank paragraph nnoremap yp yapp " Sane redo. noremap U " I use a more than A nnoremap a A nnoremap A a " visual block nnoremap v xnoremap v V " because I hate Q; apply macro nnoremap Q @q xnoremap Q :norm @q " centering an opening folds nnoremap G Gzvzz " https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc#cl-579 " move to last change (gi moves to last insert point) nnoremap gI `.a " go to file with optional line number, open folds, and center nnoremap gf gFzvzz " use m for "mode" or filetype specific bindings " nnoremap M m " }}} " Other General Mappings {{{ " jump up and down nnoremap k zz:silent! call repeat#set("zz", v:count) nnoremap o zz:silent! call repeat#set("zz", v:count) xnoremap k zz xnoremap o zz " control backspace behaviour inoremap ¸ cnoremap ¸ nnoremap ¸ daw inoremap .uu " paste in insert and command mode inoremap .yp + cnoremap .yp + " source vimrc nnoremap . :so ~/.vimrc " source current buffer nnoremap g. :so % " source line or selection; https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc#cl-405 nnoremap S ^vg_y:execute @@:echo 'Sourced line.' xnoremap S y:execute @@:echo 'Sourced selection.' "'x-ray' view; cuc and cul nnoremap x :set cursorcolumn!\|set cursorline! " open with rifle function! OpenCurrentLine() " https://github.com/gotbletu/shownotes/blob/master/mlocate_vdiscover_vim_locate.txt " grab current line let line = getline (".") " remove leading whitespace let line = substitute(line, '^\s', '', "g") " add qoutes around the current line to avoid spaces/symbols issues let line = substitute(line, '^\(.*\)$', '"\1"', "g") " changed to open with rifle (don't use with dirs/text files; use gf that) exec "!rifle" line '>&/dev/null &' endfunction " bind function to a hotkey nnoremap go :call OpenCurrentLine() " }}} " _Clipboard/Yank/Paste Related {{{ " use +/clipboard as default register set clipboard=unnamedplus " http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/ " move to end after yank or paste; similar to gp but won't go to next line xnoremap y y`] xnoremap p p`] nnoremap p p`] " since have above, change gp to paste on new line nnoremap gp :pu nnoremap gy V`] " https://github.com/Shougo/unite.vim/issues/415 let g:unite_source_history_yank_enable = 1 " saves things in clipboard register even if not yanked in vim let g:unite_source_history_yank_save_clipboard = 1 " don't save yanks to disk let g:unite_source_history_yank_file="" " let g:unite_source_history_yank_limit = 300 nnoremap y :Unite history/yank " }}} " }}} " #============================== " # Commands/ Shell {{{ " #============================== " get rid of trailing whitespace; don't remember where got this from command! Tr normal! mz:%s/\s\+$//:let @/=''`z " copy current file path to clipboard command! Yp let @+=expand("%:p") " Shell Specific nnoremap :let @+=expand("%:p"):!xterm -e "+" & " mappings for in navigation.vim command! ViewTxtPdf :!prose2pdf -v % & " command! CurrentChapterStats :! " " }}} " #============================== " # Plugin Unmaps {{{ " #============================== autocmd VimEnter * silent! nunmap tt " replace camelcase's ib map autocmd VimEnter * omap ib (textobj-anyblock-i)|xmap ib (textobj-anyblock-i) " }}} " #============================== " # Buffer, Window, and Tab Management Mappings and Settings {{{ " #============================== nnoremap q 1gt nnoremap w 11gt " re-setup session/tabs and close other buffers nnoremap ,ks 1gt:tabonly:only:e ~/.vimrc:vsplit ~/.zshrc:tabe ~/ag-sys/Else/everything/log.txt:tabe ~/ag-sys/Else/everything/arch_and_program_info.txt:vsplit ~/ag-sys/Else/everything/everything_index.txt:TabooRename main:tabe ~/ag-sys/Else/everything/\#browse.txt:TabooRename browse:tabe ~/.navigation.vim:TabooRename config:tabe ~/dotfiles/post_install/post_install.sh:TabooRename bin:tabe ~/ag-sys/Else/everything/\#remapping.txt:TabooRename remap:tabe ~/ag-sys/Else/everything/another/consume/book_notes.txt:vsplit ~/ag-sys/Else/everything/other/music/listen/music.txt:TabooRename cons:tabe ~/ag-sys/Else/everything/another/_prose/pots/draft_a.txt:vsplit ~/ag-sys/Else/everything/another/_prose/pots/plot.txt:TabooRename wr:tabnew:TabooRename wr:tabnew:Wipeout2gt " repls; vimshell has some annoyances though (lack of visual updating when window not active, weird cursor blinking, errors, etc.) nnoremap ,kl :TabooRename prog:VimShellInteractive --split='vsplit' sbcl nnoremap ,kp :TabooRename prog:VimShellInteractive --split='vsplit' python nnoremap ,kh :TabooRename prog:VimShellInteractive --split='vsplit' ghci source ~/.navigation.vim augroup navigationSourcing au! au BufEnter * so ~/.navigation.vim augroup END " General Quickmarks {{{ nnoremap ,a :e ~/ag-sys/Else/everything/arch_and_program_info.txt nnoremap ,b :e ~/ag-sys/Else/everything/\#browse.txt nnoremap ,B :e ~/.config/bspwm/bspwmrc nnoremap ,c :e ~/.config/ranger/rc.conf nnoremap ,d :e ~/ag-sys/Else/everything/another/ideas.txt nnoremap ,e :e ~/ag-sys/Else/everything/everything_index.txt nnoremap ,E :e ~/.emacs.d/awaken.org nnoremap ,g :e ~/.pentadactyl/groups.penta nnoremap ,i :e ~/ag-sys/Else/everything/interaction.txt nnoremap ,I :e ~/dotfiles/post_install/post_install.txt nnoremap ,j :e ~/ag-sys/Else/everything/journal.txt nnoremap ,l :e ~/ag-sys/Else/everything/log.txt nnoremap ,m :e ~/.muttrc nnoremap ,M :e ~/ag-sys/Else/everything/other/music/listen/music.txt nnoremap ,n :e ~/.navigation.vim nnoremap ,p :e ~/.pentadactylrc nnoremap ,P :e ~/ag-sys/Else/everything/policy.txt nnoremap ,r :e ~/ag-sys/Else/everything/\#remapping.txt nnoremap ,R :e ~/.README.md nnoremap ,t :e ~/.tmux.conf nnoremap ,v :e ~/.vimrc nnoremap ,x :e ~/.xinitrc nnoremap ,y :Unite -start-insert buffer file_mru.yml nnoremap ,z :e ~/.zshrc nnoremap ,2 :e ~/ag-sys/Else/everything/\#20xx.txt " }}} " Tabs {{{ nnoremap t :tabnew " go to last tab nnoremap l :TWcmd tcm p " move tabs nnoremap N :tabm -1 nnoremap E :tabm +1 " Taboo {{{ " default tab naming behaviour let g:taboo_modified_tab_flag='+' let g:taboo_tab_format='%m%f' let g:taboo_renamed_tab_format='[%l]%m' " save taboo names in session set sessionoptions+=tabpages,globals nnoremap r :TabooRename " }}} " }}} " Windows/Splits {{{ nnoremap q :q nnoremap x c nnoremap ' :vsplit nnoremap - :split nnoremap h nnoremap i nnoremap N nnoremap E " vim window maximize (using instead of ZoomWin); still accessible (see border) nnoremap sm :TWcmd wcm m " Wipeout (close buffers not open in windows) nnoremap W :Wipeout " Moving windows around. (if ever needed) nnoremap N J|nnoremap E K|nnoremap I L " vim-eighties let g:eighties_enabled = 1 let g:eighties_minimum_width = 110 let g:eighties_extra_width = 0 " Increase this if you want some extra room let g:eighties_compute = 1 " Disable this if you just want the minimum + extra " https://github.com/talek/obvious-resize " }}} " Bufkill {{{ " move forward and back in buffer history (for window) nnoremap l :BB nnoremap L :BF " delete buffer and leave window open and switch to last used buffer (bufkill) nnoremap d :BD " }}} " }}} " #============================== " # Operators, Motions, etc. {{{ " #============================== " more convenient motions " going to a byte is useless to me nnoremap go }:silent! call repeat#set("}", v:count) nnoremap gO {:silent! call repeat#set("{", v:count) " camelcase motion as default {{{ map w CamelCaseMotion_w map b CamelCaseMotion_b map j CamelCaseMotion_e sunmap w sunmap b sunmap j " default iw (camelcase's iw deletes spaces like aw and newline chars; ie is closer to default iw) omap iw CamelCaseMotion_ie xmap iw CamelCaseMotion_ie " }}} " vcs hunks {{{ omap ih (signify-motion-inner-pending) xmap ih (signify-motion-inner-visual) omap ah (signify-motion-outer-pending) xmap ah (signify-motion-outer-visual) " }}} " operator-surround {{{ " using this, not tpope's surround map sa (operator-surround-append) map sd (operator-surround-delete) map sc (operator-surround-replace) " delete or replace most inner surround nmap sdd (operator-surround-delete)(textobj-anyblock-a) nmap scc (operator-surround-replace)(textobj-anyblock-a) nmap saw saiW' nmap sae sa$" nmap sal sail" " }}} " sentence text object {{{ let g:textobj#sentence#abbreviations = [ \ '[ABCDIMPSUabcdegimpsv]', \ 'l[ab]', '[eRr]d', 'Ph', '[Ccp]l', '[Lli]n', '[cn]o', \ '[Oe]p', '[DJMSh]r', '[MVv]s', '[CFMPScfpw]t', \ 'alt', '[Ee]tc', 'div', 'es[pt]', '[Ll]td', 'min', \ '[MD]rs', '[Aa]pt', '[Aa]ve?', '[Ss]tr?', \ '[Aa]ssn', '[Bb]lvd', '[Dd]ept', 'incl', 'Inst', 'Prof', 'Univ', \ ] let g:textobj#sentence#select = 's' let g:textobj#sentence#move_p = '(' let g:textobj#sentence#move_n = ')' " augroup textobjSentence au! au FileType markdown,mkd call textobj#sentence#init() au FileType rst call textobj#sentence#init() au FileType text call textobj#sentence#init() augroup END " }}} " comment text object {{{ " nice for moving and formatting comments (gqax) let g:textobj_comment_no_default_key_mappings = 1 xmap ax (textobj-comment-a) omap ax (textobj-comment-a) " }}} " narrow region {{{ " thanks to ddungtang for pointing me to this plugin: " http://www.reddit.com/r/vim/comments/298049/question_on_repetitively_making_changes_to_the/ " just to get rid of normal mode mapping the plugin makes by default nmap ZXY NrrwrgnDo " for changing the same areas across multiple lines " open selected text, delete all of it, map escape to save changes and close win xmap S NrrwrgnDodG;inoremap esc> esc>:wqcr> " }}} " letters instead of symbols {{{ " paRens omap ir i( omap ar a( xmap ir i( xmap ar a( " angle brackets (not noremap because text objectify) omap ia i< omap aa a< xmap ia i< xmap aa a< " sqUare omap iu i[ omap au a[ xmap iu i[ xmap au a[ " kurly omap ik i{ omap ak a{ xmap ik i{ xmap ak a{ " shorten when possible (e.g. not for word) for i or a " https://github.com/beloglazov/vim-textobj-quotes " ',", and ` omap q iq xmap q iq omap r i( xmap r i( omap u i[ xmap u i[ omap k i{ " k for viual star " also have anyblock " }}} " }}} " #============================== " # Plugin Bindings and Settings {{{ " #============================== " Snippets and Completion {{{ " UltiSnips {{{ let g:UltiSnipsExpandTrigger = ",e" let g:UltiSnipsJumpForwardTrigger = ",f" let g:UltiSnipsJumpBackwardTrigger = ",b" " let g:UltiSnipsSnippetsDir="~/.vim/UltiSnips" " }}} " requires if_lua if !has('nvim') " NeoComplete {{{ let g:neocomplete#enable_at_startup = 0 " borrow from bundle bindings for now... nnoremap bt :NeoCompleteToggle "toggle neocomplete in insert (i.e. for file name completion) inoremap ,nt :NeoCompleteToggle " scroll through menu " inoremap pumvisible() ? "\" : "\" " inoremap pumvisible() ? "\" : "\" augroup tabWithNeocomplete " prevent tab binding from being overriden with autocmd au! " https://github.com/Shougo/neocomplete.vim/issues/32 au Bufenter * inoremap pumvisible() ? "\" : \ check_back_space() ? "\" : \ neocomplete#start_manual_complete() function! s:check_back_space() let col = col('.') - 1 return !col || getline('.')[col - 1] =~ '\s' endfunction augroup END " for backwards in completion menus inoremap " Use smartcase. let g:neocomplete#enable_smart_case = 1 " Set minimum syntax keyword length. let g:neocomplete#sources#syntax#min_keyword_length = 4 let g:neocomplete#lock_buffer_name_pattern = '\*ku\*' " Define dictionary. let g:neocomplete#sources#dictionary#dictionaries = { \ 'default' : '', \ 'vimshell' : $HOME.'/.vimshell_hist', \ } augroup neoCompleteSettings au! au FileType * NeoCompleteLock " au FileType java NeoCompleteEnable " Enable omni completion. au FileType css setlocal omnifunc=csscomplete#CompleteCSS au FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags au FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS au FileType python setlocal omnifunc=pythoncomplete#Complete au FileType xml setlocal omnifunc=xmlcomplete#CompleteTags augroup END " }}} endif " }}} " _Unite Related {{{ " http://www.codeography.com/2013/06/17/replacing-all-the-things-with-unite-vim.html " http://eblundell.com/thoughts/2013/08/15/Vim-CtrlP-behaviour-with-Unite.html let g:unite_split_rule = "topleft" " tmi let g:unite_source_buffer_time_format = '' let g:unite_source_buffer_filename_format = '' " more mru let g:unite_source_file_mru_long_limit = 3000 let g:unite_source_file_rec_max_cache_files = 5000 " fuzzy matching; sorting " call unite#filters#matcher_default#use(['matcher_fuzzy']) " call unite#filters#sorter_default#use(['sorter_rank']) " colemak let g:unite_quick_match_table = { \ 'a' : 0, 'r' : 1, 's' : 2, 't' : 3, 'd' : 4, 'h' : 5, 'n' : 6, 'e' : 7, 'i' : 8, 'o' : 9, \ 'w' : 10, 'f' : 11, 'p' : 12, 'l' : 13, 'u' : 14, 'y' : 15, 'x' : 16, 'c' : 17, 'v' : 18, 'k' : 19, \ '1' : 20, '2' : 21, '3' : 22, '4' : 23, '5' : 24, '6' : 25, '7' : 26, '8' : 27, '9' : 28, '0' : 29, \ } " Search open buffers and most recently used " only reason for p is because used to use control-p nnoremap p :Unite -start-insert buffer file_mru " Search files; this is overriden for certain tabs in ~/.navigation.vim nnoremap P :cd ~/dotfiles\|Unite -start-insert file_rec/async " search with locate; overriden for certain tabs in ~/.navigation.vim nnoremap p :Unite -start-insert locate " source for outline of file (e.g. function jumping) nnoremap U :Unite -start-insert outline " for folds in file (e.g. dotoo/org headings) nnoremap u :Unite -start-insert fold " searching; silver searcher {{{ " http://bling.github.io/blog/2013/06/02/unite-dot-vim-the-plugin-you-didnt-know-you-need/ let g:unite_source_grep_command = "ag" " ag is recursive; does not need -r let g:unite_source_grep_recursive_opt = "" let g:unite_source_grep_default_opts = \ '--smart-case --line-numbers --nocolor --nogroup --hidden --ignore ' . \ '''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr''' " search current buffer wth ag and display results in unite window " nnoremap / :Unite grep:% " interactive search (instead of typing search term before; real time results) nnoremap / :Unite line -start-insert " use last search nnoremap ? :Unite grep:%/ " search recursively nnoremap / :Unite grep:. nnoremap ? :Unite grep:./ " ag motion with kana's operator user map ga (operator-ag) map gA (operator-ag-recursive) autocmd VimEnter * call operator#user#define('ag', 'Ag_motion') autocmd VimEnter * call operator#user#define('ag-recursive', 'Ag_motion_recursive') function! Ag_motion(motion_wise) let v = operator#user#visual_command_from_wise_name(a:motion_wise) execute 'normal!' '`[' . v . '`]y' execute "Unite grep:%::" . fnameescape(getreg('+')) endfunction function! Ag_motion_recursive(motion_wise) let v = operator#user#visual_command_from_wise_name(a:motion_wise) execute 'normal!' '`[' . v . '`]y' execute "Unite grep:.::" . fnameescape(getreg('+')) endfunction " }}} augroup unite au! au FileType unite call s:unite_settings() augroup END function! s:unite_settings() " let me exit with escape and move with colemak bindings nmap (unite_exit) nmap n j " nmap n (unite_skip_cursor_down) nmap e k " nmap e (unite_skip_cursor_up) " opening with rifle action let rifleAction = { 'is_selectable' : 1 } function! rifleAction.func(items) for item in a:items execute '!rifle ' . item.word endfor endfunction call unite#custom#action('file,cdable', 'rifle', rifleAction) endfunction " }}} " Vimfiler {{{ " use instead of netrw (e.g. with gf or if use vim to open a dir) " use with vinegar let g:vimfiler_as_default_explorer = 1 augroup vimfiler au! au FileType vimfiler call s:vimfiler_mappings() au FileType vimfiler NeoCompleteDisable augroup END function! s:vimfiler_mappings() " colemak map n (vimfiler_loop_cursor_down) map e (vimfiler_loop_cursor_up) map gn (vimfiler_jump_last_child) map ge (vimfiler_jump_first_child) map i (vimfiler_smart_l) map o (vimfiler_edit_file) map q (vimfiler_exit) map (vimfiler_expand_tree) map t endfunction " }}} " _Git Related {{{ " https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc#cl-233 " Highlight VCS conflict markers match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$' " Follow Symlinks When Opening a File {{{ " Sources: " - https://github.com/tpope/vim-fugitive/issues/147#issuecomment-7572351 " - http://www.reddit.com/r/vim/comments/yhsn6/is_it_possible_to_work_around_the_symlink_bug/c5w91qw " this isn't as good as emacs' (setq vc-follow-symlinks "t") because have to use :w! to save after... function! MyFollowSymlink(...) let fname = a:0 ? a:1 : expand('%') if getftype(fname) != 'link' return endif let resolvedfile = fnameescape(resolve(fname)) exec 'file ' . resolvedfile endfunction command! FollowSymlink call MyFollowSymlink() augroup followSym au! au BufReadPost * call MyFollowSymlink(expand('')) augroup END " }}} " Fugitive {{{ " git add nnoremap ga :Gwrite " interactive status " cc to commit; ca to ammend nnoremap gs :Gstatus nnoremap gc :Gcommit nnoremap gp :Git push " for staging parts nnoremap gd :Gvdiff " nnoremap gb :Git branch nnoremap go :Git checkout nnoremap gl :Clam git loggg " http://mislav.uniqpath.com/2014/02/hidden-documentation/ nnoremap gB :Gblame nnoremap gb :Gbrowse " get previous commit version of buffer (can just undo) nnoremap gr :Gread nnoremap gm :Gmove " this will delete on disk " nnoremap gR :Gremove " git rm --cached " https://github.com/PonderingGrower/dotfiles/blob/master/.vimrc augroup fugitiveSettings au! " same bindings for merging diffs as in normal mode au BufRead fugitive://* call s:diff_bindings() au FileType fugitiveblame call s:blame_bindings() " bindings for git status window au FileType gitcommit nmap n |nmap e augroup END function! s:blame_bindings() nnoremap :Gbrowse nmap p P endfunction function! s:diff_bindings() xnoremap dp :diffput xnoremap do :diffget xnoremap du :diffupdate endfunction " }}} " vim-signify settings {{{ " which vcs and order let g:signify_vcs_list = [ 'git', 'hg' ] let g:signify_disable_by_default = 0 " eating clipboard again? " let g:signify_update_on_focusgained = 1 let g:signify_sign_change = '~' nmap gn (signify-next-hunk):silent! call repeat#set("\(signify-next-hunk)", v:count) nmap ge (signify-prev-hunk):silent! call repeat#set("\(signify-prev-hunk)", v:count) let g:signify_mapping_toggle_highlight = 'gh' " }}} " }}} " Visual {{{ " vim-signature and vim-bookmarks {{{ " marks are letters, markers are 0-9 (which correspond to shifted symbols) " not using g:SignatureMap for mn and me, because want repeatable " ugly, but works nmap me `[:silent! call repeat#set("`[", v:count) nmap mn `]:silent! call repeat#set("`]", v:count) " not tied to a letter; probably won't use anotations often or ever " mm to toggle mark; mi to add anotation; overriding mn let g:bookmark_sign = '♥' " center when jumping to a bookmark let g:bookmark_center = 1 let g:bookmark_no_default_key_mappings = 1 nnoremap m/ :Unite mark vim_bookmarks " }}} " Goyo & Limelight {{{ " toggle goyo nnoremap gy :Goyo " settings let g:goyo_width = 120 " limelight function! GoyoBefore() Limelight endfunction function! GoyoAfter() Limelight! endfunction let g:goyo_callbacks = [function('GoyoBefore'), function('GoyoAfter')] " }}} " Syntastic {{{ " from bling/dotvim let g:syntastic_error_symbol = '✗' let g:syntastic_style_error_symbol = '✠' let g:syntastic_warning_symbol = '∆' let g:syntastic_style_warning_symbol = '≈' " }}} " }}} " For Specific FileTypes {{{ " Emmet-vim {{{ imap ,he (emmet-expand-abbr) " just for html and css let g:user_emmet_install_global = 0 augroup emmet au! au FileType html,css EmmetInstall augroup END " }}} " Vim Markdown {{{ let g:markdown_fold_style = 'stacked' " let g:vim_markdown_no_default_key_mappings=1 " let g:vim_markdown_folding_disabled=0 augroup mkdown au! au FileType mkd call s:mkd_mappings() augroup END function! s:mkd_mappings() " share leader m with table mode nnoremap mt :Toc " preview nnoremap mp :call LivedownPreview() " experimenting with this; normally just use zn ze but don't really like the way it folds it nmap mn (Markdown_MoveToNextHeader):silent! call repeat#set("\Markdown_MoveToNextHeader", v:count) nmap me (Markdown_MoveToPreviousHeader):silent! call repeat#set("\Markdown_MoveToPreviousHeader", v:count) nmap mc (Markdown_MoveToCurHeader):silent! call repeat#set("\Markdown_MoveToCurHeader", v:count) nmap mu (Markdown_MoveToParentHeader):silent! call repeat#set("\Markdown_MoveToParentHeader", v:count) endfunction " }}} " }}} " 'New' FileTypes (wiki, calendar, org) {{{ " VimWiki (using like TabsOutliner with pentadactyl) {{{ " tww to go to index " tws select from multiple wikis let g:vimwiki_list = [{ \ 'path': '~/vimwiki/', \ 'path_html': '~/vimwikihtml/', \ 'maxhi': 1, \ 'css_name': 'style.css', \ 'auto_export': 0, \ 'nested_syntaxes': {}, \ 'html_header': '', \ 'html_footer': '', \ 'syntax': 'default', \ 'index': 'index', \ 'ext': '.wiki', \ 'temp': 0 \ }] " Don't automatically make CamelCase words links. let g:vimwiki_camel_case = 0 augroup vimwiki au! au FileType vimwiki call s:vimwiki_keys() augroup END function! s:vimwiki_keys() nmap i VimwikiFollowLink nmap h VimwikiGoBackLink endfunction " }}} " dotoo {{{ " maybe use with below for quick keys like behaviour " https://github.com/kana/vim-submode let g:dotoo#agenda#files = ['~/ag-sys/Else/everything/log.org'] " don't clock captures let g:dotoo#capture#clock = 0 let g:dotoo#parser#todo_keywords = [ \ 'TODO', \ 'NEXT', \ 'WAITING', \ 'MEETING', \ 'DONE'] " default let g:dotoo#capture#templates = [ \ ['t', 'Todo', ['* TODO %?', \ 'DEADLINE: [%(strftime(g:dotoo#time#datetime_format))]']], \ ['n', 'Note', '* %? :NOTE:'], \ ['m', 'Meeting', '* MEETING with %? :MEETING:'], \ ['p', 'Phone call', '* PHONE %? :PHONE:'], \ ['h', 'Habit', ['* NEXT %?', \ 'SCHEDULED: [%(strftime(g:dotoo#time#date_day_format)) +1m]', \ ':PROPERTIES:', \ ':STYLE: habit', \ ':REPEAT_TO_STATE: NEXT', \ ':END:']] \ ] " https://github.com/dhruvasagar/vim-dotoo/issues/6 " fix color alloc errors let g:dotoo_todo_keyword_faces = [ \ ['TODO', [':foreground #d46a6a', ':weight bold']], \ ['NEXT', [':foreground #d49a6a', ':weight bold']], \ ['DONE', [':foreground #0d4d4d', ':weight bold']], \ ['WAITING', [':foreground #55aa55', ':weight bold']], \ ['HOLD', [':foreground #669999', ':weight bold']], \ ['CANCELLED', [':foreground #552700', ':weight bold']], \ ['MEETING', [':foreground #ffaaaa', ':weight bold']], \ ['PHONE', [':foreground #aa6c39', ':weight bold']] \ ] " }}} " }}} " Allignment {{{ " Easy Allign {{{ " Start interactive EasyAlign in visual mode (e.g. vip) xmap a (EasyAlign) " Start interactive EasyAlign for a motion/text object (e.g. aip) nmap a (EasyAlign) " }}} " Table Mode {{{ let g:table_mode_map_prefix = 'm' let g:table_mode_toggle_map = 'm' " }}} " }}} " Shell Related {{{ " Vimshell {{{ " Use current directory as vimshell prompt. let g:vimshell_prompt_expr = \ 'escape(fnamemodify(getcwd(), ":~").">", "\\[]()?! ")." "' let g:vimshell_prompt_pattern = '^\%(\f\|\\.\)\+> ' let g:vimshell_popup_command = 'vsplit' " let g:vimshell_no_default_keymappings=0 augroup vimshell au! au FileType vimshell call s:vimshell_mappings() augroup END function! s:vimshell_mappings() " Normal mode key-mappings. {{{ " Execute command. nmap (vimshell_enter) " Hide vimshell. " nmap q (vimshell_hide) " Exit vimshell. nmap Q (vimshell_exit) " Move to previous prompt. nmap e (vimshell_previous_prompt) " Move to next prompt. nmap n (vimshell_next_prompt) " Paste this prompt. " nmap (vimshell_paste_prompt) " Search end argument. nmap E (vimshell_move_end_argument) " Change line. nmap cc (vimshell_change_line) " Delete line. nmap dd (vimshell_delete_line) " Start insert. nmap I (vimshell_insert_head) nmap i (vimshell_insert_enter) " swapped nmap A (vimshell_append_enter) nmap a (vimshell_append_end) nmap ^ (vimshell_move_head) " Interrupt. nmap q (vimshell_interrupt) nmap (vimshell_hangup) " Clear. nmap c (vimshell_clear) " Execute background. " nmap (vimshell_execute_by_background) " History completion. nmap (vimshell_history_unite) " }}} " Visual mode key-mappings. {{{ " Move to previous prompt. xmap e (vimshell_select_previous_prompt) " Move to next prompt. xmap n (vimshell_select_next_prompt) " }}} " Insert mode key-mappings. {{{ " Execute command. inoremap (bs-ctrl-]) \ getline('.')[col('.') - 2] ==# "\" ? "\" : '' imap (bs-ctrl-]) imap (vimshell_enter) " inoremap pumvisible() ? "\" : " \ start_history_complete() " inoremap pumvisible() ? "\" : " \ start_history_complete() " inoremap pumvisible() ? "\" : " \ start_history_complete() " inoremap pumvisible() ? "\" : " \ start_history_complete() " imap (vimshell_history_neocomplete) " Command completion. imap (vimshell_command_complete) " Move to Beginning of command. imap (vimshell_move_head) " Delete all entered characters in the current line. imap (vimshell_delete_backward_line) " Delete previous word characters in the current line. imap ¸ (vimshell_delete_backward_word) " Push current line to stack. imap vimshell#mappings#smart_map( \ "\(vimshell_push_current_line)", \ "\(vimshell_execute_by_background)") " Insert last word. " imap (vimshell_insert_last_word) " Interrupt. imap (vimshell_interrupt) " Delete char. imap (vimshell_delete_backward_char) " }}} endfunction " }}} " Clam {{{ let g:clam_winpos = 'topleft' " }}} " }}} " Other {{{ " NeoBundle {{{ nnoremap bi :Unite neobundle/install nnoremap bu :NeoBundleUpdate! nnoremap bs :Unite neobundle/search nnoremap bl :NeoBundleList " broswerlink maps bc ... augroup ovewriteBLMap au! au VimEnter * nnoremap bc :NeoBundleClean au BufWritePost ~/dotfiles/vim/.vimrc nnoremap bc :NeoBundleClean augroup END " }}} " Gundo {{{ nnoremap u :GundoToggle let g:gundo_map_move_older = "n" let g:gundo_map_move_newer = "e" " }}} " tcomment {{{ nnoremap c :TComment xnoremap c :TComment nnoremap C :TCommentBlock xnoremap C :TCommentBlock call tcomment#DefineType('text', '# %s' ) call tcomment#DefineType('lisp', ';; %s' ) call tcomment#DefineType('pentadactyl', '" %s' ) " don't use block comments for single lines by default call tcomment#DefineType('java', '// %s' ) call tcomment#DefineType('c', '// %s' ) " }}} " vim-session: {{{ " quickly open session nnoremap ss :OpenSession let g:session_autosave_periodic='yes' let g:session_autosave='yes' " automatically load ~/.vim/sessions/default.vim let g:session_autoload='yes' " let g:session_persist_globals = ['&sessionoptions'] " call add(g:session_persist_globals, 'g:Taboo_tabs') " }}} " Sneak Settings {{{ " 1 means use ignorecase or smartcase if set (have smartcase set) let g:sneak#use_ic_scs = 1 " use streak mode (easy motion highlighting) when > 1 match on screen let g:sneak#streak = 1 " use sneak key to go to next (and back) (f and F for me) let g:sneak#s_next = 1 let g:sneak#textobject_z = 0 " colemak chars for sneak mode; take out i for insert; d out to delete; take out f for go to next let g:sneak#target_labels = "arsthneowpluy/ARSTDHNEIOFPLUY" " mappings nmap f SneakForward nmap F SneakBackward xmap f Sneak_s xmap F Sneak_S omap f Sneak_s omap F Sneak_S hi link SneakStreakTarget ErrorMsg " }}} " Vertigo {{{ " colemak let g:Vertigo_homerow = 'arstdhneio' let g:Vertigo_onedigit_method = 'smart3' nnoremap n :VertigoDown n xnoremap n :VertigoDown v onoremap n :VertigoDown o nnoremap e :VertigoUp n xnoremap e :VertigoUp v onoremap e :VertigoUp o " }}} " _Spell correct s mappings {{{ " correct current word with first suggestion nnoremap z 1z=:silent! call repeat#set(":spellr", v:count) " goto sleep is useless; go to next mispelled nnoremap gs ]s:silent! call repeat#set("]s", v:count) nnoremap ]s ]s:silent! call repeat#set("]s", v:count) nnoremap [s [s:silent! call repeat#set("[s", v:count) " repeatable correct next or current (if is current word under cursor is mispelled) mispelled word nnoremap CorrectNextMispell Tb]s1z= nnoremap sc Tb]s1z=:silent! call repeat#set("\CorrectNextMispell", v:count) " add word to spellfile (having a count will add to next spellfile e.g. 2zg) nnoremap sa ]szg:silent! call repeat#set("]szg", v:count) " mark word a wrong; zw; zuw; not sure if sm or zw is preferable nnoremap sm zw " lexical let g:lexical#spelllang = ['en_us','en_ca',] let g:lexical#thesaurus = ['~/.vim/thesaurus/mthesaur.txt',] let g:lexical#dictionary = ['/usr/share/dict/words',] augroup lexical au! au FileType markdown,mkd call lexical#init() au FileType text call lexical#init() au FileType rst call lexical#init() augroup END " correct with popup (except doesn't suck like z=) let g:lexical#spell_key = 'ss' let g:lexical#dictionary_key = 'sk' inoremap ,sk let g:lexical#thesaurus_key = 'st' " vim-online-thesaurus let g:online_thesaurus_map_keys = 0 nnoremap sw :OnlineThesaurusCurrentWord " }}} " auto-pairs {{{ " use closing bracket to jump outside even if not next char let g:AutoPairsFlyMode = 0 let g:AutoPairsShortcutBackInsert = '' " }}} " }}} " }}} " #============================== " # Neovim Specific {{{ " #============================== if has('nvim') " neomake augroup neomake au! au BufWritePost,CursorHold *.py,*.sh,*.c Neomake augroup END " https://github.com/neovim/neovim/issues/1172#issuecomment-74602464 function! MoveToTabOnLeft() let curtab = tabpagenr() let tabonleft = curtab - 1 exe tabonleft."tabnext" endfunction augroup tabonleft au! au TabClosed * call MoveToTabOnLeft() augroup END endif " }}} " #============================== " # NeoBundle {{{ " #============================== " NeoBundle Automatic Installation {{{ if !isdirectory(expand("$HOME/.vim/bundle/neobundle.vim")) !curl https://raw.githubusercontent.com/Shougo/neobundle.vim/master/bin/install.sh > install.sh && echo "run the install.sh script to install neobundle" endif " }}} " Required: set runtimepath+=~/.vim/bundle/neobundle.vim/ " Required: call neobundle#begin(expand('~/.vim/bundle/')) " Let NeoBundle manage NeoBundle " Required: NeoBundleFetch 'Shougo/neobundle.vim' " Plugins {{{ " Constantly Active/ Visual {{{ " show non-relative line numbers in insert NeoBundle 'myusuf3/numbers.vim' " mark navigation; show marks/markers in gutter NeoBundle 'kshenoy/vim-signature' " bookmarks NeoBundle 'MattesGroeger/vim-bookmarks' " vcs info NeoBundle 'mhinz/vim-signify' " tab renaming NeoBundle 'gcmt/taboo.vim' " automatic split resizing NeoBundle 'justincampbell/vim-eighties' " statusline NeoBundle 'bling/vim-airline' if has('nvim') " async for neovim NeoBundle 'benekastah/neomake' NeoBundleLazy 'scrooloose/syntastic' else " linter NeoBundle 'scrooloose/syntastic' " can't use async so no reason to be able to source NeoBundleFetch 'benekastah/neomake' endif " substitute preview (half of emacs functionality) NeoBundle "osyo-manga/vim-over" " rainbow parens NeoBundle 'oblitum/rainbow' " NeoBundle 'amdt/vim-niji' " distraction free writing NeoBundle 'junegunn/goyo.vim' " try distraction free https://github.com/DanielFGray/DistractionFree.vim NeoBundle 'junegunn/limelight.vim' " colorschemes NeoBundle 'morhetz/gruvbox' NeoBundle 'romainl/Apprentice' NeoBundle 'junegunn/seoul256.vim' NeoBundle 'altercation/vim-colors-solarized' NeoBundle 'sjl/badwolf' NeoBundle 'nice/sweater' NeoBundle 'whatyouhide/vim-gotham' NeoBundle 'shawncplus/skittles_berry"' NeoBundle 'idbrii/vim-sandydune' " }}} " Unite Related {{{ " https://github.com/Shougo/unite.vim/wiki/unite-plugins NeoBundle 'Shougo/unite.vim' " for async file search NeoBundle 'Shougo/vimproc.vim', { \ 'build' : { \ 'windows' : 'tools\\update-dll-mingw', \ 'cygwin' : 'make -f make_cygwin.mak', \ 'mac' : 'make -f make_mac.mak', \ 'linux' : 'make', \ 'unix' : 'gmake', \ }, \ } " extra sources: " mru NeoBundle 'Shougo/neomru.vim' " ahead of https://github.com/h1mesuke/unite-outline " opens unite with functions as lines NeoBundle 'Shougo/unite-outline' " unite source for marks (also see vim-bookmarks which gives vim_bookmarks) NeoBundle 'tacroe/unite-mark' " locate NeoBundle 'ujihisa/unite-locate' " for fold text/ navigation NeoBundle 'osyo-manga/unite-fold' " }}} " Case/Filetype Specific {{{ " git NeoBundle 'tpope/vim-fugitive' " html generation NeoBundle 'mattn/emmet-vim' " reload html page displayed in browser when changes NeoBundle 'jaxbot/browserlink.vim' " markdown folding, syntax highlighting, and navigation NeoBundle 'plasticboy/vim-markdown' " NeoBundle 'nelstrom/vim-markdown-folding' " markdown preview NeoBundle 'shime/vim-livedown' " haskell NeoBundle 'kana/vim-filetype-haskell' " NeoBundle 'ag/vim2hs' NeoBundle "Twinside/vim-hoogle" " rust highlighting and indentation NeoBundle 'wting/rust.vim' " repl interaction with tmux NeoBundle 'benmills/vimux' " for move and sudowrite commands NeoBundle 'tpope/vim-eunuch' " view undo tree NeoBundle 'sjl/gundo.vim' " password syntax highlighting/hiding stuff NeoBundle 'aaronbieber/vim-vault' " wikis NeoBundle 'vimwiki/vimwiki' " openscad syntax highlighting NeoBundle 'torrancew/vim-openscad' " }}} " Writing {{{ " smarter sentence text object (kana's text object user is a dependency) NeoBundle 'reedes/vim-textobj-sentence' NeoBundle 'reedes/vim-lexical' NeoBundle 'beloglazov/vim-online-thesaurus' NeoBundle 'reedes/vim-textobj-quote' " Rst NeoBundle 'Rykka/riv.vim' NeoBundle 'Rykka/InstantRst' " }}} " Other {{{ " compiling/ running code NeoBundle 'tpope/vim-dispatch' NeoBundle 'JarrodCTaylor/vim-shell-executor' " shell NeoBundle 'Shougo/vimshell.vim' NeoBundle 'sjl/clam.vim' " easymotion pretty much does everything now, but for simplicity using seak " sneak: a 2 letter multiline find NeoBundle 'justinmk/vim-sneak' " like better than other commenters by far NeoBundle 'tomtom/tcomment_vim' " NeoBundle 'tpope/vim-commentary' " NeoBundle 'scrooloose/nerdcommenter' " session management NeoBundle 'xolox/vim-session' NeoBundle 'xolox/vim-misc' " NeoBundle 'tpope/vim-obsession' " NeoBundle 'manuel-colmenero/vim-simple-session' " for buffer history and killing buffers without changing window layout or closing NeoBundle 'bufkill.vim' " alternatively: https://github.com/Soares/butane.vim " close all buffers not open in windows NeoBundle 'wipeout' " using for tab movement history NeoBundle 'yssl/twcmd.vim' " allignment NeoBundle 'junegunn/vim-easy-align' " NeoBundle 'godlygeek/tabular' NeoBundle 'dhruvasagar/vim-table-mode' " home row line jumping NeoBundle 'prendradjaja/vim-vertigo' " completion and snippets if has('nvim') " no lua support currently NeoBundleFetch 'Shougo/neocomplete.vim' else NeoBundle 'Shougo/neocomplete.vim' endif NeoBundle 'SirVer/ultisnips' " Optional NeoBundle "honza/vim-snippets" " smart auto closing parens, quotes, etc. NeoBundle 'jiangmiao/auto-pairs' " NeoBundle 'kana/vim-smartinput' " automatic ending in vimscript (endfunction), bash, etc. NeoBundle 'tpope/vim-endwise' " allows repeat (.) with plugin mappings NeoBundle 'tpope/vim-repeat' NeoBundle 'vim-scripts/visualrepeat' " neither of these are usable for me " NeoBundle 'terryma/vim-multiple-cursors' " NeoBundle 'paradigm/vim-multicursor"' " }}} " Experimenting {{{ NeoBundle 'tpope/vim-vinegar' " chording NeoBundle 'kana/vim-arpeggio' " file manager NeoBundle "Shougo/vimfiler.vim" " all text boxes vim NeoBundle 'ardagnir/vimbed' " improved "/" search NeoBundle 'junegunn/vim-oblique' " required for above NeoBundle 'junegunn/vim-pseudocl' " latex " NeoBundle "https://github.com/vim-scripts/TeX-9" " " japanese input; mapping something up in search... " NeoBundle "https://github.com/tyru/eskk.vim" " org mode NeoBundle 'dhruvasagar/vim-dotoo' " }}} " Operators and Text Objects {{{ " required for other stuff NeoBundle 'kana/vim-textobj-user' NeoBundle 'kana/vim-operator-user' " camelcase motion NeoBundle 'bkad/CamelCaseMotion' " cx operator to exchange; X for visual NeoBundle 'tommcdo/vim-exchange' " edit selected region in separate window NeoBundle 'chrisbra/NrrwRgn' " if do something like i{ seek for {} if outside of like vim already does with i' " make i' work for multiple lines like i{ would NeoBundle 'paradigm/TextObjectify' " adds ic, iC, ac, aC text objects; great for quickly working with columns/visual blocks NeoBundle 'coderifous/textobj-word-column.vim' " adds text object io and ao for indentation whitespace NeoBundle 'glts/vim-textobj-indblock' " text objects for comments NeoBundle 'glts/vim-textobj-comment' " iq and aq for ', ", and ` " NeoBundle 'beloglazov/vim-textobj-quotes' " haven't found to work well "https://github.com/lucapette/vim-textobj-underscore " punctuation text objects (also gives iq and aq);i.e. gives %; i will work for any NeoBundle 'kurkale6ka/vim-pairs' " using this instead because works well with text objects (i.e. ic) and makes more sense than doing something like ysiW: " gives sa{any text object} (surround append), sd, and sc " see http://www.reddit.com/r/vim/comments/2qozgi/vimoperatorsurround_operator_to_surround_a_text/cn8xcbf NeoBundle 'rhysd/vim-operator-surround' " better for html tag features: " NeoBundle 'tpope/vim-surround' " match closest '', "", (), {}, [] or <> with ib and ab NeoBundle 'rhysd/vim-textobj-anyblock' " gives il and al for lines NeoBundle 'kana/vim-textobj-line' " gives ae and ie for entire buffer NeoBundle 'kana/vim-textobj-entire' " give az and iz for folds NeoBundle 'kana/vim-textobj-fold' " gives things like a= for after equal sign NeoBundle 'junegunn/vim-after-object' " }}} " future..? {{{ " https://github.com/AndrewRadev/splitjoin.vim " https://noahfrederick.com/log/vim-and-progressive-enhancement/ " nnoremap J :call try('SplitjoinJoin', 'J') " nnoremap S :call try('SplitjoinSplit', "r\015") " function! s:try(cmd, default) " if exists(':' . a:cmd) && !v:count " let tick = b:changedtick " execute a:cmd " if tick == b:changedtick " execute join(['normal!', a:default]) " endif " else " execute join(['normal! ', v:count, a:default], '') " endif " endfunction " }}} " }}} call neobundle#end() " If there are uninstalled bundles found on startup, " this will conveniently prompt you to install them. NeoBundleCheck " }}} " #==============================