From 7bb3c32e3b6f0f4acf2e916e9eb759dbb7d4a04f Mon Sep 17 00:00:00 2001 From: Kevin MacMartin Date: Wed, 22 Oct 2014 03:41:50 -0400 Subject: [PATCH] Tons of mapping issues fixed, re-add mkd table fmt, tweak keys+settings --- README.md | 115 +++++++++++++++++++++++----------------- vim/config/after.vim | 3 +- vim/config/keyboard.vim | 91 ++++++++++++++++++------------- vim/config/plugins.vim | 26 +++++++++ 4 files changed, 148 insertions(+), 87 deletions(-) diff --git a/README.md b/README.md index 6e425ca..00f14e0 100644 --- a/README.md +++ b/README.md @@ -76,71 +76,85 @@ As usual, to have your system use `vimpager` in place of `less`, you'll need to ### Mouse ### -| Binding | Mode | Action | -|:-----------------------|:----:|-------------------------------------------------:| -| Ctrl-ScrollUp | ALL | Scroll right a few characters at a time | -| Ctrl-ScrollDown | ALL | Scroll left a few characters at a time | -| Alt-ScrollUp | ALL | Scroll right one character at a time | -| Alt-ScrollDown | ALL | Scroll left one character at a time | -| | | | -| MiddleClick | ALL | Select between the cursor and the mouse | -| Ctrl-LeftClick | ALL | Select between the cursor and the mouse | -| Alt-LeftClick | ALL | Select the line at the mouse | -| Ctrl-Alt-LeftClick | ALL | Select the paragraph at the mouse | -| | | | -| Ctrl-RightClick | ALL | Copy selection or character under the cursor | -| Ctrl-MiddleClick | ALL | Copy selection or character under the cursor | -| Alt-RightClick | ALL | Cut selection or character under the cursor | -| Alt-MiddleClick | ALL | Cut selection or character under the cursor | -| Ctrl-Alt-RightClick | ALL | Paste at the cursor | -| Ctrl-Alt-MiddleClick | ALL | Paste at the cursor | -| Shift-MiddleClick | ALL | Paste the contents of the xorg buffer | +| Binding | Mode | Action | +|--------------------------|------|----------------------------------------------| +| \ | ALL | Scroll right a few characters at a time | +| \ | ALL | Scroll left a few characters at a time | +| \ | ALL | Scroll right one character at a time | +| \ | ALL | Scroll left one character at a time | +| | | | +| MiddleClick | ALL | Select between the cursor and the mouse | +| \ | ALL | Select between the cursor and the mouse | +| \ | ALL | Select the line at the mouse | +| \ | ALL | Select the paragraph at the mouse | +| | | | +| \ | ALL | Copy selection or character under the cursor | +| \ | ALL | Copy selection or character under the cursor | +| \ | ALL | Cut selection or character under the cursor | +| \ | ALL | Cut selection or character under the cursor | +| \ | ALL | Paste at the cursor | +| \ | ALL | Paste at the cursor | +| \ | ALL | Paste the contents of the xorg buffer | ### Keyboard ### #### Sidebars #### -| Binding | Mode | Action | -|:-----------------------|:----:|-------------------------------------------------:| -| \<(Ctrl-or-Alt)-F1\> | ALL | Toggle **vimfiler** file manager sidebar | -| \<(Ctrl-or-Alt)-F2\> | ALL | Toggle the **gundo** undo history sidebar | -| \<(Ctrl-or-Alt)-F3\> | ALL | Toggle the **tagbar** source code tag sidebar | -| \<(Ctrl-or-Alt)-F4\> | ALL | Toggle the **extradite** git history window | -| \<(Ctrl-or-Alt)-F12\> | ALL | Toggle the **goyo** distraction-free mode | +| Binding | Mode | Action | +|-----------------------|------|-----------------------------------------------| +| \<(Ctrl-or-Alt)-F1\> | ALL | Toggle **vimfiler** file manager sidebar | +| \<(Ctrl-or-Alt)-F2\> | ALL | Toggle the **gundo** undo history sidebar | +| \<(Ctrl-or-Alt)-F3\> | ALL | Toggle the **tagbar** source code tag sidebar | +| \<(Ctrl-or-Alt)-F4\> | ALL | Toggle the **extradite** git history window | +| \<(Ctrl-or-Alt)-F12\> | ALL | Toggle the **goyo** distraction-free mode | #### Toggles #### -| Binding | Mode | Action | -|:-----------------------|:----:|-------------------------------------------------:| -| \` | NORM | Popup a command list dialog | +| Binding | Mode | Action | +|------------------------|------|--------------------------------------------------| +| ~ | N | Popup a command list dialog | | | | | -| \ | ALL | Toggle line wrapping | -| \ | ALL | Toggle highlighting of spelling mistakes | -| \ | ALL | Toggle source code syntax checking | -| \ | ALL | Toggle external-paste mode | +| \ | ALL | Toggle line wrapping | +| \ | ALL | Toggle highlighting of spelling mistakes | +| \ | ALL | Toggle source code syntax checking | +| \ | ALL | Toggle external-paste mode | | | | | -| ~ | NORM | Toggle gutter (left bar with line numbers etc.) | -| \\ | NORM | Toggle the **vim** reference manual | -| \\ | NORM | Toggle the **goyo** distraction-free UI | -| ?\ | NORM | Toggle the **spellcheck** bottom bar of mistakes | +| \` | N | Toggle gutter (left bar with line numbers etc.) | +| \\ | N | Toggle the **vim** reference manual | +| \\ | N | Toggle the **goyo** distraction-free UI | +| ?\ | N | Toggle the **spellcheck** bottom bar of mistakes | #### Spell Check #### -| Binding | Mode | Action | -|:-----------------------|:----:|-------------------------------------------------:| -| ? | NORM | Toggle spellcheck error list | -| ?+ | NORM | Add the selected word to the local dictionary | -| ?? | NORM | Show spelling suggestions for selected word | -| ?N | NORM | Go to the next spelling mistake | -| ?P | NORM | Go to the previous spelling mistake | +| Binding | Mode | Action | +|------------|------|-----------------------------------------------| +| ?\ | N | Toggle spellcheck error list | +| ?+ | 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 | -##### GVim ##### +#### Formatting #### -| Binding | Mode | Action | -|:-----------------------|:----:|-------------------------------------------------:| -| \\ | ALL | Toggle the menubar **(gvim)** | -| \\ | ALL | Toggle the toolbar **(gvim)** | -| \\ | ALL | Toggle the scrollbars **(gvim)** | +| Binding | Mode | Action | +|-------------|------|---------------------------------------------------------------| +| \J | N+V | Format line/selected lines to a max width of the _textwidth_ | +| \f | N+V | Format document/selection alignment using Vim syntax | +| \F | N | Format based on file-type using Autoformat | +| \F | N+V | (Markdown) Format table cursor is currently on | +| \t | N | Convert all tabs into spaces and continue session with spaces | +| \T | N | Convert all spaces into tabs and continue session with tabs | +| \w | N | Remove all trailing whitespace | +| \A | N+V | Align comments in document/selection | +| \a | N+V | Align comments following non-comments in document/selection | + +#### GVim #### + +| Binding | Mode | Action | +|---------------------|------|----------------------------------| +| \\ | ALL | Toggle the menubar **(gvim)** | +| \\ | ALL | Toggle the toolbar **(gvim)** | +| \\ | ALL | Toggle the scrollbars **(gvim)** | ### Complete Reference ### @@ -187,6 +201,7 @@ For a complete list of mappings specific to **darkcloud-vimconfig**, check the l * By Kevin MacMartin: [GitHub Projects](https://github.com/prurigro?tab=repositories) | [Arch Linux AUR Packages](https://aur.archlinux.org/packages/?SeB=m&K=prurigro) * The jellybean theme for Vim by [NanoTech](http://nanotech.nanotechcorp.net) was stripped down and used as a starting point to build the darkcloud theme included in this project. +* The [vim-markdown](https://github.com/plasticboy/vim-markdown) plugin **TableFormat** command, used to format tables in markdown files, was pulled into [plugins.vim](https://github.com/prurigro/darkcloud-vimconfig/blob/master/vim/config/plugins.vim) from [ftplugin/mkd](https://github.com/plasticboy/vim-markdown/blob/master/ftplugin/mkd.vim). ## License ## diff --git a/vim/config/after.vim b/vim/config/after.vim index b1acc6a..2626023 100644 --- a/vim/config/after.vim +++ b/vim/config/after.vim @@ -41,7 +41,8 @@ endif autocmd BufEnter,BufRead PKGBUILD setlocal iskeyword-=. "filtype specific settings - autocmd Filetype text,mkd,mkdc,gitcommit,notes,mail,notmuch,rst,taskreport setlocal nonumber spell nolist wrap linebreak breakat&vim breakat-=* breakat-=. breakat-=/ breakat-=? breakat-=, breakat-=: breakat-=; breakat-=! "set some defaults for word processing + autocmd Filetype text,mkd,mkdc,gitcommit,notes,mail,notmuch,rst,taskreport setlocal nonumber spell nolist linebreak breakat&vim breakat-=* breakat-=. breakat-=/ breakat-=? breakat-=, breakat-=: breakat-=; breakat-=! "set some defaults for word processing + autocmd Filetype text,gitcommit,notes,mail,notmuch,rst,taskreport setlocal wrap autocmd FileType help* wincmd L "help windows always open vertically autocmd FileType help* vertical resize 80 "set the window size to 80 cols autocmd FileType help* setlocal nocursorline "remove the horizontal cursor line diff --git a/vim/config/keyboard.vim b/vim/config/keyboard.vim index 65bb58a..7f42f4f 100644 --- a/vim/config/keyboard.vim +++ b/vim/config/keyboard.vim @@ -72,18 +72,20 @@ " | (N) -> create a new tab with vimfiler " | (N) -> create a new tab with a double pane vimfiler " +" (display) +" | (N) -> reset window and clear search +" // | (N) -> reset window and clear search +" " (toggles and features) -" ` | (N) -> popup a command reference +" ~ | (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) +" ` | (A) -> toggle the gutter(line numbers, folds and signify) " -" | (N) -> toggle selected fold -" | (N) -> open all folds +" | (N) -> toggle selected fold " = | (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 @@ -118,7 +120,6 @@ " " (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 @@ -162,16 +163,21 @@ " 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 +" T | (N) -> convert spaces into tabs +" w | (N) -> remove whitespace +" A | (N) -> aligns comments using the comment symbol " 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 +" > | (V) -> indent all the lines currently selected +" > | (N) -> indent the current line +" | (V) -> un-indent all the lines currently selected +" | (N) -> un-indent the current line +" < | (V) -> un-indent all the lines currently selected +" < | (N) -> un-indent the current line " " (movement) " = | (N) -> go to the first char on the next line @@ -217,8 +223,6 @@ " | (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 @@ -262,7 +266,9 @@ " <> | (N) -> update differences " >< | (N) -> update differences " > | (N) -> replace diff in other pane with current pane +" . | (N) -> replace diff in other pane with current pane " replace diff in current pane with other pane +" replace diff in current pane with other pane " " (vimfiler) " | (A) -> left click + left justify the cursor @@ -386,9 +392,15 @@ nnoremap ':VimFiler -tab -project -double' "} + "DISPLAY:{ + "clear search and reset buffer + nnoremap ':noh:redraw!' + nnoremap // ':noh:redraw!' + "} + "TOGGLES AND FEATURES:{ "toggle the command reference box - nnoremap ` ':TCommand' + nnoremap ~ ':TCommand' "display tag information in the gutter noremap , ':TTagechoWord' @@ -398,18 +410,16 @@ 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"' + 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 + 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"' + 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"' @@ -506,9 +516,6 @@ "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 @@ -555,7 +562,7 @@ return pumvisible() ? neocomplcache#close_popup() : "\" endfunction "neocomplcache tab completion - inoremap pumvisible() ? "\" : "\" + inoremap pumvisible() ? "\" : "\" "neocomplcache : undo completion inoremap neocomplcache#smart_close_popup()."\" "neocomplcache undo completion @@ -570,26 +577,35 @@ 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 + "format by Vim syntax + by Autoformat tool 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 + "convert tabs to spaces and spaces to tabs + nnoremap t ':set expandtab:retab!:echo "Tabs have been converted to spaces"' + nnoremap T ':set noexpandtab:%retab!:echo "Spaces have been converted to tabs"' + + "remove trailing whitespace 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, '[^%]*').'.*' + nnoremap A :exe "%Tabular" '/^[^'.matchstr(&commentstring, '[^%]*').']*\zs'.matchstr(&commentstring, '[^%]*').'.*':redraw! + vnoremap A :exe "'<,'>Tabular" '/^[^'.matchstr(&commentstring, '[^%]*').']*\zs'.matchstr(&commentstring, '[^%]*').'.*':redraw! - "tab and untab the currently selected lines + "align only comments following non-comments + nnoremap a :exe "%Tabular" '/^ *[^'.matchstr(&commentstring, '[^%]*').' ][^\'.matchstr(&commentstring, '[^%]*').']*\zs'.matchstr(&commentstring, '[^%]*').'.*':redraw! + vnoremap a :exe "'<,'>Tabular" '/^ *[^'.matchstr(&commentstring, '[^%]*').' ][^\'.matchstr(&commentstring, '[^%]*').']*\zs'.matchstr(&commentstring, '[^%]*').'.*':redraw! + + "tab/> and untab/< the currently selected lines vnoremap >gv nnoremap v>gv + vnoremap > >gv + nnoremap > v>gv vnoremap v + vnoremap < < v "} "MOVEMENT:{ @@ -650,9 +666,6 @@ xnoremap G$ xnoremap $ xnoremap ^ - - "clear search results - nnoremap // ':noh' "} "}}} @@ -681,7 +694,11 @@ autocmd FileType help map ? ':q' endif - "mappings for qf-based plugins + "markdown + autocmd FileType mkd nnoremap F ':TableFormat' + autocmd FileType mkd xnoremap F ':TableFormatgv' + + "qf-sidebar autocmd FileType qf map 0 autocmd FileType qf map autocmd FileType qf map @@ -699,7 +716,9 @@ 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 . dp|endif autocmd FilterWritePre * if &diff|nnoremap < do|endif + autocmd FilterWritePre * if &diff|nnoremap , do|endif autocmd FilterWritePre * if &diff|cabbrev q! qall!|endif "vimfiler @@ -713,7 +732,7 @@ autocmd FileType vimfiler map ~ q "}}} -"DISABLED MAPPINGS FOR FILETYPES: {{{ +"MAPPINGS DISABLED FOR GIVEN FILETYPES: {{{ "remove incompatible toggles from specific file types autocmd Filetype qf,gundo,vimfiler,tagbar,extradite,help noremap ~ autocmd Filetype qf,vimfiler,extradite,help noremap diff --git a/vim/config/plugins.vim b/vim/config/plugins.vim index 109b8db..427b42b 100644 --- a/vim/config/plugins.vim +++ b/vim/config/plugins.vim @@ -8,6 +8,14 @@ " License: MIT " " " "============================================================" +" +" Acknowledgements: +" +" The Tabular TableFormat() function is taken from the +" vim-markdown project by plasticboy, which can be found +" at https://github.com/plasticboy/vim-markdown and is +" licensed with the MIT license. +" "INITIALIZE PLUGINS: {{{ "create missing plugin config files and directories @@ -167,6 +175,24 @@ endif "}}} +"TAGBAR: {{{ + " TableFormat() for formatting markdown tables with Tabular + function! s:TableFormat() + let l:pos = getpos('.') + normal! { + " Search instead of `normal! j` because of the table at beginning of file edge case. + call search('|') + normal! j + " Remove everything that is not a pipe othewise well formated tables would grow + " because of addition of 2 spaces on the separator line by Tabularize /|. + s/[^|]//g + Tabularize /| + s/ /-/g + call setpos('.', l:pos) + endfunction + command! -buffer TableFormat call s:TableFormat() +"}}} + "TAGBAR: {{{ "autostart tagbar when vim opens to a compatible filetype (default: 0) if !exists("g:autostarttagbar")