"============================================================" " " " Darkcloud Vim Config: keyboard settings " " " " By: Kevin MacMartin (prurigro@gmail.com) " " Website: https://github.com/prurigro/darkcloud-vimconfig " " " " License: MIT " " " "============================================================" " " Note: " *The default key is: \ " " Aliases: " :GitLog & :gitlog | (C) -> show a navigatable log of commit history " :GitDiff & :gitdiff | (C) -> current file and last commit in vimdiff " :GitStatus & :gitstatus | (C) -> shows the output of git status " :GitCommit & :gitcommit | (C) -> commits changes to the current file " :wsudo & :sudow | (C) -> write the file as root using sudo " :esudo & :sudoe | (C) -> read a file as root using sudo " " Reference: (view plugin documentation for the full list of commands each offers) " (tcomment _ can also be -) " | (A) -> comment selection/create an empty comment " gc | (A) -> comment selection/create an empty comment " b | (A) -> comment the current block(s) " r | (A) -> comment everything on the line to the right " p | (A) -> comment the current paragraph " + | (V) -> increase the selected region " _ | (V) -> decrease the selected region " | (N) -> center content and hide everything else " " (surround) " S" | (V) -> surround selection with quotes " S | (V) -> surround selection " ds" | (N) -> delete surrounding "" " dst | (N) -> delete surrounding tag (ie: ) " cs'" | (N) -> change surrounding '' to "" (any delimiters work) " cs" | (N) -> change surrounding "" to the tag: " cst" | (N) -> change any surrounding tag to "" " ysiw' | (N) -> surround the current word with '' " yss' | (N) -> surround non-whitespace of current line with '' " " Mappings: " (mouse) " | (A) -> scroll right quickly " | (A) -> scroll left quickly " | (A) -> scroll right slowly " | (A) -> scroll left slowly " " | (A) -> selects from the cursor " | (A) -> selects from the cursor " | (A) -> select the line being clicked " | (A) -> select the paragraph being clicked " " | (A) -> copy selection or character under the cursor " | (A) -> copy selection or character under the cursor " " | (A) -> cut selection or character under the cursor " | (A) -> cut selection or character under the cursor " " | (A) -> paste at the cursor (not mouse) " | (A) -> paste at the cursor (not mouse) " " | (A) -> paste from xorg paste buffer " " (tabs) " | (N) -> go to the next open tab " | (N) -> go to the previous open tab " | (N) -> open a new tab " | (N) -> create a new tab with vimfiler " | (N) -> create a new tab with a double pane vimfiler " " (toggles and features) " ` | (N) -> popup a command reference " , | (N) -> display tag information in echo area " | (N) -> toggle the vim reference manual " ? | (N) -> toggle the vim reference manual " ~ | (A) -> toggle the gutter(line numbers, folds and signify) " " | (N) -> toggle selected fold " | (N) -> open all folds " = | (N) -> open all folds " + | (N) -> open all folds " | (N) -> open all folds " - | (N) -> unopen all folds " _ | (N) -> unopen all folds " 0 | (N) -> reset all folds using default fold level " " | (A) -> toggle vimfiler sidebar " | (A) -> toggle the gundo sidebar " | (A) -> toggle the tagbar sidebar " | (A) -> toggle extradite git commit history " | (A) -> toggle vimfiler sidebar " | (A) -> toggle the gundo sidebar " | (A) -> toggle the tagbar sidebar " | (A) -> toggle extradite git commit history " " | (A) -> toggle line wrapping " | (A) -> toggle spell check " | (A) -> toggle external-paste mode " | (A) -> toggle syntax checking " " | (A) -> toggle goyo (distraction-free mode) " | (A) -> toggle goyo (distraction-free mode) " " (gvim toggles) " | (A) -> toggle the menubar " | (A) -> toggle the toolbar " | (A) -> toggle the scrollbars " " (spellcheck) " ?+ | (N) -> add the selected word to the local dictionary " ?? | (N) -> show spelling suggestions for selected word " ?N | (N) -> go to the next spelling mistake " ?P | (N) -> go to the previous spelling mistake " " (copy/paste and undo/redo) " p | (N) -> view the paste buffers and register contents " y | (N) -> copies the character at the cursor " P | (V) -> save selection to the buffer and paste over " p | (V) -> preserve the buffer pasting over selected text " Direction | (N) -> paste in the direction entered " T | (N) -> copy to the end of the line " T | (V) -> copy to the end of the line " " (delete/cut functions) " x | (N) -> delete the char(s) under and the cursor " x | (V) -> delete the currently selected text " X | (N) -> delete the char(s) before the cursor " X | (V) -> delete the currently selected lines " D | (N) -> delete chars under and after the cursor on the line " D | (V) -> delete the currently selected lines " dw | (N) -> delete chars under and after the cursor in the word " dd | (N) -> delete lines under and after the one below " d | (V) -> delete the currently selected text " " (improved copy and paste shortcuts) " | (N) -> paste from buffer " | (V) -> paste buffer in place of selection " | (I) -> paste from buffer then return to input " | (N) -> copy character " | (V) -> copy selection " | (N) -> cut character " | (V) -> cut selection " | (I) -> cut previous word during input " | (I) -> cut line before cursor during input " | (I) -> paste what's been cut during input " " (completion) " , | (A) -> enter after emmet 'word' (ie: html:5) " | (I) -> (neocomp) close the popup and " | (I) -> (neocomp) select/cycle popup completion " | (I) -> (neocomp) close the popup and " | (I) -> (neocomp) undo the most recent completion " " (formatting) " | (V) -> deletes currently selected text " J | (N) -> split the line into lines of <=79 chars " J | (V) -> split the selection into lines of <=79 chars " f | (N) -> format document and return to cursor " f | (V) -> format the selection and return to cursor " F | (N) -> format document using :Autoformat " w | (N) -> remove whitespace " t | (N) -> convert tabs into spaces " A | (N) -> aligns all comments " A | (V) -> aligns selected comments " a | (N) -> aligns all comments after text " a | (V) -> aligns selected comments after text " | (V) -> indent all the lines currently selected " | (N) -> indent the current line " | (V) -> unindent all the lines currently selected " | (N) -> unindent the current line " " (movement) " = | (N) -> go to the first char on the next line " _ | (N) -> go to the first char on the previous line " | (N) -> move to the beginning of the document " | (N) -> move to the end of the document " | (N) -> move to the end of the line " | (N) -> move to the beginning of the non-whitespace " " | (N) -> move four lines up " | (N) -> move four lines down " | (N) -> move one word right " | (N) -> move one word left " " | (V) -> move a block up one line " | (V) -> move a block down one line " | (N) -> move a line up one line " | (N) -> move a line down one line " " | (V) -> move a block up a half page " | (V) -> move a block down a half page " | (N) -> move a line up a half page " | (N) -> move a line down a half page " | (V) -> move a block up a half page " | (V) -> move a block down a half page " | (N) -> move a line up a half page " | (N) -> move a line down a half page " " >> | (N) -> next difference (vimdiff/signify) " << | (N) -> previous difference (vimdiff/signify) " " (selection) " | (N) -> select all text " | (V) -> select all text " " | (V) -> select all text above " | (V) -> select all text below " | (V) -> select all text to the right " | (V) -> select all text to the left up to the indent " " | (V) -> select four lines up " | (V) -> select four lines down " | (V) -> select one word right " | (V) -> select one word left " " // | (N) -> remove search highlighting " " (remap dangerous functions that skip undo) " | (I) -> undo-able equivalent " | (I) -> undo-able equivalent " " Filetype Specific Mappings: " (extradite) " | (A) -> close the dialog " | (A) -> close the dialog " | (A) -> same as down " l | (A) -> same as j " | (A) -> same as Up " h | (A) -> same as k " " (gundo) " | (A) -> same as normal + justify on the left " | (A) -> same as the left mouse " | (A) -> same as the left mouse " | (A) -> same as down " l | (A) -> same as j " | (A) -> same as Up " h | (A) -> same as k " " (help) " q | (A) -> close the dialog " | (A) -> close the dialog " ?> | (A) -> close the dialog " ?< | (A) -> close the dialog " " (qf sidebar mappings) " | (A) -> left click + left justify the cursor " | (A) -> same as the left click " | (A) -> same as the left click " | (A) -> select entry " | (A) -> select entry but remain in qf sidebar " | (A) -> up " | (A) -> down " h | (A) -> j " l | (A) -> k " " (vimdiff) " <> | (N) -> update differences " >< | (N) -> update differences " > | (N) -> replace diff in other pane with current pane " replace diff in current pane with other pane " " (vimfiler) " | (A) -> left click + left justify the cursor " | (A) -> same as the left click " | (A) -> same as the left click " | (A) -> edit selected file " | (A) -> map to l, which opens a directory " | (A) -> map to h, which goes up one directory " ' | (A) -> edit the selected file " n | (A) -> start editing a new file " "DISABLED DEFAULT MAPPING: UNSET SHORTCUTS {{{ "-unmapping tabbing from < and > for use with diff "+these commands are replaced by tab and shift+tab noremap > noremap < "-unmapping help from F1 and Ctrl-F1 for use toggling the reference manual "+the :h topic feature works, and displays quickref map map map "-unmap the suspend function map "unmap mousewheel combos to ensure the old behaviour stays gone map map map map "}}} "ALIASES: COMMAND SHORTCUTS {{{ cabbrev GitLog ':Extradite:wincmd x:wincmd j:resize 10' cabbrev gitlog ':Extradite:wincmd x:wincmd j:resize 10' cabbrev GitDiff ':Gdiff' cabbrev gitdiff ':Gdiff' cabbrev GitStatus ':Gstatus' cabbrev gitstatus ':Gstatus' cabbrev GitCommit ':Gcommit' cabbrev gitcommit ':Gcommit' cabbrev sudow SudoWrite cabbrev wsudo SudoWrite cabbrev sudoe SudoRead cabbrev esudo SudoRead "}}} "MAPPINGS: GENERAL KEYBINDINGS AND REBINDINGS {{{ "MOUSE:{ "hold ctrl to scroll left/right instead of up/down nnoremap 4zl xnoremap 4zl inoremap 4zl nnoremap 4zh xnoremap 4zh inoremap 4zh "hold alt to scroll left/right more precisely nnoremap zl xnoremap zl inoremap zl nnoremap zh xnoremap zh inoremap zh "middle & ctrl+left = select from cursor nnoremap xnoremap inoremap nnoremap xnoremap inoremap "alt+left = line nnoremap V xnoremap $ inoremap V "ctrl+alt+left = select paragraph nnoremap vip xnoremap ip$ inoremap vip "ctrl+(middle/right) = copy nnoremap Vy vnoremap y inoremap y nnoremap Vy vnoremap y inoremap y "alt+(middle/right) = cut nnoremap x xnoremap x inoremap x nnoremap x xnoremap x inoremap x "ctrl+alt+(middle/right) = paste nnoremap p xnoremap p inoremap p nnoremap p xnoremap p inoremap p "configure middle click to paste from X noremap noremap! "} "TABS:{ nnoremap ':tabnext' nnoremap ':tabprev' nnoremap ':tabnew' nnoremap ':VimFiler -tab -project' nnoremap ':VimFiler -tab -project -double' "} "TOGGLES AND FEATURES:{ "toggle the command reference box nnoremap ` ':TCommand' "display tag information in the gutter noremap , ':TTagechoWord' "toggle the vim reference manual nnoremap ':h index.txt' nnoremap ? ':h index.txt' "toggle the display of the left gutter nnoremap ~ ':if (&number)set nonumberif (&foldenable)set nofoldenableendifif exists("b:sy")if (b:sy.active)SignifyToggleendifendifelseset numberif !(&foldenable)set foldenableendifif exists("b:sy")if !(b:sy.active)SignifyToggleendifendifendif:echo "gutter visibility toggled"' "toggle folded code at foldpoints nnoremap za "open all folds nnoremap 'zn:echo "all folds have been opened"' nnoremap = 'zn:echo "all folds have been opened"' nnoremap + 'zn:echo "all folds have been opened"' "close folds set to be closed nnoremap 'zN:echo "all opened folds have been closed"' nnoremap - 'zN:echo "all opened folds have been closed"' nnoremap _ 'zN:echo "all opened folds have been closed"' "reset all folds to the default fold level nnoremap 0 'zX:echo "all folds have been reset"' "trigger vimfiler nnoremap ':VimFiler -split -simple -toggle -no-quit -direction=topleft -winwidth=45' xnoremap ':VimFiler -split -simple -toggle -no-quit -direction=topleft -winwidth=45' inoremap ':VimFiler -split -simple -toggle -no-quit -direction=topleft -winwidth=45' nnoremap ':VimFiler -split -simple -toggle -no-quit -direction=topleft -winwidth=45' xnoremap ':VimFiler -split -simple -toggle -no-quit -direction=topleft -winwidth=45' inoremap ':VimFiler -split -simple -toggle -no-quit -direction=topleft -winwidth=45' "bindings to trigger the gundo undo history nnoremap ':GundoToggle:echo "undo history sidebar toggled"' xnoremap ':GundoToggle' inoremap ':GundoToggle' nnoremap ':GundoToggle:echo "undo history sidebar toggled"' xnoremap ':GundoToggle' inoremap ':GundoToggle' "bindings to trigger the tagbar list of tags nnoremap ':TagbarToggle:echo "tagbar toggled"' xnoremap ':TagbarTogglegv' inoremap ':TagbarToggle' nnoremap ':TagbarToggle:echo "tagbar toggled"' xnoremap ':TagbarTogglegv' inoremap ':TagbarToggle' "view commit history and diffs nnoremap ':Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' xnoremap ':Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' inoremap ':Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' nnoremap ':Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' xnoremap ':Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' inoremap ':Extradite!:resize 10:wincmd x:wincmd b:wincmd H:wincmd b' "toggle line wrapping (and bottom bar if using the gui) nnoremap ':set wrap!:echo "line wrapping toggled"' xnoremap ':set wrap!gv' inoremap ':set wrap!' "toggle show spelling errors nnoremap ':set spell!:echo "spell checking toggled"' xnoremap ':set spell!gv' inoremap ':set spell!' "toggle external-paste mode set pastetoggle= "toggle syntax checking nnoremap ':if (g:syntastic_check_on_open == 1)let g:syntastic_check_on_open=0elselet g:syntastic_check_on_open=1endif:SyntasticToggleMode' xnoremap ':if (g:syntastic_check_on_open == 1)let g:syntastic_check_on_open=0elselet g:syntastic_check_on_open=1endif:SyntasticToggleModegv' inoremap ':if (g:syntastic_check_on_open == 1)let g:syntastic_check_on_open=0elselet g:syntastic_check_on_open=1endif:SyntasticToggleMode' "toggle goyo nnoremap ':Goyo' nnoremap ':Goyo' "} "GVIM TOGGLES:{ "toggle the menu nnoremap ":if &go=~#'m'set go-=melseset go+=mendif:echo 'Menu bar toggled'" vnoremap ":if &go=~#'m'set go-=melseset go+=mendifgv" inoremap ":if &go=~#'m'set go-=melseset go+=mendif" "toggle the toolbar nnoremap ":if &go=~#'T'set go-=Telseset go+=Tendif:echo 'Toolbar toggled'" vnoremap ":if &go=~#'T'set go-=Telseset go+=Tendifgv" inoremap ":if &go=~#'T'set go-=Telseset go+=Tendif" "toggle the scrollbars nnoremap ":if &go=~#'l'set go-=lRbelseset go+=lRbendif:echo 'Scrollbars toggled'" vnoremap ":if &go=~#'l'set go-=lRbelseset go+=lRbendifgv" inoremap ":if &go=~#'l'set go-=lRbelseset go+=lRbendif" "} "SPELLCHECK:{ "add the selected mispelled word to the local dictionary nnoremap ?+ zg "display a list of suggestions for the selected mispelled word nnoremap ?? hei "go to the next mispelled word nnoremap ?N ]s "go to the previous mispelled word nnoremap ?P [s "} "COPY PASTE AND UNDO REDO:{ "display contents of paste buffers nnoremap p ':reg' "allow y to copy a single character in normal mode nnoremap y vy "P pastes and replaces the buffer, p pastes and keeps it vnoremap P p xmap p ReplaceWithRegisterVisual "copy to the end of the line nnoremap T vg_y vnoremap T g_y "Alternatives to cut/deletion commands that don't replace the buffer nnoremap x "_x vnoremap x "_x nnoremap X "_X vnoremap X "_X nnoremap D "_D vnoremap D "_D nnoremap dd "_dd nnoremap dw "_dw vnoremap d "_d "map copy/paste shortcuts to more typical ones nnoremap P xmap ReplaceWithRegisterVisual inoremap p nnoremap y vnoremap y nnoremap x vnoremap x inoremap db inoremap d0 inoremap " "remap ctrl-u and ctrl-w to safer alternatives inoremap u inoremap u "} "COMPLETION:{ "emmet switch triggerkey from let g:user_emmet_leader_key='' "neocomplcache close popup and save indent inoremap =neocompl_cr() function! s:neocompl_cr() return pumvisible() ? neocomplcache#close_popup() : "\" endfunction "neocomplcache tab completion inoremap pumvisible() ? "\" : "\" "neocomplcache : undo completion inoremap neocomplcache#smart_close_popup()."\" "neocomplcache undo completion inoremap neocomplcache#undo_completion() "} "FORMATTING:{ "have backspace delete the selected text vnoremap "_x "format width to text width (or 80 chars if text width is 0) nnoremap J ':let b:tw=&textwidth:if (b:tw == 0)set tw=80endifgg0vG$gq:if (b:tw == 0)set tw=0let b:tw=80endif:echo "Document has been formatted to a width of ".b:tw." characters"' vnoremap J ':let b:tw=&textwidth:if (b:tw == 0)set tw=80endifgvgq:if (b:tw == 0)set tw=0let b:tw=80endif:echo "Selection has been formatted to a width of ".b:tw." characters"' "format syntax nnoremap f mzgg=G`z:echo "The document has been formatted" vnoremap f mz=`z:echo "The selection has been formatted" nnoremap F ':Autoformat:echo "The document has been formatted with :Autoformat"' "convert tabs to spaces nnoremap w ':FixWhitespace:echo "Trailing whitespace has been removed"' nnoremap t ':retab:noh:echo "Tabs have been converted to spaces"' "align comments nnoremap A :exe "%Tabular" '/^[^'.matchstr(&commentstring, '[^%]*').']*\zs'.matchstr(&commentstring, '[^%]*').'.*' vnoremap A :exe "'<,'>Tabular" '/^[^'.matchstr(&commentstring, '[^%]*').']*\zs'.matchstr(&commentstring, '[^%]*').'.*' nnoremap a :exe "%Tabular" '/^\ *[^'.matchstr(&commentstring, '[^%]*').'\ ][^\'.matchstr(&commentstring, '[^%]*').']*\zs'.matchstr(&commentstring, '[^%]*').'.*' vnoremap a :exe "'<,'>Tabular" '/^\ *[^'.matchstr(&commentstring, '[^%]*').' ][^\'.matchstr(&commentstring, '[^%]*').']*\zs'.matchstr(&commentstring, '[^%]*').'.*' "tab and untab the currently selected lines vnoremap >gv nnoremap v>gv vnoremap v "} "MOVEMENT:{ "additional mappings for easier access nnoremap = + nnoremap _ - "remap keys for speedier movement nnoremap 4k nnoremap 4j nnoremap nnoremap "remap keys to scroll to the end in a direction nnoremap gg0 nnoremap G$ nnoremap $ nnoremap ^ "remap alt+up/down to move blocks up/down a line vmap MoveBlockUp vmap MoveBlockDown nmap MoveLineUp nmap MoveLineDown "remap alt+left/right/h/l to move blocks up/down a half page vmap MoveBlockHalfPageUp vmap MoveBlockHalfPageDown nmap MoveLineHalfPageUp nmap MoveLineHalfPageDown vmap MoveBlockHalfPageUp vmap MoveBlockHalfPageDown nmap MoveLineHalfPageUp nmap MoveLineHalfPageDown "map signify to ]c and [c let g:signify_mapping_next_hunk = ']c' let g:signify_mapping_prev_hunk = '[c' "move to next/previous difference (vimdiff/signify) nmap >> ]c nmap << [c "} "SELECTION:{ "ctrl-a to select all nnoremap gg0vG$ xnoremap gg0vG$ "map remap keys for speedier text selection xnoremap 4k xnoremap 4j xnoremap xnoremap "remap keys to select all text in one direction xnoremap gg0 xnoremap G$ xnoremap $ xnoremap ^ "clear search results nnoremap // ':noh' "} "}}} "FILETYPE SPECIFIC MAPPINGS: {{{ "extradite autocmd FileType extradite map autocmd FileType extradite map l j autocmd FileType extradite map autocmd FileType extradite map h k autocmd FileType extradite map q autocmd FileType extradite map q "gundo autocmd FileType gundo map 0l autocmd FileType gundo map autocmd FileType gundo map autocmd FileType gundo map autocmd FileType gundo map l j autocmd FileType gundo map autocmd FileType gundo map h k "help if !&diff autocmd FileType help map q ':q' autocmd FileType help map ':q' autocmd FileType help map ? ':q' endif "mappings for qf-based plugins autocmd FileType qf map 0 autocmd FileType qf map autocmd FileType qf map autocmd FileType qf map <2-LeftMouse> autocmd FileType qf map p autocmd FileType qf map autocmd FileType qf map autocmd FileType qf map h j autocmd FileType qf map l k autocmd FileType qf map q ':call ToggleQuickfixList()' autocmd FileType qf map ':call ToggleQuickfixList()' autocmd FileType qf map ':call ToggleQuickfixList()' "vimdiff autocmd FilterWritePre * if &diff|nnoremap <> ':diffu'|endif autocmd FilterWritePre * if &diff|nnoremap >< ':diffu'|endif autocmd FilterWritePre * if &diff|nnoremap > dp|endif autocmd FilterWritePre * if &diff|nnoremap < do|endif autocmd FilterWritePre * if &diff|cabbrev q! qall!|endif "vimfiler autocmd FileType vimfiler map 0 autocmd FileType vimfiler map autocmd FileType vimfiler map autocmd FileType vimfiler map <2-LeftMouse> (vimfiler_edit_file) autocmd FileType vimfiler map l autocmd FileType vimfiler map h autocmd FileType vimfiler map ' e autocmd FileType vimfiler map ~ q "}}} "DISABLED MAPPINGS FOR FILETYPES: {{{ "remove incompatible toggles from specific file types autocmd Filetype qf,gundo,vimfiler,tagbar,extradite,help noremap ~ autocmd Filetype qf,vimfiler,extradite,help noremap autocmd Filetype qf,vimfiler,extradite,help noremap autocmd Filetype gundo,vimfiler,extradite,help noremap autocmd Filetype gundo,vimfiler,extradite,help noremap autocmd Filetype qf,gundo,vimfiler,tagbar,help,diff noremap autocmd Filetype qf,gundo,vimfiler,tagbar,help,diff noremap "disable modifier keys with directions that would interfere with logic autocmd Filetype qf,gundo,vimfiler noremap autocmd Filetype qf,gundo,vimfiler noremap autocmd Filetype qf,gundo,vimfiler noremap autocmd Filetype qf,gundo,vimfiler noremap autocmd Filetype qf,gundo,vimfiler,extradite noremap autocmd Filetype qf,gundo,vimfiler,extradite noremap autocmd Filetype qf,gundo,vimfiler,extradite noremap autocmd Filetype qf,gundo,vimfiler,extradite noremap autocmd Filetype qf,gundo,vimfiler noremap autocmd Filetype qf,gundo,vimfiler noremap autocmd Filetype qf,gundo,vimfiler noremap autocmd Filetype qf,gundo,vimfiler noremap autocmd Filetype qf,gundo,vimfiler,extradite noremap autocmd Filetype qf,gundo,vimfiler,extradite noremap autocmd Filetype qf,gundo,vimfiler,extradite noremap autocmd Filetype qf,gundo,vimfiler,extradite noremap "}}}