From ee2aa3d6865341b9c31f93121e102cf9f7b2f656 Mon Sep 17 00:00:00 2001 From: Kevin Date: Fri, 28 Mar 2014 22:12:13 -0400 Subject: [PATCH] Added some vimdiff bindings and disabled folding by default when launching vimdiff. Reorganized the keyboard bindings to make htem easier to find and read. You can now trigger most of the cut commands by hitting the key (backslash) first to avoid replacing the paste-buffer. A bunch of commands and toggles that made sense to do so now work in all three modes. All folds can be toggled with . The command to turn tabs into spaces has been added. A few settings added earlier today were tweaked or removed. --- vim/config/keyboard.vim | 381 ++++++++++++++++++++++++---------------- vim/config/settings.vim | 8 +- 2 files changed, 232 insertions(+), 157 deletions(-) diff --git a/vim/config/keyboard.vim b/vim/config/keyboard.vim index d140c12..ddbcf3c 100644 --- a/vim/config/keyboard.vim +++ b/vim/config/keyboard.vim @@ -2,94 +2,122 @@ " Keyboard Configuration: " "===========================" " +" Note: +" *The default key is: \ +" " Reference: (view plugin documentation for the full list of commands each offers) -" , | (A) -> enter this following an emme 'word' (ie: html:5) -" | (N) -> toggle hexhighlight's hexcode to colours in :gui -" cs'" | (N) -> change surrounding '' to "" (any delimiters work) -" cs" | (N) -> change surrounding "" to the tag: -" cst" | (N) -> change any surrounding tag to "" -" ds" | (N) -> delete surrounding "" +" cs'" | (N) -> change surrounding '' to "" (any delimiters work) +" cs" | (N) -> change surrounding "" to the tag: +" cst" | (N) -> change any surrounding tag to "" +" ds" | (N) -> delete surrounding "" " " Mappings: -" = | (N) -> move to the first character on the next line -" | (A) -> scroll right -" | (A) -> scroll left -" | (A) -> unbind this from vim so xorg can paste -" | (A) -> open a new tab -" | (A) -> go to the next open tab -" | (A) -> go to the previous open tab -" | (V) -> deletes currently selected text -" | (N) -> deletes the character behind the cursor -" | (V) -> indent all the lines currently selected -" | (N) -> indent the current line -" | (V) -> unindent all the lines currently selected -" | (N) -> unindent the current line -" \\ | (N) -> show spelling suggestions popup for word -" \| | (N) -> add word to a local list of correct spellings -" ` | (N) -> toggle the nerdtree sidebar -" ~ | (N) -> toggle the tagbar sidebar -" p | (V) -> paste and replace the selection -" | (N) -> paste and replace the current word -" | (A) -> toggle line numbers -" | (A) -> toggle line wrapping -" | (A) -> toggle row/column highlighting -" | (A) -> toggle spellcheck -" | (A) -> toggle collapsed/folded rows -" | (N) -> format document and return to current line -" | (N) -> remove whitespace -" | (N) -> convert tabs into spaces -" \ | (N) -> remove search highlighting -" | (N) -> move to the beginning of the document -" | (N) -> move to the beginning of the document -" | (N) -> move to the end of the document -" | (N) -> move to the end of the document -" | (N) -> move to the end of the line -" | (N) -> move to the end of the line -" | (N) -> move to the beginning of the non-whitespace -" | (N) -> move to the beginning of the line -" | (V) -> select all -" | (N) -> select all -" a | (V) -> select all -" a | (N) -> select all -" | (V) -> toggle selection of all text above the cursor -" | (N) -> select all text above the cursor -" | (V) -> toggle selection of all text above the cursor -" | (N) -> select all text above the cursor -" | (V) -> toggle selection of all text below the cursor -" | (N) -> select all text below the cursor -" | (V) -> toggle selection of all text below the cursor -" | (N) -> select all text below the cursor -" | (V) -> toggle selection of all text to the right of the cursor -" | (N) -> select all text to the right of the cursor -" | (V) -> toggle selection of all text to the right of the cursor -" | (N) -> select all text to the right of the cursor -" | (V) -> toggle selection of all non-whitespace to the left -" | (N) -> select all non-whitespace to the left -" | (V) -> toggle selection of all non-whitespace to the left -" | (N) -> select to the beginning of the line +" (mouse) +" | (A) -> scroll right +" | (A) -> scroll left +" | (A) -> unbind this from vim so xorg can paste " -" (neocomplcache) -" | (I) -> write the part common to all suggestions -" | (I) -> cancle the match dialog (during suggestion) -" | (N) -> undo the most recent match selection +" (tabs) +" | (A) -> open a new tab +" | (A) -> go to the next open tab +" | (A) -> go to the previous open tab " -" GVim Mappings: -" | (A) -> toggle the menu -" | (A) -> toggle the toolbar -" | (A) -> toggle the scrollbar +" (toggles) +" | (A) -> toggle line numbers +" | (A) -> toggle row/column highlighting +" | (A) -> toggle spellcheck +" | (A) -> toggle line wrapping +" | (A) -> toggle the nerdtree sidebar +" | (A) -> toggle the tagbar sidebar +" | (A) -> toggle collapsed/folded rows +" | (A) -> toggle all folds +" | (A) -> toggle all folds " -" Aliases: -" :wsudo & :sudow | (N) -> :SudoWrite (write the file as root using sudo) -" :esudo & :sudoe | (N) -> :SudoRead (read a file as root using sudo) +" (gvim toggles) +" | (A) -> toggle the menu +" | (A) -> toggle the toolbar +" | (A) -> toggle the scrollbar " -" Notes: -" *by the default key is: \ +" (spelling-and-completion) +" , | (A) -> enter this following an emme 'word' (ie: html:5) +" \\ | (N) -> show spelling suggestions popup for word +" \| | (N) -> add word to a local list of correct spellings +" | (N) -> undo the most recent match selection +" | (I) -> write the part common to all suggestions +" | (I) -> cancle the match dialog (during suggestion) +" +" (formatting) +" | (V) -> deletes currently selected text +" | (N) -> deletes the character behind the cursor +" | (N) -> format document and return to current line +" | (N) -> remove whitespace +" | (N) -> convert tabs into spaces +" \ | (N) -> remove search highlighting +" | (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) -> move to the first character on the next line +" | (N) -> move to the beginning of the document +" | (N) -> move to the beginning of the document +" | (N) -> move to the end of the document +" | (N) -> move to the end of the document +" | (N) -> move to the end of the line +" | (N) -> move to the end of the line +" | (N) -> move to the beginning of the non-whitespace +" | (N) -> move to the beginning of the line +" +" (selection) +" | (V) -> select all +" | (N) -> select all +" a | (V) -> select all +" a | (N) -> select all +" | (V) -> toggle selection of all text above the cursor +" | (N) -> select all text above the cursor +" | (V) -> toggle selection of all text above the cursor +" | (N) -> select all text above the cursor +" | (V) -> toggle selection of all text below the cursor +" | (N) -> select all text below the cursor +" | (V) -> toggle selection of all text below the cursor +" | (N) -> select all text below the cursor +" | (V) -> toggle selection of all text to the right of the cursor +" | (N) -> select all text to the right of the cursor +" | (V) -> toggle selection of all text to the right of the cursor +" | (N) -> select all text to the right of the cursor +" | (V) -> toggle selection of all non-whitespace to the left +" | (N) -> select all non-whitespace to the left +" | (V) -> toggle selection of all non-whitespace to the left +" | (N) -> select to the beginning of the line +" +" (vimdiff) +" du | (N) -> update differences +" | (N) -> next difference +" | (N) -> previous difference +" < | (N) -> replace diff in current pane with other pane +" > | (N) -> replace diff in other pane with current pane +" +" (paste-buffer-override) +" p | (V) -> paste and replace the currently selected text +" P | (V) -> paste and replace the currently selected text +" \d | (V) -> delete the currently selected text +" \x | (V) -> delete the currently selected text +" \x | (N) -> delete the char(s) under and the cursor +" \X | (V) -> delete the currently selected lines +" \X | (N) -> delete the char(s) before the cursor +" \D | (V) -> delete the currently selected lines +" \D | (N) -> delete chars under and after the cursor on the line +" \dw | (N) -> delete chars under and after the cursor in the word +" \dd | (N) -> delete lines under and after the one below +" +" Aliases: +" :wsudo -and- :sudow | (C) -> :SudoWrite (write the file as root using sudo) +" :esudo -and- :sudoe | (C) -> :SudoRead (read a file as root using sudo) " "MAPPINGS: GENERAL KEYBINDINGS AND REBINDINGS {{{ - "map = to + so shift doesn't need to be held to use its functionality - nnoremap = + - + "MOUSE:{ "hold shift to enable middle-click paste noremap noremap! @@ -97,68 +125,106 @@ "hold ctrl to scroll left/right instead of up/down noremap 3zl noremap 3zh + "} - "have backspace delete the highlighted selection in visual mode - vnoremap x - nnoremap il + "TABS:{ + "move to the next and previous tabs + nnoremap ':tabnew' + nnoremap ':tabnext' + nnoremap ':tabprev' + "} - "tab and untabbing selected blocks - vnoremap >gv - vnoremap v>gv - nnoremap v + "TOGGLES:{ + "unmap F1 from help then map it to toggle the display of line numbers + nnoremap ':set number!' + vnoremap ':set number!v' + inoremap ':set number!' + + "toggle the cursor line and column + nnoremap ':set cursorline! cursorcolumn!' + vnoremap ':set cursorline! cursorcolumn!v' + inoremap ':set cursorline! cursorcolumn!' + + "toggle spellcheck + nnoremap ':set spell!' + vnoremap ':set spell!v' + inoremap ':set spell!' + + "toggle line wrapping (and bottom bar if using the gui) + nnoremap ':set wrap! go'.'-+'[&wrap]."=b\r" + vnoremap ':set wrap! go'.'-+'[&wrap]."=b\rv" + inoremap ':set wrap! go'.'-+'[&wrap]."=b\r" + + "bindings to trigger the nerdtree and tagbar sidebars + nnoremap ':NERDTreeToggle' + vnoremap ':NERDTreeToggle' + inoremap ':NERDTreeToggle' + nnoremap ':TagbarToggle' + vnoremap ':TagbarTogglev' + inoremap ':TagbarToggle' + + "toggle folded code at foldpoints + nnoremap za + vnoremap zav + inoremap za + + "toggle all folds + nnoremap zi + vnoremap ziv + inoremap zi + "} + + "GVIM TOGGLES:{ + "map toggles for the menu, toolbar and vertical scrollbar + nnoremap ":if &go=~#'m'set go-=melseset go+=mendif" + vnoremap ":if &go=~#'m'set go-=melseset go+=mendifv" + inoremap ":if &go=~#'m'set go-=melseset go+=mendif" + + nnoremap ":if &go=~#'T'set go-=Telseset go+=Tendif" + vnoremap ":if &go=~#'T'set go-=Telseset go+=Tendifv" + inoremap ":if &go=~#'T'set go-=Telseset go+=Tendif" + + nnoremap ":if &go=~#'r'set go-=relseset go+=rendif" + vnoremap ":if &go=~#'r'set go-=relseset go+=rendifv" + inoremap ":if &go=~#'r'set go-=relseset go+=rendif" + "} + + "SPELLING AND COMPLETION:{ + "emmet switch triggerkey from to + let g:user_emmet_leader_key='' "press backslash twice on a mispelled word for suggestions nnoremap \\ ea nnoremap \| zg - "move to the next and previous tabs - nnoremap ':tabnew' - nnoremap ':tabnext' - nnoremap ':tabprev' + "neocomplcache suggestions: cancel, autocomplete, scroll up and scroll down + inoremap neocomplcache#undo_completion() + inoremap pumvisible() ? neocomplcache#complete_common_string() : "\" + inoremap pumvisible() ? neocomplcache#close_popup() : "\" + "} - "map shift-p to paste over a word, and visual paste to replace selection - vnoremap p "_d"0P - nnoremap "_diwP + "FORMATTING:{ + "have backspace delete the selected text + vnoremap x + nnoremap il - "unmap F1 from help then map it to toggle the display of line numbers - nnoremap ':set number!' - inoremap ':set number!a' - vnoremap ':set number!v' - - "toggle line wrapping (and bottom bar if using the gui) - nnoremap ':set wrap! go'.'-+'[&wrap]."=b\r" - inoremap ':set wrap! go'.'-+'[&wrap]."=b\ra" - vnoremap ':set wrap! go'.'-+'[&wrap]."=b\rv" - - "toggle the cursor line and column - nnoremap ':set cursorline! cursorcolumn!' - inoremap ':set cursorline! cursorcolumn!a' - vnoremap ':set cursorline! cursorcolumn!v' - - "toggle spellcheck - nnoremap ':set spell!' - inoremap ':set spell!a' - vnoremap ':set spell!a' - - "toggle folded code at foldpoints - inoremap za - nnoremap za - onoremap za - vnoremap zav - - "format the document + "formatting options to apply to the whole document nnoremap mzgg=G`z - - "remove trailing white space from the document nnoremap ':FixWhitespace' - - "convert tabs to spaces nnoremap ':retab:noh' - - "remove search highlight nnoremap / ':noh' + "tab and untab the currently selected lines + vnoremap >gv + nnoremap v>gv + vnoremap v + "} + + "MOVEMENT:{ + "additional mappings for easier access + nnoremap = + + "remap keys to scroll through text nnoremap gg0 nnoremap gg0 @@ -168,7 +234,9 @@ nnoremap $ nnoremap ^ nnoremap ^ + "} + "SELECTION:{ "map remap keys to select text vnoremap gg0vG$ nnoremap gg0vG$ @@ -190,25 +258,42 @@ nnoremap v^ vnoremap ^ nnoremap v^ + "} + + "VIMDIFF:{ + "map shortcuts for vimdiff + nnoremap du ':diffu' + nnoremap ]c + nnoremap [c + nnoremap < do + nnoremap > dp + "} + + "PASTE BUFFER OVERRIDE:{ + "alternatives that preserve the paste buffer + vnoremap p "_d"0P + vnoremap P "_d"0P + vnoremap x "_x + nnoremap x "_x + vnoremap X "_X + nnoremap X "_X + vnoremap D "_D + nnoremap D "_D + vnoremap d "_d + nnoremap dd "_dd + nnoremap dw "_dw + "} "}}} -"PLUGIN KEYBINDINGS {{{ - "toggle the nerd tree sidebar - nnoremap ` ':NERDTree' - - "toggle the tagbar sidebar - nnoremap ~ ':TagbarToggle' - - "neocomplcache suggestions: cancel, autocomplete, scroll up and scroll down - inoremap pumvisible() ? neocomplcache#complete_common_string() : "\" - inoremap pumvisible() ? neocomplcache#close_popup() : "\" - inoremap neocomplcache#undo_completion() - - "emmet switch triggerkey from to - let g:user_emmet_leader_key='' +"ALIASES: COMMAND SHORTCUTS {{{ + cabbrev sudow SudoWrite + cabbrev wsudo SudoWrite + cabbrev sudoe SudoRead + cabbrev esudo SudoRead "}}} "TMUX AND SCREEN COMPATIBILITY: SOME HACKS TO MAKE THINGS WORK RIGHT {{{ + "general compatibility settings for both screen and tmux if $TERM =~ '^screen-256color' nmap OH imap OH @@ -216,7 +301,7 @@ imap OF endif - "tmux will send xterm-style keys when xterm-keys is on + "full keyboard compatibility for tmux with xterm-keys enabled if &term =~ '^screen' && exists('$TMUX') execute "set =\e[1;*A" execute "set =\e[1;*B" @@ -242,17 +327,3 @@ execute "set =\e[24;*~" endif "}}} - -"GVIM: MAPPINGS FOR GUI ELEMENTS {{{ - "map toggles for the menu, toolbar and vertical scrollbar - noremap ":if &go=~#'m'set go-=melseset go+=mendif" - noremap ":if &go=~#'T'set go-=Telseset go+=Tendif" - noremap ":if &go=~#'r'set go-=relseset go+=rendif" -"}}} - -"ALIASES: COMMAND SHORTCUTS {{{ - cabbrev sudow SudoWrite - cabbrev wsudo SudoWrite - cabbrev sudoe SudoRead - cabbrev esudo SudoRead -"}}} diff --git a/vim/config/settings.vim b/vim/config/settings.vim index 095c93f..138bcfe 100644 --- a/vim/config/settings.vim +++ b/vim/config/settings.vim @@ -4,7 +4,6 @@ "COMPATIBILITY SETTINGS: DOCUMENT AND ENVIRONMENT SETTINGS {{{ set nocompatible "enable vim specific capabilities - set hidden "tells vim to track things like undo history while a buffer is in the background set encoding=utf-8 "set encoding set fileformats=unix,dos,mac "set compatible line endings in order of preference set backspace=indent,eol,start "enables backspacing @@ -58,8 +57,13 @@ "SYNTAX: INDENTING, HIGHLIGHTING, FOLDING {{{ filetype plugin indent on syntax on "turn syntax highlighting on - set foldmethod=syntax foldcolumn=1 foldlevel=3 "configure how folding code works set formatoptions=roqnl12 "configure format options + set foldmethod=syntax foldcolumn=1 foldlevel=3 "fold layers 3 or more deep + + "disable folding by default in vimdiff + if &diff + au VimEnter * windo set nofoldenable + endif "}}} "FILETYPES: SETTINGS SPECIFIC TO A FILETYPE {{{