aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-11 00:07:47 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-11 00:28:01 +1200
commitd249084db5d90f006ac73b441c24a977bcf2e4b4 (patch)
tree64ad34435de48f41954b3c78f145adb30ea38e06
parentUpdate vim-cursorline-current to v2.0.1 (diff)
downloaddotfiles-d249084db5d90f006ac73b441c24a977bcf2e4b4.tar.gz
dotfiles-d249084db5d90f006ac73b441c24a977bcf2e4b4.zip
Lots more progress on documentating literate vimrc
-rw-r--r--vim/vimrc549
1 files changed, 350 insertions, 199 deletions
diff --git a/vim/vimrc b/vim/vimrc
index d044ff74..013786f6 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -988,11 +988,9 @@ endtry
" * Avoid shadowing any of Vim's existing functionality. If possible, extend
" or supplement what Vim does, rather than replacing it.
"
-
-" We'll start with the non-leader mappings. Ideally there shouldn't be too
+" We'll start with the non-leader mappings. Ideally, there shouldn't be too
" many of these.
"
-
" I like using the space bar to scroll down a page, so I can lazily tap it to
" read documents, and I find its default behaviour of moving right one
" character to be useless.
@@ -1101,322 +1099,475 @@ endif
imap <C-K><C-K>
\ <Plug>(DigraphSearch)
-" Stack Ctrl-L to clear search highlight, make it work in insert mode too
+" I end up hitting CTRL-L to clear or redraw the screen in interactive shells
+" and tools like Mutt and Vim pretty often. It feels natural to me to stack
+" issuing a :nohlsearch command to stop highlighting searches on top of this.
+"
+" This gets by far the most use in normal mode, but I'd like it to work in
+" visual and insert mode, too, where it's occasionally useful, especially on
+" things like mobile phone terminal emulators that can be choppy and require
+" a lot of redrawing.
+"
+" For each of these, we end the mapping with a CTRL-L in normal mode, thereby
+" extending rather than replacing Vim's normal behaviour.
+"
nnoremap <C-L>
\ :<C-U>nohlsearch<CR><C-L>
+
+" We use :vnoremap rather than :xnoremap and thereby make the mapping apply to
+" select mode as well, because CTRL-L doesn't reflect a printable character,
+" and so we may as well, even though I never use select mode directly.
+"
vnoremap <C-L>
\ :<C-U>nohlsearch<CR>gv<C-L>
+
+" The insert mode mapping uses CTRL-O to issue a single normal normal-mode
+" command, but twice: once to issue the :nohlsearch command, and then once to
+" issue an unmapped normal-mode CTRL-L.
+"
inoremap <C-L>
\ <C-O>:<C-U>nohlsearch<CR><C-O><C-L>
-" Remap normal/visual & and g& to preserve substitution flags
+" By default, the very-useful normal mode command '&' that repeats the
+" previous :substitute command doesn't preserve the flags from that
+" substitution. I'd prefer it to do so, like the :&& command does, and it's
+" easily remapped for both normal and visual mode, so let's just do it.
+"
nnoremap &
\ :&&<CR>
xnoremap &
\ :&&<CR>
-nnoremap g&
- \ :<C-U>%&&<CR>
-" Map g: as a 'colon operator'
+" I really like using the '!' command in normal mode as an operator to filter
+" text through a shell command. It always bugged me a little that there
+" didn't seem to be an analogue for a motion to filter text through an
+" internal command like :sort, so I wrote one.
+"
nmap g:
\ <Plug>(ColonOperator)
-" Cycle through argument list
+" I used Tim Pope's unimpaired.vim plugin for ages, and I liked some of these
+" bracket pair mappings, so I've carried a few of the simpler ones over. All
+" of these can be prefixed with a count if needed, too. I use all of them
+" pretty regularly, even though cycling through lists to look for something
+" can be a bit wasteful.
+"
+
+" Argument list
nnoremap [a
\ :previous<CR>
nnoremap ]a
\ :next<CR>
-" Cycle through buffers
+" Buffers
nnoremap [b
\ :bprevious<CR>
nnoremap ]b
\ :bnext<CR>
-" Cycle through quickfix list items
+" Quickfix list
nnoremap [c
\ :cprevious<CR>
nnoremap ]c
\ :cnext<CR>
-" Cycle through location list items
+" Location list
nnoremap [l
\ :lprevious<CR>
nnoremap ]l
\ :lnext<CR>
-" Insert blank lines around current line
+" Here's another mapping I particularly liked from unimpaired.vim here; insert
+" blank lines from normal mode, using a custom plugin of mine called
+" put_blank_lines.vim. These use operator functions so that they're
+" repeatable without repeat.vim. They accept count prefixes, too.
+"
nmap [<Space>
\ <Plug>(PutBlankLinesAbove)
nmap ]<Space>
\ <Plug>(PutBlankLinesBelow)
-" Set leader keys
+" We're on to the leader maps, now. It's difficult to know what order to put
+" these in; I originally had them in alphabetical order, but it seems more
+" useful now to group the by the category of their function, albeit roughly.
+"
+" First of all, let's set the leader keys; backslash happens to be the
+" default, but I like to make my choice explicit here.
+"
+" As of 2019, I'm still not certain that comma is the best choice for my local
+" leader. I use it all the time for this purpose, and it works well, but
+" I don't much like that it shadows a useful function in the fFtT;, group, and
+" wonder if I would use it more if I hadn't shadowed it.
+"
let mapleader = '\'
let maplocalleader = ','
-" Leader,a toggles 'formatoptions' 'a' flag using a plugin
-nnoremap <Leader>a
- \ :<C-U>ToggleFlagLocal formatoptions a<CR>
-
-" Leader,b toggles settings friendly to copying and pasting
-nmap <Leader>b
- \ <Plug>(CopyLinebreakToggle)
+" Let's start with some simple ones; these ones all just toggle a boolean
+" option, and print its new value. They're dirt simple to specify, and don't
+" require any plugins.
+"
+" These are sometimes applicable in visual mode, and sometimes not. We'll
+" start with the ones that only make sense as normal mode maps. Interesting,
+" a visual mode mapping for 'cursorline' toggling doesn't work at all;
+" 'cursorline' is always off when in any visual mode, including block mode,
+" where it actually might have been really handy.
-" Leader,c toggles 'cursorline'; no visual mode map as it doesn't work
+"" Leader,TAB toggles automatic indentation based on the previous line
+nnoremap <Leader><Tab>
+ \ :<C-U>setlocal autoindent! autoindent?<CR>
+"" Leader,c toggles highlighted cursor row; doesn't work in visual mode
nnoremap <Leader>c
\ :<C-U>setlocal cursorline! cursorline?<CR>
-" Leader,C toggles 'cursorcolumn'; works in visual mode
+"" Leader,h toggles highlighting search results
+nnoremap <Leader>h
+ \ :<C-U>set hlsearch! hlsearch?<CR>
+"" Leader,i toggles showing matches as I enter my pattern
+nnoremap <Leader>i
+ \ :<C-U>set incsearch! incsearch?<CR>
+"" Leader,s toggles spell checking
+nnoremap <Leader>s
+ \ :<C-U>setlocal spell! spell?<CR>
+
+" The next group of option-toggling maps are much the same as the previous
+" group, except they also include analogous maps for visual mode, defined as
+" recursive maps into normal mode that conclude with re-selecting the text.
+
+"" Leader,C toggles highlighted cursor column; works in visual mode
nnoremap <Leader>C
\ :<C-U>setlocal cursorcolumn! cursorcolumn?<CR>
-xnoremap <Leader>C
- \ :<C-U>setlocal cursorcolumn! cursorcolumn?<CR>gv
+xmap <Leader>C
+ \ <Esc><Leader>Cgv
+"" Leader,l toggles showing tab, end-of-line, and trailing white space
+nnoremap <Leader>l
+ \ :<C-U>setlocal list! list?<CR>
+xmap <Leader>l
+ \ <Esc><Leader>lgv
+"" Leader,n toggles line number display
+nnoremap <Leader>n
+ \ :<C-U>setlocal number! number?<CR>
+xmap <Leader>n
+ \ <Esc><Leader>ngv
+"" Leader,N toggles position display in bottom right
+nnoremap <Leader>N
+ \ :<C-U>set ruler! ruler?<CR>
+xmap <Leader>N
+ \ <Esc><Leader>Ngv
+"" Leader,p toggles paste mode
+nnoremap <Leader>p
+ \ :<C-U>set paste! paste?<CR>
+xmap <Leader>p
+ \ <Esc><Leader>pgv
+"" Leader,w toggles soft wrapping
+nnoremap <Leader>w
+ \ :<C-U>setlocal wrap! wrap?<CR>
+xmap <Leader>w
+ \ <Esc><Leader>wgv
-" Insert an RFC2822-compliant date string into the buffer
-command! -range PutDate
- \ <line1>put =strftime('%a, %d %b %Y %T %z')
+" This next one just shows option state of the 'formatoptions' affecting how
+" text is automatically formatted; it doesn't change its value.
+
+"" Leader,f shows the current 'formatoptions' at a glance
+nnoremap <Leader>f
+ \ :<C-U>setlocal formatoptions?<CR>
+
+" I often have to switch between US English and NZ English. The latter is
+" almost exactly the same as UK English in most locales, although we use
+" dollars rather than pounds. This is mostly so I remember things like
+" excluding or including the 'u' in words like 'favourite', depending on the
+" target audience. I generally use US English for international audiences.
+
+"" Leader,u sets US English spelling language
+nnoremap <Leader>u
+ \ :<C-U>setlocal spelllang=en_us<CR>
+"" Leader,z sets NZ English spelling language
+nnoremap <Leader>z
+ \ :<C-U>setlocal spelllang=en_nz<CR>
+
+" The next mapping is another option toggler, but it's more complicated; it
+" uses a simple plugin of mine called copy_linebreak.vim to manage several
+" options at once, related to the 'wrap' option that soft-wraps text.
+"
+" It's designed for usage in terminal emulators and multiplexers to
+" temporarily make the buffer text suitable for copying in such a way that the
+" wrapping and any associated soft formatting won't pervert the text,
+" including 'breakindent', 'linebreak', and 'showbreak' artifacts.
+"
+" This is really handy for quick selections of small regions of text. For
+" larger blocks of text or for programatically manipulating the text as it
+" leaves the buffer, it makes more sense to use :! commands.
+"
+
+"" Leader,b toggles settings friendly to copying and pasting
+nmap <Leader>b
+ \ <Plug>(CopyLinebreakToggle)
+
+" The above mappings show that mappings for toggling boolean options are
+" simple, but there isn't a way to toggle single flags within option strings,
+" so I wrote a plugin called toggle_flags.vim to provide :ToggleFlag and
+" :ToggleFlagLocal commands. The first argument is the name of an option, and
+" the second is the flag within it that should be toggled on or off.
+
+"" Leader,a toggles 'formatoptions' 'a' auto-flowing flag
+nnoremap <Leader>a
+ \ :<C-U>ToggleFlagLocal formatoptions a<CR>
+"" Leader,L toggles 'colorcolumn' showing the first column beyond 'textwidth'
+nnoremap <Leader>L
+ \ :<C-U>ToggleFlagLocal colorcolumn +1<CR>
+xmap <Leader>L
+ \ <Esc><Leader>Lgv
+
+" These mappings are for managing filetypes. The first one uses the
+" :FileTypeReload command that was defined much earlier in this file.for
+" a vimrc reload hook.
+
+"" Leader,F reloads filetype plugins
+nnoremap <Leader>F
+ \ :<C-U>FileTypeReload<CR>
+"" Leader,t shows current filetype
+nnoremap <Leader>t
+ \ :<C-U>setlocal filetype?<CR>
+"" Leader,T clears filetype
+nnoremap <Leader>T
+ \ :<C-U>setlocal filetype=<CR>
" Set up a quick command-function pair to run a command with the UTC timezone,
-" in this case, for my date-printing mappings. Is there a nicer way to do
-" this? I couldn't find one.
+" in this case, for my date-printing mappings. To do this, we define two new
+" commands, one of which uses a script-local function.
+"
+" While this is a tidy way to abstract the operation for the map, I don't like
+" the function implementation much at all. It works OK in stable versions of
+" Vim, but changing an environment variable just long enough to affect the
+" outcome of a command as a side effect seems a bit gross.
+"
+" Worse, the whole thing presently seems to be broken in v8.1.1487; the
+" timezone first chosen seems to 'stick' permanently, and the mapping each
+" produce timestamps in that zone. I haven't worked out why this happens yet.
+" Using the new getenv() and setenv() functions does not seem to fix it. It
+" works fine in Debian GNU/Linux's packaged v8.0.x.
+
+" First, of all, we define a :PutDate command that inserts a line into the buffer with
+" an RFC-2822 date string, using the system strftime() implementation. This
+" might be useful outside of the vimrc, too; we allow it to accept a range
+" which defaults to the current line.
"
-" This presently seems to be broken in v8.1.1487; the timezone first chosen
-" seems to 'stick' permanently. I haven't worked out why yet. Using the new
-" getenv() and setenv() functions does not seem to fix it. It works fine in
-" Debian GNU/Linux's packaged v8.0.x.
+command! -range PutDate
+ \ <line1>put =strftime('%a, %d %b %Y %T %z')
+
+" Next, we define a :UTC command wrapper, implemented with a script-local
+" function of the same name. We use expand('$TZ') to ensure we're getting the
+" value of the current timezone from the environment, and cache that in
+" a local variable just long enough to manipulate the environment into using
+" UTC for a command, in our case, the newly-defined :PutDate command.
"
function! s:UTC(command) abort
let tz = expand('$TZ')
let $TZ = 'UTC' | execute a:command | let $TZ = tz
endfunction
+
+" The :UTC command itself completes another command name, and accepts one
+" required argument, which it passes in quoted form to the helper function.
+"
command! -complete=command -nargs=1 UTC
\ call s:UTC(<q-args>)
-" Leader,d inserts the local date (RFC 2822)
+" And finally, we define the maps that actually use the commands.
+
+"" Leader,d inserts the local date (RFC 2822)
nnoremap <Leader>d
\ :<C-U>PutDate<CR>
-" Leader,D inserts the UTC date (RFC 2822)
+"" Leader,D inserts the UTC date (RFC 2822)
nnoremap <Leader>D
\ :<C-U>UTC PutDate<CR>
-" Leader,e forces a buffer to be editable
-nnoremap <Leader>e
- \ :<C-U>setlocal modifiable noreadonly<CR>
-
-" Leader,f shows the current 'formatoptions' at a glance
-nnoremap <Leader>f
- \ :<C-U>setlocal formatoptions?<CR>
-
-" Leader,F reloads filetype plugins
-nnoremap <Leader>F
- \ :<C-U>FileTypeReload<CR>
+" This group contains mappings that are to do with file and path management
+" relative to the current buffer.
-" Leader,g shows the current file's fully expanded path
+"" Leader,g shows the current file's fully expanded path
nnoremap <Leader>g
\ :<C-U>echo expand('%:p')<CR>
-" Leader,G changes directory to the current file's location
+"" Leader,G changes directory to the current file's location
nnoremap <Leader>G
\ :<C-U>cd %:h<Bar>pwd<CR>
+"" Leader,P creates the path to the current file
+nnoremap <Leader>P
+ \ :<C-U>call mkdir(expand('%:h'), 'p')<CR>
-" Leader,h toggles highlighting search results
-nnoremap <Leader>h
- \ :<C-U>set hlsearch! hlsearch?<CR>
+" This group contains mappings that show information about Vim's internals:
+" marks, registers, variables, and the like.
-" Leader,H shows command history
+"" Leader,H shows command history
nnoremap <Leader>H
\ :<C-U>history :<CR>
-
-" Leader,i toggles showing matches as I enter my pattern
-nnoremap <Leader>i
- \ :<C-U>set incsearch! incsearch?<CR>
-
-" Leader,j jumps to buffers ("jetpack")
-nnoremap <Leader>j
- \ :<C-U>buffers<CR>:buffer<Space>
-
-" Leader,k shows my marks
+"" Leader,k shows my marks
nnoremap <Leader>k
\ :<C-U>marks<CR>
-
-" Leader,l toggles showing tab, end-of-line, and trailing white space
-nnoremap <Leader>l
- \ :<C-U>setlocal list! list?<CR>
-xnoremap <Leader>l
- \ :<C-U>setlocal list! list?<CR>gv
-
-" Leader,L toggles 'colorcolumn' showing 'textwidth'
-nnoremap <Leader>L
- \ :<C-U>ToggleFlagLocal colorcolumn +1<CR>
-xnoremap <Leader>L
- \ :<C-U>ToggleFlagLocal colorcolumn +1<CR>gv
-
-" Leader,m shows normal maps
+"" Leader,m shows normal maps
nnoremap <Leader>m
\ :<C-U>map<CR>
-" Leader,M shows buffer-local normal maps
+"" Leader,M shows buffer-local normal maps
nnoremap <Leader>M
\ :<C-U>map <buffer><CR>
-
-" Leader,n toggles line number display
-nnoremap <Leader>n
- \ :<C-U>setlocal number! number?<CR>
-xnoremap <Leader>n
- \ :<C-U>setlocal number! number?<CR>gv
-" Leader,N toggles position display in bottom right
-nnoremap <Leader>N
- \ :<C-U>set ruler! ruler?<CR>
-xnoremap <Leader>N
- \ :<C-U>set ruler! ruler?<CR>gv
-
-" Leader,o opens a line below in paste mode
-nmap <Leader>o
- \ <Plug>(PasteOpenBelow)
-" Leader,O opens a line above in paste mode
-nmap <Leader>O
- \ <Plug>(PasteOpenAbove)
-
-" Leader,p toggles paste mode
-nnoremap <Leader>p
- \ :<C-U>set paste! paste?<CR>
-
-" Leader,P creates the path to the current file
-nnoremap <Leader>P
- \ :<C-U>call mkdir(expand('%:h'), 'p')<CR>
-
-" Leader,q formats the current paragraph
-nnoremap <Leader>q
- \ gqap
-
-" Leader,r acts as a replacement operator
-nmap <Leader>r
- \ <Plug>(ReplaceOperator)
-xmap <Leader>r
- \ <Plug>(ReplaceOperator)
-
-" Leader,R reloads ~/.vimrc
-nnoremap <Leader>R
- \ :<C-U>source $MYVIMRC<CR>
-
-" Leader,s toggles spell checking
-nnoremap <Leader>s
- \ :<C-U>setlocal spell! spell?<CR>
-
-" Leader,S shows loaded scripts
+"" Leader,S shows loaded scripts
nnoremap <Leader>S
\ :<C-U>scriptnames<CR>
-
-" Leader,t shows current filetype
-nnoremap <Leader>t
- \ :<C-U>setlocal filetype?<CR>
-" Leader,T clears filetype
-nnoremap <Leader>T
- \ :<C-U>setlocal filetype=<CR>
-
-" Leader,u sets US English spelling (compare Leader,z)
-nnoremap <Leader>u
- \ :<C-U>setlocal spelllang=en_us<CR>
-
-" Leader,v shows all global variables
+"" Leader,v shows all global variables
nnoremap <Leader>v
\ :<C-U>let g: v:<CR>
-" Leader,V shows all local variables
+"" Leader,V shows all local variables
nnoremap <Leader>V
\ :<C-U>let b: t: w:<CR>
+"" Leader,y shows all registers
+nnoremap <Leader>y
+ \ :<C-U>registers<CR>
-" Leader,w toggles wrapping
-nnoremap <Leader>w
- \ :<C-U>setlocal wrap! wrap?<CR>
-xnoremap <Leader>w
- \ :<C-U>setlocal wrap! wrap?<CR>gv
+" This group contains mappings concerned with buffer navigation and
+" management. I use the "jetpack" buffer jumper one like crazy; I really like
+" it. I got it from one of bairui's "Vim and Vigor" comics:
+"
+" <http://of-vim-and-vigor.blogspot.com/p/vim-vigor-comic.html>
+
+"" Leader,DEL deletes the current buffer
+nnoremap <Leader><Delete>
+ \ :bdelete<CR>
+"" Leader,INS edits a new buffer
+nnoremap <Leader><Insert>
+ \ :<C-U>enew<CR>
+"" Leader,e forces a buffer to be editable, even a :help one
+nnoremap <Leader>e
+ \ :<C-U>setlocal modifiable noreadonly<CR>
+"" Leader,E locks a buffer, reversible with <Leader>e
+nnoremap <Leader>e
+ \ :<C-U>setlocal nomodifiable readonly<CR>
+"" Leader,j jumps to buffers ("jetpack")
+nnoremap <Leader>j
+ \ :<C-U>buffers<CR>:buffer<Space>
+
+" Filtering and batch operations to clean up buffer text
-" Leader,x strips trailing whitespace via a custom plugin
+"" Leader,x strips trailing whitespace via a custom plugin
nnoremap <Leader>x
\ :StripTrailingWhitespace<CR>
xnoremap <Leader>x
\ :StripTrailingWhitespace<CR>
-
-" Leader,X squeezes repeated blank lines via a custom plugin
+"" Leader,X squeezes repeated blank lines via a custom plugin
nnoremap <Leader>X
\ :SqueezeRepeatBlanks<CR>
xnoremap <Leader>X
\ :SqueezeRepeatBlanks<CR>
-
-" Leader,y shows all registers
-nnoremap <Leader>y
- \ :<C-U>registers<CR>
-
-" Leader,z sets NZ English spelling (compare Leader,u)
-nnoremap <Leader>z
- \ :<C-U>setlocal spelllang=en_nz<CR>
-
-" Leader,= runs the whole buffer through =, preserving position
+"" Leader,= runs the whole buffer through =, preserving position
nnoremap <Leader>=
\ :<C-U>KeepPosition normal! 1G=G<CR>
-" Leader,+ runs the whole buffer through gq, preserving position
+"" Leader,+ runs the whole buffer through gq, preserving position
nnoremap <Leader>+
\ :<C-U>KeepPosition normal! 1GgqG<CR>
-" Leader,. runs the configured make program into the location list
-nnoremap <Leader>.
- \ :<C-U>lmake!<CR>
-
-" Leader,< and Leader,> adjust indent of last edit; good for pasting
-nnoremap <Leader><lt>
- \ :<C-U>'[,']<lt><CR>
-nnoremap <Leader>>
- \ :<C-U>'[,']><CR>
+" This group defines a few :onoremap commands to make my own text objects.
+" I should probably make some more of these, as they've proven to be
+" terrifically handy.
-" Leader,_ uses last changed or yanked text as an object
+"" Leader,_ uses last changed or yanked text as an object
onoremap <Leader>_
\ :<C-U>normal! `[v`]<CR>
-
-" Leader,% uses entire buffer as an object
+"" Leader,% uses entire buffer as an object
onoremap <Leader>%
\ :<C-U>normal! 1GVG<CR>
-" Leader,{ and Leader,} move to lines with non-space chars before current column
+" This group defines some useful motions.
+
+"" Leader,{ and Leader,} move to lines with non-space chars before current column
map <Leader>{
\ <Plug>(VerticalRegionUp)
sunmap <Leader>{
map <Leader>}
\ <Plug>(VerticalRegionDown)
sunmap <Leader>}
+"" Leader,\ jumps to the last edit position mark: think "Now, where was I?"
+nnoremap <Leader>\
+ \ `"
+xnoremap <Leader>\
+ \ `"
+
+" This group does both: useful motions on defined text objects.
-" Leader,/ types :vimgrep for me ready to enter a search pattern
+"" Leader,< and Leader,> adjust indent of last edit; good for pasting
+nnoremap <Leader><lt>
+ \ :<C-U>'[,']<lt><CR>
+nnoremap <Leader>>
+ \ :<C-U>'[,']><CR>
+
+" This group is for directory tree or help search convenience mappings.
+
+"" Leader,/ types :vimgrep for me ready to enter a search pattern
nnoremap <Leader>/
\ :<C-U>vimgrep /\c/j **<S-Left><S-Left><Right>
-" Leader,? types :lhelpgrep for me ready to enter a search pattern
+"" Leader,? types :lhelpgrep for me ready to enter a search pattern
nnoremap <Leader>?
\ :<C-U>lhelpgrep \c<S-Left>
-" Leader,* escapes regex metacharacters
+" This group contains miscellaneous mappings for which I couldn't find any
+" other place. The plugin mappings probably require their own documentation
+" comment block, but my hands are getting tired from all this typing.
+
+"" Leader,. runs the configured make program into the location list
+nnoremap <Leader>.
+ \ :<C-U>lmake!<CR>
+"" Leader,o opens a line below in paste mode
+nmap <Leader>o
+ \ <Plug>(PasteOpenBelow)
+"" Leader,O opens a line above in paste mode
+nmap <Leader>O
+ \ <Plug>(PasteOpenAbove)
+"" Leader,q formats the current paragraph
+nnoremap <Leader>q
+ \ gqap
+"" Leader,r acts as a replacement operator
+nmap <Leader>r
+ \ <Plug>(ReplaceOperator)
+xmap <Leader>r
+ \ <Plug>(ReplaceOperator)
+"" Leader,* escapes regex metacharacters
nmap <Leader>*
\ <Plug>(RegexEscape)
xmap <Leader>*
\ <Plug>(RegexEscape)
-" Leader,\ jumps to the last edit position mark, like g;, but works as a motion
-" "Now, where was I?" (tap-tap)
-nnoremap <Leader>\
- \ `"
-xnoremap <Leader>\
- \ `"
-
-" Leader,DEL deletes the current buffer
-nnoremap <Leader><Delete>
- \ :bdelete<CR>
-" Leader,INS edits a new buffer
-nnoremap <Leader><Insert>
- \ :<C-U>enew<CR>
+" And last, but definitely not least, I'm required by Vim fanatic law to
+" include a mapping that reloads my whole configuration. Doing this triggers
+" the #vimrc#SourceCmd hooks defined much earlier in the file so that
+" filetypes get reloaded afterwards, so I don't need to follow <Leader>R with
+" a <Leader>F.
-" Leader,TAB toggles 'autoindent'
-nnoremap <Leader><Tab>
- \ :<C-U>setlocal autoindent! autoindent?<CR>
-
-" Some useful abbreviations
-inoreabbrev tr@ tom@sanctum.geek.nz
-inoreabbrev tr/ <https://sanctum.geek.nz/>
+"" Leader,R reloads ~/.vimrc
+nnoremap <Leader>R
+ \ :<C-U>source $MYVIMRC<CR>
-" THe things I almsot always type wrnog
-inoreabbrev almsot almost
-inoreabbrev wrnog wrong
-inoreabbrev Fielding Feilding
-inoreabbrev THe The
-inoreabbrev THere There
+" I'll close this file with a few abbreviations. Perhaps of everything in
+" here, I'm least confident that these should be in here, but they've proven
+" pretty useful. First, some 'deliberate' abbreviations for stuff I type
+" a lot:
+"
+inoreabbrev tr@
+ \ tom@sanctum.geek.nz
+inoreabbrev tr/
+ \ <https://sanctum.geek.nz/>
+
+" And then, just fix some typographical and spelling errors for me
+" automatically.
+"
+inoreabbrev almsot
+ \ almost
+inoreabbrev wrnog
+ \ wrong
+inoreabbrev Fielding
+ \ Feilding
+inoreabbrev THe
+ \ The
+inoreabbrev THere
+ \ There
+
+" Here endeth the literate vimrc.
+"
+" > Consequently, it is soon recognised that they write for the sake of
+" > filling up the paper, and this is the case sometimes with the best
+" > authors; for example, in parts of Lessing’s Dramaturgie, and even in many
+" > of Jean Paul’s romances. As soon as this is perceived the book should be
+" > thrown away, for time is precious.
+" > -- Schopenhauer
+"