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 <Leader> 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 <shift-F12>.
The command to turn tabs into spaces has been added. A few settings
added earlier today were tweaked or removed.
This commit is contained in:
Kevin 2014-03-28 22:12:13 -04:00
parent 8821f922de
commit ee2aa3d686
2 changed files with 232 additions and 157 deletions

View file

@ -2,43 +2,64 @@
" Keyboard Configuration: "
"==========================="
"
" Note:
" *The default <Leader> key is: \
"
" Reference: (view plugin documentation for the full list of commands each offers)
" <Ctrl-z>, | (A) -> enter this following an emme 'word' (ie: html:5)
" <Leader><F2> | (N) -> toggle hexhighlight's hexcode to colours in :gui
" cs'" | (N) -> change surrounding '' to "" (any delimiters work)
" cs"<q> | (N) -> change surrounding "" to the tag: <q></q>
" cst" | (N) -> change any surrounding tag to ""
" ds" | (N) -> delete surrounding ""
"
" Mappings:
" = | (N) -> move to the first character on the next line
" (mouse)
" <Ctrl-ScrollUp> | (A) -> scroll right
" <Ctrl-ScrollDown> | (A) -> scroll left
" <Shift-MiddleClick> | (A) -> unbind this from vim so xorg can paste
"
" (tabs)
" <Ctrl-t> | (A) -> open a new tab
" <Ctrl-n> | (A) -> go to the next open tab
" <Ctrl-p> | (A) -> go to the previous open tab
" <Backspace> | (V) -> deletes currently selected text
" <Backspace> | (N) -> deletes the character behind the cursor
" <Tab> | (V) -> indent all the lines currently selected
" <Tab> | (N) -> indent the current line
" <Shift-Tab> | (V) -> unindent all the lines currently selected
" <Shift-Tab> | (N) -> unindent the current line
"
" (toggles)
" <F1> | (A) -> toggle line numbers
" <F2> | (A) -> toggle row/column highlighting
" <F3> | (A) -> toggle spellcheck
" <F4> | (A) -> toggle line wrapping
" <F9> | (A) -> toggle the nerdtree sidebar
" <Shift-F9> | (A) -> toggle the tagbar sidebar
" <F12> | (A) -> toggle collapsed/folded rows
" <Shift-F12> | (A) -> toggle all folds
" <Shift-F12> | (A) -> toggle all folds
"
" (gvim toggles)
" <Ctrl-F1> | (A) -> toggle the menu
" <Ctrl-F2> | (A) -> toggle the toolbar
" <Ctrl-F3> | (A) -> toggle the scrollbar
"
" (spelling-and-completion)
" <Ctrl-z>, | (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) -> toggle the nerdtree sidebar
" ~ | (N) -> toggle the tagbar sidebar
" p | (V) -> paste and replace the selection
" <Shift-p> | (N) -> paste and replace the current word
" <F1> | (A) -> toggle line numbers
" <F2> | (A) -> toggle line wrapping
" <F3> | (A) -> toggle row/column highlighting
" <F4> | (A) -> toggle spellcheck
" <F12> | (A) -> toggle collapsed/folded rows
" <Leader><Backspace> | (N) -> undo the most recent match selection
" <Tab> | (I) -> write the part common to all suggestions
" <Backspace> | (I) -> cancle the match dialog (during suggestion)
"
" (formatting)
" <Backspace> | (V) -> deletes currently selected text
" <Backspace> | (N) -> deletes the character behind the cursor
" <Leader><C-f> | (N) -> format document and return to current line
" <Leader><C-w> | (N) -> remove whitespace
" <Leader><C-t> | (N) -> convert tabs into spaces
" <Leader>\ | (N) -> remove search highlighting
" <Tab> | (V) -> indent all the lines currently selected
" <Tab> | (N) -> indent the current line
" <Shift-Tab> | (V) -> unindent all the lines currently selected
" <Shift-Tab> | (N) -> unindent the current line
"
" (movement)
" = | (N) -> move to the first character on the next line
" <Ctrl-Up> | (N) -> move to the beginning of the document
" <Ctrl-k> | (N) -> move to the beginning of the document
" <Ctrl-Down> | (N) -> move to the end of the document
@ -47,6 +68,8 @@
" <Ctrl-l> | (N) -> move to the end of the line
" <Ctrl-Left> | (N) -> move to the beginning of the non-whitespace
" <Ctrl-h> | (N) -> move to the beginning of the line
"
" (selection)
" <Ctrl-a> | (V) -> select all
" <Ctrl-a> | (N) -> select all
" <Leader>a | (V) -> select all
@ -68,28 +91,33 @@
" <Shift-h> | (V) -> toggle selection of all non-whitespace to the left
" <Shift-h> | (N) -> select to the beginning of the line
"
" (neocomplcache)
" <Tab> | (I) -> write the part common to all suggestions
" <Backspace> | (I) -> cancle the match dialog (during suggestion)
" <Leader><Backspace> | (N) -> undo the most recent match selection
" (vimdiff)
" du | (N) -> update differences
" <Ctrl-n> | (N) -> next difference
" <Ctrl-p> | (N) -> previous difference
" < | (N) -> replace diff in current pane with other pane
" > | (N) -> replace diff in other pane with current pane
"
" GVim Mappings:
" <Ctrl-F1> | (A) -> toggle the menu
" <Ctrl-F2> | (A) -> toggle the toolbar
" <Ctrl-F3> | (A) -> toggle the scrollbar
" (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 & :sudow | (N) -> :SudoWrite (write the file as root using sudo)
" :esudo & :sudoe | (N) -> :SudoRead (read a file as root using sudo)
"
" Notes:
" *by the default <Leader> key is: \
" :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 <S-Insert> <MiddleMouse>
noremap! <S-Insert> <MiddleMouse>
@ -97,68 +125,106 @@
"hold ctrl to scroll left/right instead of up/down
noremap <C-ScrollWheelUp> 3zl
noremap <C-ScrollWheelDown> 3zh
"}
"have backspace delete the highlighted selection in visual mode
vnoremap <Backspace> x
nnoremap <Backspace> i<Backspace><Esc>l
"TABS:{
"move to the next and previous tabs
nnoremap <silent><expr> <C-t> ':tabnew<CR>'
nnoremap <silent><expr> <C-n> ':tabnext<CR>'
nnoremap <silent><expr> <C-p> ':tabprev<CR>'
"}
"tab and untabbing selected blocks
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
nnoremap <Tab> v>gv<Esc>
nnoremap <S-Tab> v<gv<Esc>
"TOGGLES:{
"unmap F1 from help then map it to toggle the display of line numbers
nnoremap <silent><expr> <F1> ':set number!<CR>'
vnoremap <silent><expr> <F1> '<Esc>:set number!<CR>v'
inoremap <silent><expr> <F1> '<C-O>:set number!<CR>'
"toggle the cursor line and column
nnoremap <silent><expr> <F2> ':set cursorline! cursorcolumn!<CR>'
vnoremap <silent><expr> <F2> '<Esc>:set cursorline! cursorcolumn!<CR>v'
inoremap <silent><expr> <F2> '<C-O>:set cursorline! cursorcolumn!<CR>'
"toggle spellcheck
nnoremap <silent><expr> <F3> ':set spell!<CR>'
vnoremap <silent><expr> <F3> '<Esc>:set spell!<CR>v'
inoremap <silent><expr> <F3> '<C-O>:set spell!<CR>'
"toggle line wrapping (and bottom bar if using the gui)
nnoremap <silent><expr> <F4> ':set wrap! go'.'-+'[&wrap]."=b\r"
vnoremap <silent><expr> <F4> '<Esc>:set wrap! go'.'-+'[&wrap]."=b\rv"
inoremap <silent><expr> <F4> '<C-O>:set wrap! go'.'-+'[&wrap]."=b\r"
"bindings to trigger the nerdtree and tagbar sidebars
nnoremap <silent><expr> <F9> ':NERDTreeToggle<CR>'
vnoremap <silent><expr> <F9> '<Esc>:NERDTreeToggle<CR>'
inoremap <silent><expr> <F9> '<Esc>:NERDTreeToggle<CR>'
nnoremap <silent><expr> <S-F9> ':TagbarToggle<CR>'
vnoremap <silent><expr> <S-F9> '<Esc>:TagbarToggle<CR>v'
inoremap <silent><expr> <S-F9> '<C-O>:TagbarToggle<CR>'
"toggle folded code at foldpoints
nnoremap <F12> za
vnoremap <F12> <Esc>zav
inoremap <F12> <C-O>za
"toggle all folds
nnoremap <S-F12> zi
vnoremap <S-F12> <Esc>ziv
inoremap <S-F12> <C-O>zi
"}
"GVIM TOGGLES:{
"map toggles for the menu, toolbar and vertical scrollbar
nnoremap <silent><expr> <C-F1> ":if &go=~#'m'<Bar>set go-=m<Bar>else<Bar>set go+=m<Bar>endif<CR>"
vnoremap <silent><expr> <C-F1> "<Esc>:if &go=~#'m'<Bar>set go-=m<Bar>else<Bar>set go+=m<Bar>endif<CR>v"
inoremap <silent><expr> <C-F1> "<C-O>:if &go=~#'m'<Bar>set go-=m<Bar>else<Bar>set go+=m<Bar>endif<CR>"
nnoremap <silent><expr> <C-F2> ":if &go=~#'T'<Bar>set go-=T<Bar>else<Bar>set go+=T<Bar>endif<CR>"
vnoremap <silent><expr> <C-F2> "<Esc>:if &go=~#'T'<Bar>set go-=T<Bar>else<Bar>set go+=T<Bar>endif<CR>v"
inoremap <silent><expr> <C-F2> "<C-O>:if &go=~#'T'<Bar>set go-=T<Bar>else<Bar>set go+=T<Bar>endif<CR>"
nnoremap <silent><expr> <C-F3> ":if &go=~#'r'<Bar>set go-=r<Bar>else<Bar>set go+=r<Bar>endif<CR>"
vnoremap <silent><expr> <C-F3> "<Esc>:if &go=~#'r'<Bar>set go-=r<Bar>else<Bar>set go+=r<Bar>endif<CR>v"
inoremap <silent><expr> <C-F3> "<C-O>:if &go=~#'r'<Bar>set go-=r<Bar>else<Bar>set go+=r<Bar>endif<CR>"
"}
"SPELLING AND COMPLETION:{
"emmet switch triggerkey from <Ctrl-Y> to <Ctrl-Z>
let g:user_emmet_leader_key='<C-Z>'
"press backslash twice on a mispelled word for suggestions
nnoremap \\ ea<C-X><C-S>
nnoremap \| zg
"move to the next and previous tabs
nnoremap <silent><expr> <C-t> ':tabnew<CR>'
nnoremap <silent><expr> <C-n> ':tabnext<CR>'
nnoremap <silent><expr> <C-p> ':tabprev<CR>'
"neocomplcache suggestions: cancel, autocomplete, scroll up and scroll down
inoremap <expr><Leader><Backspace> neocomplcache#undo_completion()
inoremap <expr><Tab> pumvisible() ? neocomplcache#complete_common_string() : "\<Tab>"
inoremap <expr><Backspace> pumvisible() ? neocomplcache#close_popup() : "\<Backspace>"
"}
"map shift-p to paste over a word, and visual paste to replace selection
vnoremap p "_d"0P
nnoremap <S-p> "_diwP
"FORMATTING:{
"have backspace delete the selected text
vnoremap <Backspace> x
nnoremap <Backspace> i<Backspace><Esc>l
"unmap F1 from help then map it to toggle the display of line numbers
nnoremap <silent><expr> <F1> ':set number!<CR>'
inoremap <silent><expr> <F1> '<Esc>:set number!<CR>a'
vnoremap <silent><expr> <F1> '<Esc>:set number!<CR>v'
"toggle line wrapping (and bottom bar if using the gui)
nnoremap <silent><expr> <F2> ':set wrap! go'.'-+'[&wrap]."=b\r"
inoremap <silent><expr> <F2> '<Esc>:set wrap! go'.'-+'[&wrap]."=b\ra"
vnoremap <silent><expr> <F2> '<Esc>:set wrap! go'.'-+'[&wrap]."=b\rv"
"toggle the cursor line and column
nnoremap <silent><expr> <F3> ':set cursorline! cursorcolumn!<CR>'
inoremap <silent><expr> <F3> '<Esc>:set cursorline! cursorcolumn!<CR>a'
vnoremap <silent><expr> <F3> '<Esc>:set cursorline! cursorcolumn!<CR>v'
"toggle spellcheck
nnoremap <silent><expr> <F4> ':set spell!<CR>'
inoremap <silent><expr> <F4> '<Esc>:set spell!<CR>a'
vnoremap <silent><expr> <F4> '<Esc>:set spell!<CR>a'
"toggle folded code at foldpoints
inoremap <F12> <C-O>za
nnoremap <F12> za
onoremap <F12> <C-C>za
vnoremap <F12> <Esc>zav
"format the document
"formatting options to apply to the whole document
nnoremap <Leader><C-f> mzgg=G`z<CR>
"remove trailing white space from the document
nnoremap <silent><expr> <Leader><C-w> ':FixWhitespace<CR>'
"convert tabs to spaces
nnoremap <silent><expr> <Leader><C-t> ':retab<CR>:noh<CR>'
"remove search highlight
nnoremap <silent><expr> <Leader>/ ':noh<CR>'
"tab and untab the currently selected lines
vnoremap <Tab> >gv
nnoremap <Tab> v>gv<Esc>
vnoremap <S-Tab> <gv
nnoremap <S-Tab> v<gv<Esc>
"}
"MOVEMENT:{
"additional mappings for easier access
nnoremap = +
"remap keys to scroll through text
nnoremap <C-Up> gg0
nnoremap <C-k> gg0
@ -168,7 +234,9 @@
nnoremap <C-l> $
nnoremap <C-Left> ^
nnoremap <C-h> ^
"}
"SELECTION:{
"map remap keys to select text
vnoremap <C-a> <Esc>gg0vG$
nnoremap <C-a> gg0vG$
@ -190,25 +258,42 @@
nnoremap <S-Left> v^
vnoremap <S-h> ^
nnoremap <S-h> v^
"}
"VIMDIFF:{
"map shortcuts for vimdiff
nnoremap <silent><expr> du ':diffu<CR>'
nnoremap <C-n> ]c
nnoremap <C-p> [c
nnoremap < do
nnoremap > dp
"}
"PASTE BUFFER OVERRIDE:{
"alternatives that preserve the paste buffer
vnoremap p "_d"0P
vnoremap P "_d"0P
vnoremap <Leader>x "_x
nnoremap <Leader>x "_x
vnoremap <Leader>X "_X
nnoremap <Leader>X "_X
vnoremap <Leader>D "_D
nnoremap <Leader>D "_D
vnoremap <Leader>d "_d
nnoremap <Leader>dd "_dd
nnoremap <Leader>dw "_dw
"}
"}}}
"PLUGIN KEYBINDINGS {{{
"toggle the nerd tree sidebar
nnoremap <silent><expr> ` ':NERDTree<CR>'
"toggle the tagbar sidebar
nnoremap <silent><expr> ~ ':TagbarToggle<CR>'
"neocomplcache suggestions: cancel, autocomplete, scroll up and scroll down
inoremap <expr><Tab> pumvisible() ? neocomplcache#complete_common_string() : "\<Tab>"
inoremap <expr><Backspace> pumvisible() ? neocomplcache#close_popup() : "\<Backspace>"
inoremap <expr><Leader><Backspace> neocomplcache#undo_completion()
"emmet switch triggerkey from <Ctrl-Y> to <Ctrl-Z>
let g:user_emmet_leader_key='<C-Z>'
"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 <Esc>OH <Home>
imap <Esc>OH <Home>
@ -216,7 +301,7 @@
imap <Esc>OF <End>
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 <xUp>=\e[1;*A"
execute "set <xDown>=\e[1;*B"
@ -242,17 +327,3 @@
execute "set <F12>=\e[24;*~"
endif
"}}}
"GVIM: MAPPINGS FOR GUI ELEMENTS {{{
"map toggles for the menu, toolbar and vertical scrollbar
noremap <silent><expr> <C-F1> ":if &go=~#'m'<Bar>set go-=m<Bar>else<Bar>set go+=m<Bar>endif<CR>"
noremap <silent><expr> <C-F2> ":if &go=~#'T'<Bar>set go-=T<Bar>else<Bar>set go+=T<Bar>endif<CR>"
noremap <silent><expr> <C-F3> ":if &go=~#'r'<Bar>set go-=r<Bar>else<Bar>set go+=r<Bar>endif<CR>"
"}}}
"ALIASES: COMMAND SHORTCUTS {{{
cabbrev sudow SudoWrite
cabbrev wsudo SudoWrite
cabbrev sudoe SudoRead
cabbrev esudo SudoRead
"}}}

View file

@ -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 {{{