From f4ff4c3280748a158ce8a58377e22a03155c3e29 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 10 Jun 2019 08:58:23 +1200 Subject: Break mapping lines in two This seems to do syntax highlighting a little more usefully, too. --- vim/vimrc | 267 +++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 178 insertions(+), 89 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 2e5d693d..bd66a019 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -1020,9 +1020,11 @@ endtry " if globpath(&runtimepath, 'plugin/scroll_next.vim') !=# '' \ && &loadplugins - nmap (ScrollNext) + nmap + \ (ScrollNext) else - nnoremap + nnoremap + \ endif " I hate CTRL-C in insert mode, which ends the insert session without firing @@ -1062,7 +1064,8 @@ endif " if globpath(&runtimepath, 'plugin/insert_cancel.vim') !=# '' \ && &loadplugins - imap (InsertCancel) + imap + \ (InsertCancel) endif " I often don't remember or can't guess digraph codes very well, and want to @@ -1097,211 +1100,297 @@ endif " checking that the plugin's available before we map to it; it'll just quietly " do nothing. " -imap (DigraphSearch) +imap + \ (DigraphSearch) " Stack Ctrl-L to clear search highlight, make it work in insert mode too -nnoremap :nohlsearch -vnoremap :nohlsearchgv -inoremap :nohlsearch +nnoremap + \ :nohlsearch +vnoremap + \ :nohlsearchgv +inoremap + \ :nohlsearch " Remap normal/visual & and g& to preserve substitution flags -nnoremap & :&& -xnoremap & :&& -nnoremap g& :%&& +nnoremap & + \ :&& +xnoremap & + \ :&& +nnoremap g& + \ :%&& " Map g: as a 'colon operator' -nmap g: (ColonOperator) +nmap g: + \ (ColonOperator) " Cycle through argument list -nnoremap [a :previous -nnoremap ]a :next +nnoremap [a + \ :previous +nnoremap ]a + \ :next " Cycle through buffers -nnoremap [b :bprevious -nnoremap ]b :bnext +nnoremap [b + \ :bprevious +nnoremap ]b + \ :bnext " Cycle through quickfix list items -nnoremap [c :cprevious -nnoremap ]c :cnext +nnoremap [c + \ :cprevious +nnoremap ]c + \ :cnext " Cycle through location list items -nnoremap [l :lprevious -nnoremap ]l :lnext +nnoremap [l + \ :lprevious +nnoremap ]l + \ :lnext " Insert blank lines around current line -nmap [ (PutBlankLinesAbove) -nmap ] (PutBlankLinesBelow) +nmap [ + \ (PutBlankLinesAbove) +nmap ] + \ (PutBlankLinesBelow) " Set leader keys let mapleader = '\' let maplocalleader = ',' " Leader,a toggles 'formatoptions' 'a' flag using a plugin -nnoremap a :ToggleFlagLocal formatoptions a +nnoremap a + \ :ToggleFlagLocal formatoptions a " Leader,b toggles settings friendly to copying and pasting -nmap b (CopyLinebreakToggle) +nmap b + \ (CopyLinebreakToggle) " Leader,c toggles 'cursorline'; no visual mode map as it doesn't work -nnoremap c :setlocal cursorline! cursorline? +nnoremap c + \ :setlocal cursorline! cursorline? " Leader,C toggles 'cursorcolumn'; works in visual mode -nnoremap C :setlocal cursorcolumn! cursorcolumn? -xnoremap C :setlocal cursorcolumn! cursorcolumn?gv +nnoremap C + \ :setlocal cursorcolumn! cursorcolumn? +xnoremap C + \ :setlocal cursorcolumn! cursorcolumn?gv " Leader,d inserts the local date (POSIX date) -nnoremap d :read !date +nnoremap d + \ :read !date " Leader,D inserts the UTC date (POSIX date) -nnoremap D :read !date -u +nnoremap D + \ :read !date -u " Leader,e forces a buffer to be editable -nnoremap e :setlocal modifiable noreadonly +nnoremap e + \ :setlocal modifiable noreadonly " Leader,f shows the current 'formatoptions' at a glance -nnoremap f :setlocal formatoptions? +nnoremap f + \ :setlocal formatoptions? " Leader,F reloads filetype plugins -nnoremap F :FileTypeReload +nnoremap F + \ :FileTypeReload " Leader,g shows the current file's fully expanded path -nnoremap g :echo expand('%:p') +nnoremap g + \ :echo expand('%:p') " Leader,G changes directory to the current file's location -nnoremap G :cd %:hpwd +nnoremap G + \ :cd %:hpwd " Leader,h toggles highlighting search results -nnoremap h :set hlsearch! hlsearch? +nnoremap h + \ :set hlsearch! hlsearch? " Leader,H shows command history -nnoremap H :history : +nnoremap H + \ :history : " Leader,i toggles showing matches as I enter my pattern -nnoremap i :set incsearch! incsearch? +nnoremap i + \ :set incsearch! incsearch? " Leader,j jumps to buffers ("jetpack") -nnoremap j :buffers:buffer +nnoremap j + \ :buffers:buffer " Leader,k shows my marks -nnoremap k :marks +nnoremap k + \ :marks " Leader,l toggles showing tab, end-of-line, and trailing white space -nnoremap l :setlocal list! list? -xnoremap l :setlocal list! list?gv +nnoremap l + \ :setlocal list! list? +xnoremap l + \ :setlocal list! list?gv " Leader,L toggles 'colorcolumn' showing 'textwidth' -nnoremap L :ToggleFlagLocal colorcolumn +1 -xnoremap L :ToggleFlagLocal colorcolumn +1gv +nnoremap L + \ :ToggleFlagLocal colorcolumn +1 +xnoremap L + \ :ToggleFlagLocal colorcolumn +1gv " Leader,m shows normal maps -nnoremap m :map +nnoremap m + \ :map " Leader,M shows buffer-local normal maps -nnoremap M :map +nnoremap M + \ :map " Leader,n toggles line number display -nnoremap n :setlocal number! number? -xnoremap n :setlocal number! number?gv +nnoremap n + \ :setlocal number! number? +xnoremap n + \ :setlocal number! number?gv " Leader,N toggles position display in bottom right -nnoremap N :set ruler! ruler? -xnoremap N :set ruler! ruler?gv +nnoremap N + \ :set ruler! ruler? +xnoremap N + \ :set ruler! ruler?gv " Leader,o opens a line below in paste mode -nmap o (PasteOpenBelow) +nmap o + \ (PasteOpenBelow) " Leader,O opens a line above in paste mode -nmap O (PasteOpenAbove) +nmap O + \ (PasteOpenAbove) " Leader,p toggles paste mode -nnoremap p :set paste! paste? +nnoremap p + \ :set paste! paste? " Leader,P creates the path to the current file -nnoremap P :call mkdir(expand('%:h'), 'p') +nnoremap P + \ :call mkdir(expand('%:h'), 'p') " Leader,q formats the current paragraph -nnoremap q gqap +nnoremap q + \ gqap " Leader,r acts as a replacement operator -nmap r (ReplaceOperator) -xmap r (ReplaceOperator) +nmap r + \ (ReplaceOperator) +xmap r + \ (ReplaceOperator) " Leader,R reloads ~/.vimrc -nnoremap R :source $MYVIMRC +nnoremap R + \ :source $MYVIMRC " Leader,s toggles spell checking -nnoremap s :setlocal spell! spell? +nnoremap s + \ :setlocal spell! spell? " Leader,S shows loaded scripts -nnoremap S :scriptnames +nnoremap S + \ :scriptnames " Leader,t shows current filetype -nnoremap t :setlocal filetype? +nnoremap t + \ :setlocal filetype? " Leader,T clears filetype -nnoremap T :setlocal filetype= +nnoremap T + \ :setlocal filetype= " Leader,u sets US English spelling (compare Leader,z) -nnoremap u :setlocal spelllang=en_us +nnoremap u + \ :setlocal spelllang=en_us " Leader,v shows all global variables -nnoremap v :let g: v: +nnoremap v + \ :let g: v: " Leader,V shows all local variables -nnoremap V :let b: t: w: +nnoremap V + \ :let b: t: w: " Leader,w toggles wrapping -nnoremap w :setlocal wrap! wrap? -xnoremap w :setlocal wrap! wrap?gv +nnoremap w + \ :setlocal wrap! wrap? +xnoremap w + \ :setlocal wrap! wrap?gv " Leader,x strips trailing whitespace via a custom plugin -nnoremap x :StripTrailingWhitespace -xnoremap x :StripTrailingWhitespace +nnoremap x + \ :StripTrailingWhitespace +xnoremap x + \ :StripTrailingWhitespace " Leader,X squeezes repeated blank lines via a custom plugin -nnoremap X :SqueezeRepeatBlanks -xnoremap X :SqueezeRepeatBlanks +nnoremap X + \ :SqueezeRepeatBlanks +xnoremap X + \ :SqueezeRepeatBlanks " Leader,y shows all registers -nnoremap y :registers +nnoremap y + \ :registers " Leader,z sets NZ English spelling (compare Leader,u) -nnoremap z :setlocal spelllang=en_nz +nnoremap z + \ :setlocal spelllang=en_nz " Leader,= runs the whole buffer through =, preserving position -nnoremap = :KeepPosition normal! 1G=G +nnoremap = + \ :KeepPosition normal! 1G=G " Leader,+ runs the whole buffer through gq, preserving position -nnoremap + :KeepPosition normal! 1GgqG +nnoremap + + \ :KeepPosition normal! 1GgqG " Leader,. runs the configured make program into the location list -nnoremap . :lmake! +nnoremap . + \ :lmake! " Leader,< and Leader,> adjust indent of last edit; good for pasting -nnoremap :'[,'] -nnoremap > :'[,']> +nnoremap + \ :'[,'] +nnoremap > + \ :'[,']> " Leader,_ uses last changed or yanked text as an object -onoremap _ :normal! `[v`] +onoremap _ + \ :normal! `[v`] " Leader,% uses entire buffer as an object -onoremap % :normal! 1GVG +onoremap % + \ :normal! 1GVG " Leader,{ and Leader,} move to lines with non-space chars before current column -map { (VerticalRegionUp) +map { + \ (VerticalRegionUp) sunmap { -map } (VerticalRegionDown) +map } + \ (VerticalRegionDown) sunmap } " Leader,/ types :vimgrep for me ready to enter a search pattern -nnoremap / :vimgrep /\c/j ** +nnoremap / + \ :vimgrep /\c/j ** " Leader,? types :lhelpgrep for me ready to enter a search pattern -nnoremap ? :lhelpgrep \c +nnoremap ? + \ :lhelpgrep \c " Leader,* escapes regex metacharacters -nmap * (RegexEscape) -xmap * (RegexEscape) +nmap * + \ (RegexEscape) +xmap * + \ (RegexEscape) " Leader,\ jumps to the last edit position mark, like g;, but works as a motion " "Now, where was I?" (tap-tap) -nnoremap \ `" -xnoremap \ `" +nnoremap \ + \ `" +xnoremap \ + \ `" " Leader,DEL deletes the current buffer -nnoremap :bdelete +nnoremap + \ :bdelete " Leader,INS edits a new buffer -nnoremap :enew +nnoremap + \ :enew " Leader,TAB toggles 'autoindent' -nnoremap :setlocal autoindent! autoindent? +nnoremap + \ :setlocal autoindent! autoindent? " Some useful abbreviations inoreabbrev tr@ tom@sanctum.geek.nz -- cgit v1.2.3