aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--.gitmodules6
-rw-r--r--IDEAS.md9
-rw-r--r--Makefile24
-rw-r--r--README.md9
-rw-r--r--TABS.md4
-rw-r--r--VERSION4
-rw-r--r--bin/td.sh18
-rw-r--r--bin/vic.sh6
-rw-r--r--ex/exrc2
-rw-r--r--gnupg/gpg.conf8
-rw-r--r--gnupg/gpg.conf.mi548
-rw-r--r--i3/config20
-rw-r--r--man/man1/grec.1df2
-rw-r--r--man/man1/gred.1df2
-rw-r--r--man/man1/td.1df7
-rw-r--r--man/man1/vic.1df11
-rw-r--r--man/man7/dotfiles.7df10
-rw-r--r--perlcritic/perlcriticrc3
-rw-r--r--terminfo/putty-256color.ti7
-rw-r--r--terminfo/putty.ti8
-rw-r--r--terminfo/rxvt-256color.ti8
-rw-r--r--terminfo/rxvt-unicode-256color.ti4
-rw-r--r--terminfo/rxvt-unicode.ti160
-rw-r--r--terminfo/rxvt.ti175
-rw-r--r--terminfo/screen-256color.ti7
-rw-r--r--terminfo/screen.ti8
-rw-r--r--terminfo/tmux-256color.ti6
-rw-r--r--terminfo/tmux.ti104
-rw-r--r--tmux/tmux.conf2
-rw-r--r--vim/after/ftplugin/c.vim16
-rw-r--r--vim/after/ftplugin/html.vim11
-rw-r--r--vim/after/ftplugin/mail.vim49
-rw-r--r--vim/after/ftplugin/perl.vim5
-rw-r--r--vim/after/ftplugin/php.vim16
-rw-r--r--vim/after/ftplugin/sh.vim5
-rw-r--r--vim/after/ftplugin/vim.vim5
-rw-r--r--vim/after/ftplugin/zsh.vim5
-rw-r--r--vim/after/indent/c.vim19
-rw-r--r--vim/after/indent/gitconfig.vim15
-rw-r--r--vim/after/indent/make.vim18
-rw-r--r--vim/autoload/alternate_filetypes.vim13
-rw-r--r--vim/autoload/colorscheme.vim8
-rw-r--r--vim/autoload/escape.vim13
-rw-r--r--vim/autoload/fortune.vim46
-rw-r--r--vim/autoload/has.vim16
-rw-r--r--vim/autoload/html.vim6
-rw-r--r--vim/autoload/mail.vim23
-rw-r--r--vim/autoload/map.vim12
-rw-r--r--vim/autoload/markdown.vim9
-rw-r--r--vim/autoload/paste_insert.vim12
-rw-r--r--vim/autoload/path.vim12
-rw-r--r--vim/autoload/plugin.vim4
-rw-r--r--vim/autoload/put_date.vim19
-rw-r--r--vim/autoload/reload.vim12
-rw-r--r--vim/autoload/scratch_buffer.vim11
-rw-r--r--vim/autoload/spellfile_local.vim79
-rw-r--r--vim/autoload/split.vim12
-rw-r--r--vim/autoload/unescape.vim3
-rw-r--r--vim/autoload/utc.vim4
m---------vim/bundle/cursorline_current0
m---------vim/bundle/digraph_search0
m---------vim/bundle/paste_insert0
m---------vim/bundle/quickfix_auto_open0
m---------vim/bundle/select_old_files0
m---------vim/bundle/write_mkpath0
-rw-r--r--vim/filetype.vim20
-rw-r--r--vim/ftplugin/awk.vim5
-rw-r--r--vim/ftplugin/markdown.vim4
-rw-r--r--vim/ftplugin/sed.vim5
-rw-r--r--vim/ftplugin/textarea.vim12
-rw-r--r--vim/indent/csv.vim15
-rw-r--r--vim/indent/help.vim20
-rw-r--r--vim/plugin/alternate_filetypes.vim4
-rw-r--r--vim/plugin/fortune.vim4
-rw-r--r--vim/plugin/paste_insert.vim8
-rw-r--r--vim/plugin/put_date.vim6
-rw-r--r--vim/plugin/scratch_buffer.vim2
-rw-r--r--vim/plugin/spellfile_local.vim13
-rw-r--r--vim/plugin/utc.vim6
-rw-r--r--vim/vimrc1227
-rw-r--r--vim/vimrc.stub25
-rw-r--r--vim/vimrc.stub.vim11
83 files changed, 1481 insertions, 1069 deletions
diff --git a/.gitignore b/.gitignore
index 67cae516..9e71ad86 100644
--- a/.gitignore
+++ b/.gitignore
@@ -145,6 +145,7 @@
/bin/uts
/bin/vest
/bin/vex
+/bin/vic
/bin/wro
/bin/xgo
/bin/xgoc
@@ -173,7 +174,5 @@
/git/template/hooks/pre-commit
/git/template/hooks/prepare-commit-msg
/git/template/hooks/post-update
-/gnupg/gpg.conf
-/gnupg/gpg.conf.m4
/include/mktd.m4
/urxvt/ext/select
diff --git a/.gitmodules b/.gitmodules
index 5f049838..f91504da 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -32,6 +32,9 @@
[submodule "vim/bundle/keep_position"]
path = vim/bundle/keep_position
url = https://sanctum.geek.nz/code/vim-keep-position.git
+[submodule "vim/bundle/paste_insert"]
+ path = vim/bundle/paste_insert
+ url = https://sanctum.geek.nz/code/vim-paste-insert.git
[submodule "vim/bundle/put_blank_lines"]
path = vim/bundle/put_blank_lines
url = https://sanctum.geek.nz/code/vim-put-blank-lines.git
@@ -47,6 +50,9 @@
[submodule "vim/bundle/replace_operator"]
path = vim/bundle/replace_operator
url = https://sanctum.geek.nz/code/vim-replace-operator.git
+[submodule "vim/bundle/select_old_files"]
+ path = vim/bundle/select_old_files
+ url = https://sanctum.geek.nz/code/vim-select-old-files.git
[submodule "vim/bundle/shebang_change_filetype"]
path = vim/bundle/shebang_change_filetype
url = https://sanctum.geek.nz/code/vim-shebang-change-filetype.git
diff --git a/IDEAS.md b/IDEAS.md
index 49f49548..2d485ffb 100644
--- a/IDEAS.md
+++ b/IDEAS.md
@@ -24,8 +24,6 @@ Ideas
* Ideally, the AWK and/or sed scripts in the bin and games directories should
be syntax-checked or linted. I could at least add some patient application
of appropriate `gawk --lint` calls for each of the .awk scripts.
-* Alternate buffer type switching would probably work rather well as a simple
- plugin.
* Write a ftplugin for Perl to switch between punctuation variable names and
English variable names., i.e. \e on `$?` would change to `$CHILD_ERROR`, and
vice-versa.
@@ -33,5 +31,8 @@ Ideas
some point
* I'd like a Git hook that pre-fills out "Version X.Y.Z" if making an annotated
tag named `vX.Y.Z`.
-* Per-filetype spelling dictionaries might be a good idea, e.g. writing all the
- valid :commands and 'options' for Vim script into a file for ft=vim.
+* There's no reason to limit `digraph_search.vim` to insert mode only
+* alternate\_filetype.vim can be spun out into its own repository
+* fortune.vim can be spun out into its own repository
+* put\_date.vim can be spun out into its own repository
+* scratch\_buffer.vim can be spun out into its own repository
diff --git a/Makefile b/Makefile
index f6a2ae02..e6fd8d70 100644
--- a/Makefile
+++ b/Makefile
@@ -220,6 +220,7 @@ BINS = bin/ap \
bin/uts \
bin/vest \
bin/vex \
+ bin/vic \
bin/wro \
bin/xgo \
bin/xgoc \
@@ -268,7 +269,7 @@ GIT_TEMPLATE_HOOKS = git/template/hooks/post-update \
git/template/hooks/pre-commit \
git/template/hooks/prepare-commit-msg
-all: $(BINS) git/gitconfig $(GIT_TEMPLATE_HOOKS) gnupg/gpg.conf
+all: $(BINS) git/gitconfig $(GIT_TEMPLATE_HOOKS)
clean distclean:
rm -f -- \
@@ -281,8 +282,6 @@ clean distclean:
dillo/dillorc.m4 \
git/gitconfig \
git/gitconfig.m4 \
- gnupg/gpg.conf \
- gnupg/gpg.conf.m4 \
include/mktd.m4 \
urxvt/ext/select \
vim/dist/*
@@ -337,15 +336,6 @@ git/gitconfig: git/gitconfig.m4
-D SENDMAIL=$(SENDMAIL) \
git/gitconfig.m4 > $@
-KEYSERVER = hkps://hkps.pool.sks-keyservers.net
-KEYID_FORMAT = none
-
-gnupg/gpg.conf: gnupg/gpg.conf.m4
- m4 \
- -D KEYSERVER=$(KEYSERVER) \
- -D KEYID_FORMAT=$(KEYID_FORMAT) \
- gnupg/gpg.conf.m4 > $@
-
MAILDIR = $(HOME)/Mail
install: install-bin \
@@ -432,7 +422,7 @@ install-git: git/gitconfig $(GIT_TEMPLATE_HOOKS)
$(HOME)/.git-template"$${1#git/template}"' \
_ {} \;
-install-gnupg: gnupg/gpg.conf
+install-gnupg:
mkdir -m 0700 -p -- $(HOME)/.gnupg
cp -p -- gnupg/*.conf $(HOME)/.gnupg
@@ -563,7 +553,7 @@ install-vim-after-indent:
mkdir -p $(VIMDIR)/after/indent
cp -p -- vim/after/indent/*.vim $(VIMDIR)/after/indent
-install-vim-after-plugin:
+install-vim-after-plugin: install-vim-autoload
mkdir -p $(VIMDIR)/after/plugin
cp -p -- vim/after/plugin/*.vim $(VIMDIR)/after/plugin
@@ -597,13 +587,13 @@ install-vim-compiler:
cp -p -- vim/compiler/*.vim $(VIMDIR)/compiler
install-vim-config: install-vim-cache
- cp -p -- vim/vimrc.stub.vim $(HOME)/.vimrc
+ cp -p -- vim/vimrc.stub $(HOME)/.vimrc
cp -p -- vim/vimrc $(VIMRC)
install-vim-filetype:
cp -p -- vim/filetype.vim vim/scripts.vim $(VIMDIR)
-install-vim-ftplugin:
+install-vim-ftplugin: install-vim-autoload
mkdir -p -- $(VIMDIR)/ftplugin
cp -p -- vim/ftplugin/*.vim $(VIMDIR)/ftplugin
@@ -619,7 +609,7 @@ install-vim-indent:
mkdir -p -- $(VIMDIR)/indent
cp -p -- vim/indent/*.vim $(VIMDIR)/indent
-install-vim-plugin:
+install-vim-plugin: install-vim-autoload
mkdir -p -- $(VIMDIR)/plugin
cp -p -- vim/plugin/*.vim $(VIMDIR)/plugin
diff --git a/README.md b/README.md
index 9f124ea4..bb095c3c 100644
--- a/README.md
+++ b/README.md
@@ -349,7 +349,7 @@ keybindings. It's extensively commented.
I define my own `filetype.vim` and `scripts.vim`, so that filetype detection
works in a way I like, and loads quickly. They are unlikely to suit you as
-they are, but if you want to use it, you can extend them with your favourite
+they are, but if you want to use it, you can extend them with your favorite
filetypes in custom `ftdetect` rules.
#### Plugins
@@ -485,7 +485,7 @@ Installed by the `install-bin` target:
* `apf(1df)` inserts arguments to a command with ones read from a file,
intended as a framework for shell wrappers or functions.
* `ax(1df)` evaluates an AWK expression given on the command line; this is
- intended as a quick way to test how Awk would interpret a given expression.
+ intended as a quick way to test how AWK would interpret a given expression.
* `bcq(1df)` runs `bc(1)`, quieting it down if need be.
* `bel(1df)` prints a terminal bell character.
* `bl(1df)` generates a given number of blank lines.
@@ -536,7 +536,7 @@ Installed by the `install-bin` target:
* `mex(1df)` makes given filenames in `$PATH` executable.
* `mi5(1df)` is a crude preprocessor for `m4`.
* `mim(1df)` starts an interactive Mutt message with its input.
-* `mftl(1df)` finds usable-looking targets in makefiles.
+* `mftl(1df)` finds usable-looking targets in Makefiles.
* `mkcp(1df)` creates a directory and copies preceding arguments into it.
* `mkmv(1df)` creates a directory and moves preceding arguments into it.
* `motd(1df)` shows the system MOTD.
@@ -545,7 +545,7 @@ Installed by the `install-bin` target:
* `oii(1df)` runs a command on input only if there is any.
* `onl(1df)` crunches input down to one printable line.
* `osc(1df)` implements a `netcat(1)`-like wrapper for `openssl(1)`'s
- `s_client` subcommand.
+ `s_client` sub-command.
* `p(1df)` prints concatenated standard input; `cat(1)` as it should always
have been.
* `pa(1df)` prints its arguments, one per line.
@@ -584,6 +584,7 @@ Installed by the `install-bin` target:
* `vest(1df)` runs `test(1)` but fails with explicit output via `vex(1df)`.
* `vex(1df)` runs a command and prints `true` or `false` explicitly to `stdout`
based on the exit value.
+* `vic(1df)` tries to run a POSIX-compliant `vi(1)`.
* `xrbg(1df)` applies the same randomly-selected background to each X screen.
* `xrq(1df)` gets the values of specific resources out of `xrdb -query` output.
diff --git a/TABS.md b/TABS.md
index cecbf2ed..105d89d4 100644
--- a/TABS.md
+++ b/TABS.md
@@ -17,8 +17,8 @@ pretty nicely:
If you have GNU `unexpand(1)` and can add `--first-only` to each of those
calls, the results seem perfect.
-You can configure Vim to accommodate this by removing the settings in vim/vimrc
-for:
+You can configure Vim to accommodate this by removing the settings in
+vim/vimrc.vim for:
* `'expandtab'`
* `'shiftwidth'`
diff --git a/VERSION b/VERSION
index 587f6a86..4e6ae8cd 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-tejr dotfiles v6.11.0
-Sat, 15 Jun 2019 15:22:27 +0000
+tejr dotfiles v7.0.0
+Thu, 18 Jul 2019 02:27:14 +0000
diff --git a/bin/td.sh b/bin/td.sh
index ef0be618..a5a4ab30 100644
--- a/bin/td.sh
+++ b/bin/td.sh
@@ -2,7 +2,6 @@
# Specify the path and file
dir=${TODO_DIR:-"$HOME"/Todo}
-file=${1:-"${TODO_NAME:-todo}"}
# If the directory doesn't exist, create it
[ -d "$dir" ] || mkdir -p -- "$dir" || exit
@@ -17,15 +16,16 @@ if ! command -v isgr >/dev/null 2>&1 ; then
fi
isgr || git init --quiet || exit
-# If the to-do file doesn't exist yet, create it
-[ -e "$file" ] || touch -- "$file" || exit
+if [ "$#" -eq 0 ] ; then
+ set -- "${TODO_NAME:-todo}"
+fi
-# Launch an appropriate editor to edit that file
-"${VISUAL:-"${EDITOR:-ed}"}" "$file"
+# Launch an appropriate editor to edit those files
+"${VISUAL:-"${EDITOR:-ed}"}" "$@"
-# Add the file to the changeset
-git add -- "$file"
+# Add those files to the changeset
+git add -- "$@"
-# If there are changes to commit, commit them
-git diff-index --quiet HEAD 2>/dev/null ||
+# If there are changes to those files to commit, commit them
+git diff-index --quiet HEAD "$@" 2>/dev/null ||
git commit --message 'Changed by td(1df)' --quiet
diff --git a/bin/vic.sh b/bin/vic.sh
new file mode 100644
index 00000000..c1967ef1
--- /dev/null
+++ b/bin/vic.sh
@@ -0,0 +1,6 @@
+# If the system vi is Vim, start it with -C for 'compatible'
+ver=$(vim --version 2>/dev/null | awk '{print $1;exit}')
+case $ver in
+ (VIM) vim -C "$@" ;;
+ (*) vi "$@" ;;
+esac
diff --git a/ex/exrc b/ex/exrc
index 355b48ee..c1214c2f 100644
--- a/ex/exrc
+++ b/ex/exrc
@@ -1,5 +1,5 @@
" POSIX ex/vi settings
set autoindent
set report=0
-set shiftwidth=4
+set showmatch
set showmode
diff --git a/gnupg/gpg.conf b/gnupg/gpg.conf
new file mode 100644
index 00000000..7ef1c07d
--- /dev/null
+++ b/gnupg/gpg.conf
@@ -0,0 +1,8 @@
+# Assume I mean to encrypt to myself if no recipient is specified
+default-recipient-self
+
+# Suppress the copyright message
+no-greeting
+
+# Use the GPG agent for key management and decryption
+use-agent
diff --git a/gnupg/gpg.conf.mi5 b/gnupg/gpg.conf.mi5
deleted file mode 100644
index 97726d20..00000000
--- a/gnupg/gpg.conf.mi5
+++ /dev/null
@@ -1,48 +0,0 @@
-# Retrieve certs automatically if possible
-auto-key-locate cert pka
-
-# Use SHA512 as the hash when making key signatures
-cert-digest-algo SHA512
-
-# Specify the hash algorithms to be used for new keys as available
-default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed
-
-# In the absence of any other recipient, encrypt messages for myself
-default-recipient-self
-
-# Show complete dates and use proper column separation for --with-colon listing
-# mode
-fixed-list-mode
-
-# Use only fingerprints as key IDs
-keyid-format <% KEYID_FORMAT %>
-
-# Use a pool of servers which support HKPS (encrypted key retrieval)
-keyserver <% KEYSERVER %>
-
-# Retrieve keys automatically; check the keyserver port cert; use whichever
-# server is proffered from the pool
-keyserver-options auto-key-retrieve no-honor-keyserver-url
-
-# Include trust/validity for UIDs in listings
-list-options show-uid-validity
-
-# Suppress the copyright message
-no-greeting
-
-# Use SHA512 as my message digest, overriding GnuPG's efforts to use the lowest
-# common denominator in hashing algorithms
-personal-digest-preferences SHA512
-
-# Suppress a lot of output; sometimes I add --verbose to undo this
-quiet
-
-# Use the GPG agent for key management and decryption
-use-agent
-
-# Include trust/validity for UIDs when verifying signatures
-verify-options pka-lookups show-uid-validity
-
-# Assume "yes" is the answer to most questions, that is, don't keep asking me
-# to confirm something I've asked to be done
-yes
diff --git a/i3/config b/i3/config
index 2b190998..be00e590 100644
--- a/i3/config
+++ b/i3/config
@@ -50,22 +50,22 @@ bindsym $mod+a focus parent
bindsym $mod+z focus child
# Mod+<n> switches to a workspace
-bindsym $mod+1 workspace 1
-bindsym $mod+2 workspace 2
-bindsym $mod+3 workspace 3
-bindsym $mod+4 workspace 4
-bindsym $mod+5 workspace 5
+bindsym $mod+1 workspace 1:main
+bindsym $mod+2 workspace 2:home
+bindsym $mod+3 workspace 3:work
+bindsym $mod+4 workspace 4:soc
+bindsym $mod+5 workspace 5:tor
bindsym $mod+6 workspace 6
bindsym $mod+7 workspace 7
bindsym $mod+8 workspace 8
bindsym $mod+9 workspace 9
# Mod+Shift+<n> moves a container to a workspace
-bindsym $mod+Shift+1 move container to workspace 1
-bindsym $mod+Shift+2 move container to workspace 2
-bindsym $mod+Shift+3 move container to workspace 3
-bindsym $mod+Shift+4 move container to workspace 4
-bindsym $mod+Shift+5 move container to workspace 5
+bindsym $mod+Shift+1 move container to workspace 1:main
+bindsym $mod+Shift+2 move container to workspace 2:home
+bindsym $mod+Shift+3 move container to workspace 3:work
+bindsym $mod+Shift+4 move container to workspace 4:soc
+bindsym $mod+Shift+5 move container to workspace 5:tor
bindsym $mod+Shift+6 move container to workspace 6
bindsym $mod+Shift+7 move container to workspace 7
bindsym $mod+Shift+8 move container to workspace 8
diff --git a/man/man1/grec.1df b/man/man1/grec.1df
index b1f70193..9916c6d5 100644
--- a/man/man1/grec.1df
+++ b/man/man1/grec.1df
@@ -8,7 +8,7 @@ PATTERN [FILE...]
.br
.SH DESCRIPTION
.B grec
-is the same as grep(1) when run with a a -c option, because the name always
+is the same as grep(1) when run with its -c option, because the name always
bugged me a bit--"g/re/p, except don't print it, count it"?
.SH AUTHOR
Tom Ryder <tom@sanctum.geek.nz>
diff --git a/man/man1/gred.1df b/man/man1/gred.1df
index e3dbce87..74eb8561 100644
--- a/man/man1/gred.1df
+++ b/man/man1/gred.1df
@@ -8,7 +8,7 @@ PATTERN [FILE...]
.br
.SH DESCRIPTION
.B gred
-is the same as grep(1) when run with a a -v option, because the name always
+is the same as grep(1) when run with its -v option, because the name always
bugged me a bit--"g/re/p, except don't print it, delete it"?
.SH AUTHOR
Tom Ryder <tom@sanctum.geek.nz>
diff --git a/man/man1/td.1df b/man/man1/td.1df
index df1ff82f..86d463cb 100644
--- a/man/man1/td.1df
+++ b/man/man1/td.1df
@@ -1,12 +1,13 @@
-.TH TD 1df "June 2016" "Manual page for td"
+.TH TD 1df "July 2019" "Manual page for td"
.SH NAME
.B td
\- manage to-do files
.SH SYNOPSIS
-.B td [FILENAME]
+.B td [FILENAME...]
.SH DESCRIPTION
Edit to-do files in ~/Todo, defaulting to a file just named "todo",
-automatically maintaining a changelog via git(1).
+automatically maintaining a changelog via git(1). Multiple filenames are
+accepted.
.SH SEE ALSO
git(1)
.SH AUTHOR
diff --git a/man/man1/vic.1df b/man/man1/vic.1df
new file mode 100644
index 00000000..e7aae6e2
--- /dev/null
+++ b/man/man1/vic.1df
@@ -0,0 +1,11 @@
+.TH VIC 1df "June 2019" "Manual page for vic"
+.SH NAME
+.B vic
+\- run a compatible vi
+.SH DESCRIPTION
+.B vic
+checks the system implementation of vi(1) to see whether it's Vim. If it is,
+it starts it with `vim -C` to turn the 'compatible' option on. If it isn't, it
+just runs `vi`.
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>
diff --git a/man/man7/dotfiles.7df b/man/man7/dotfiles.7df
index a4800f6b..5eb551e7 100644
--- a/man/man7/dotfiles.7df
+++ b/man/man7/dotfiles.7df
@@ -496,7 +496,7 @@ It's extensively commented.
I define my own \f[C]filetype.vim\f[] and \f[C]scripts.vim\f[], so that
filetype detection works in a way I like, and loads quickly.
They are unlikely to suit you as they are, but if you want to use it,
-you can extend them with your favourite filetypes in custom
+you can extend them with your favorite filetypes in custom
\f[C]ftdetect\f[] rules.
.SS Plugins
.PP
@@ -736,7 +736,7 @@ input, prompting if appropriate.
file, intended as a framework for shell wrappers or functions.
.IP \[bu] 2
\f[C]ax(1df)\f[] evaluates an AWK expression given on the command line;
-this is intended as a quick way to test how Awk would interpret a given
+this is intended as a quick way to test how AWK would interpret a given
expression.
.IP \[bu] 2
\f[C]bcq(1df)\f[] runs \f[C]bc(1)\f[], quieting it down if need be.
@@ -834,7 +834,7 @@ Good for quick tests.
.IP \[bu] 2
\f[C]mim(1df)\f[] starts an interactive Mutt message with its input.
.IP \[bu] 2
-\f[C]mftl(1df)\f[] finds usable\-looking targets in makefiles.
+\f[C]mftl(1df)\f[] finds usable\-looking targets in Makefiles.
.IP \[bu] 2
\f[C]mkcp(1df)\f[] creates a directory and copies preceding arguments
into it.
@@ -852,7 +852,7 @@ one per line.
\f[C]onl(1df)\f[] crunches input down to one printable line.
.IP \[bu] 2
\f[C]osc(1df)\f[] implements a \f[C]netcat(1)\f[]\-like wrapper for
-\f[C]openssl(1)\f[]'s \f[C]s_client\f[] subcommand.
+\f[C]openssl(1)\f[]'s \f[C]s_client\f[] sub\-command.
.IP \[bu] 2
\f[C]p(1df)\f[] prints concatenated standard input; \f[C]cat(1)\f[] as
it should always have been.
@@ -927,6 +927,8 @@ via \f[C]vex(1df)\f[].
\f[C]vex(1df)\f[] runs a command and prints \f[C]true\f[] or
\f[C]false\f[] explicitly to \f[C]stdout\f[] based on the exit value.
.IP \[bu] 2
+\f[C]vic(1df)\f[] tries to run a POSIX\-compliant \f[C]vi(1)\f[].
+.IP \[bu] 2
\f[C]xrbg(1df)\f[] applies the same randomly\-selected background to
each X screen.
.IP \[bu] 2
diff --git a/perlcritic/perlcriticrc b/perlcritic/perlcriticrc
index a3517cc8..0bd59c98 100644
--- a/perlcritic/perlcriticrc
+++ b/perlcritic/perlcriticrc
@@ -25,3 +25,6 @@ add_exceptions = inet4 inet6 ipv4 ipv6
# milliseconds etc), 60 (for angles and clocks), and 1900 (for localtime)
[ValuesAndExpressions::ProhibitMagicNumbers]
allowed_values = -1 0..9 10 60 100 1000 1900
+
+# There's nothing wrong with $x == 2, and 2 == $x is just weird
+[-ValuesAndExpressions::RequireConstantOnLeftSideOfEquality]
diff --git a/terminfo/putty-256color.ti b/terminfo/putty-256color.ti
new file mode 100644
index 00000000..81d2b3f1
--- /dev/null
+++ b/terminfo/putty-256color.ti
@@ -0,0 +1,7 @@
+putty-256color| PuTTY with 256 colors,
+ use=putty,
+ colors#256,
+ initc@,
+ pairs#32767,
+ setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m,
+ setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,
diff --git a/terminfo/putty.ti b/terminfo/putty.ti
index 3f2ab27f..6c3bd69e 100644
--- a/terminfo/putty.ti
+++ b/terminfo/putty.ti
@@ -126,11 +126,3 @@ putty| PuTTY,
vpa=\E[%i%p1%dd,
xenl,
xon,
-
-putty-256color| PuTTY with 256 colors,
- use=putty,
- colors#256,
- initc@,
- pairs#32767,
- setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m,
- setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,
diff --git a/terminfo/rxvt-256color.ti b/terminfo/rxvt-256color.ti
new file mode 100644
index 00000000..19057b84
--- /dev/null
+++ b/terminfo/rxvt-256color.ti
@@ -0,0 +1,8 @@
+rxvt-256color| rxvt with 256 colors,
+ use=rxvt,
+ ccc,
+ colors#256,
+ initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\,
+ pairs#32767,
+ setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m,
+ setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,
diff --git a/terminfo/rxvt-unicode-256color.ti b/terminfo/rxvt-unicode-256color.ti
new file mode 100644
index 00000000..62e6c021
--- /dev/null
+++ b/terminfo/rxvt-unicode-256color.ti
@@ -0,0 +1,4 @@
+rxvt-unicode-256color| rxvt-unicode with 256 colors,
+ use=rxvt-unicode,
+ colors#256,
+ pairs#32767,
diff --git a/terminfo/rxvt-unicode.ti b/terminfo/rxvt-unicode.ti
new file mode 100644
index 00000000..3c4e0479
--- /dev/null
+++ b/terminfo/rxvt-unicode.ti
@@ -0,0 +1,160 @@
+rxvt-unicode| rxvt-unicode,
+ acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
+ am,
+ bce,
+ bel=^G,
+ blink=\E[5m,
+ bold=\E[1m,
+ btns#5,
+ bw,
+ ccc,
+ civis=\E[?25l,
+ clear=\E[H\E[2J,
+ cnorm=\E[?25h,
+ colors#88,
+ cols#80,
+ cr=^M,
+ csr=\E[%i%p1%d;%p2%dr,
+ cub1=^H,
+ cub=\E[%p1%dD,
+ cud1=^J,
+ cud=\E[%p1%dB,
+ cuf1=\E[C,
+ cuf=\E[%p1%dC,
+ cup=\E[%i%p1%d;%p2%dH,
+ cuu1=\E[A,
+ cuu=\E[%p1%dA,
+ cvvis=\E[?25h,
+ dch1=\E[P,
+ dch=\E[%p1%dP,
+ dl1=\E[M,
+ dl=\E[%p1%dM,
+ dsl=\E]2;\007,
+ ech=\E[%p1%dX,
+ ed=\E[J,
+ el1=\E[1K,
+ el=\E[K,
+ enacs=,
+ eo,
+ flash=\E[?5h$<20/>\E[?5l,
+ fsl=^G,
+ home=\E[H,
+ hpa=\E[%i%p1%dG,
+ hs,
+ ht=^I,
+ hts=\EH,
+ ich1=\E[@,
+ ich=\E[%p1%d@,
+ il1=\E[L,
+ il=\E[%p1%dL,
+ ind=^J,
+ indn=\E[%p1%dS,
+ initc=\E]4;%p1%d;rgb\:%p2%{65535}%*%{1000}%/%4.4X/%p3%{65535}%*%{1000}%/%4.4X/%p4%{65535}%*%{1000}%/%4.4X\E\\,
+ is1=\E[!p,
+ is2=\E[r\E[m\E[2J\E[?7;25h\E[?1;3;4;5;6;9;66;1000;1001;1049l\E[4l,
+ it#8,
+ kDC=\E[3$,
+ kEND=\E[8$,
+ kHOM=\E[7$,
+ kIC=\E[2$,
+ kLFT=\E[d,
+ kNXT=\E[6$,
+ kPRV=\E[5$,
+ kRIT=\E[c,
+ ka1=\EOw,
+ ka3=\EOy,
+ kb2=\EOu,
+ kbs=\177,
+ kc1=\EOq,
+ kc3=\EOs,
+ kcbt=\E[Z,
+ kcub1=\E[D,
+ kcud1=\E[B,
+ kcuf1=\E[C,
+ kcuu1=\E[A,
+ kdch1=\E[3~,
+ kel=\E[8\^,
+ kend=\E[8~,
+ kent=\EOM,
+ kf10=\E[21~,
+ kf11=\E[23~,
+ kf12=\E[24~,
+ kf13=\E[25~,
+ kf14=\E[26~,
+ kf15=\E[28~,
+ kf16=\E[29~,
+ kf17=\E[31~,
+ kf18=\E[32~,
+ kf19=\E[33~,
+ kf1=\E[11~,
+ kf20=\E[34~,
+ kf2=\E[12~,
+ kf3=\E[13~,
+ kf4=\E[14~,
+ kf5=\E[15~,
+ kf6=\E[17~,
+ kf7=\E[18~,
+ kf8=\E[19~,
+ kf9=\E[20~,
+ kfnd=\E[1~,
+ khome=\E[7~,
+ kich1=\E[2~,
+ km,
+ kmous=\E[M,
+ knp=\E[6~,
+ kpp=\E[5~,
+ kslt=\E[4~,
+ lines#24,
+ lm#0,
+ mc0=\E[i,
+ mc4=\E[4i,
+ mc5=\E[5i,
+ mc5i,
+ mir,
+ msgr,
+ ncv#0,
+ npc,
+ op=\E[39;49m,
+ pairs#7744,
+ rc=\E8,
+ rev=\E[7m,
+ ri=\EM,
+ rin=\E[%p1%dT,
+ ritm=\E[23m,
+ rmacs=\E(B,
+ rmam=\E[?7l,
+ rmcup=\E[r\E[?1049l,
+ rmir=\E[4l,
+ rmkx=\E>,
+ rmso=\E[27m,
+ rmul=\E[24m,
+ rs1=\Ec,
+ rs2=\E[r\E[m\E[?7;25h\E[?1;3;4;5;6;9;66;1000;1001;1049l\E[4l,
+ s0ds=\E(B,
+ s1ds=\E(0,
+ s2ds=\E*B,
+ s3ds=\E+B,
+ sc=\E7,
+ setab=\E[48;5;%p1%dm,
+ setaf=\E[38;5;%p1%dm,
+ setb=%?%p1%{7}%>%t\E[48;5;%p1%dm%e\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m%;,
+ setf=%?%p1%{7}%>%t\E[38;5;%p1%dm%e\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m%;,
+ sgr0=\E[m\E(B,
+ sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\E(0%e\E(B%;,
+ sitm=\E[3m,
+ smacs=\E(0,
+ smam=\E[?7h,
+ smcup=\E[?1049h,
+ smir=\E[4h,
+ smkx=\E=,
+ smso=\E[7m,
+ smul=\E[4m,
+ tbc=\E[3g,
+ tsl=\E]2;,
+ u6=\E[%i%d;%dR,
+ u7=\E[6n,
+ u8=\E[?1;2c,
+ u9=\E[c,
+ vpa=\E[%i%p1%dd,
+ xenl,
+ xon,
diff --git a/terminfo/rxvt.ti b/terminfo/rxvt.ti
index 735c7ef7..41cafa39 100644
--- a/terminfo/rxvt.ti
+++ b/terminfo/rxvt.ti
@@ -149,178 +149,3 @@ rxvt| rxvt,
vpa=\E[%i%p1%dd,
xenl,
xon,
-
-rxvt-256color| rxvt with 256 colors,
- use=rxvt,
- ccc,
- colors#256,
- initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\,
- pairs#32767,
- setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m,
- setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,
-
-rxvt-unicode| rxvt-unicode,
- acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
- am,
- bce,
- bel=^G,
- blink=\E[5m,
- bold=\E[1m,
- btns#5,
- bw,
- ccc,
- civis=\E[?25l,
- clear=\E[H\E[2J,
- cnorm=\E[?25h,
- colors#88,
- cols#80,
- cr=^M,
- csr=\E[%i%p1%d;%p2%dr,
- cub1=^H,
- cub=\E[%p1%dD,
- cud1=^J,
- cud=\E[%p1%dB,
- cuf1=\E[C,
- cuf=\E[%p1%dC,
- cup=\E[%i%p1%d;%p2%dH,
- cuu1=\E[A,
- cuu=\E[%p1%dA,
- cvvis=\E[?25h,
- dch1=\E[P,
- dch=\E[%p1%dP,
- dl1=\E[M,
- dl=\E[%p1%dM,
- dsl=\E]2;\007,
- ech=\E[%p1%dX,
- ed=\E[J,
- el1=\E[1K,
- el=\E[K,
- enacs=,
- eo,
- flash=\E[?5h$<20/>\E[?5l,
- fsl=^G,
- home=\E[H,
- hpa=\E[%i%p1%dG,
- hs,
- ht=^I,
- hts=\EH,
- ich1=\E[@,
- ich=\E[%p1%d@,
- il1=\E[L,
- il=\E[%p1%dL,
- ind=^J,
- indn=\E[%p1%dS,
- initc=\E]4;%p1%d;rgb\:%p2%{65535}%*%{1000}%/%4.4X/%p3%{65535}%*%{1000}%/%4.4X/%p4%{65535}%*%{1000}%/%4.4X\E\\,
- is1=\E[!p,
- is2=\E[r\E[m\E[2J\E[?7;25h\E[?1;3;4;5;6;9;66;1000;1001;1049l\E[4l,
- it#8,
- kDC=\E[3$,
- kEND=\E[8$,
- kHOM=\E[7$,
- kIC=\E[2$,
- kLFT=\E[d,
- kNXT=\E[6$,
- kPRV=\E[5$,
- kRIT=\E[c,
- ka1=\EOw,
- ka3=\EOy,
- kb2=\EOu,
- kbs=\177,
- kc1=\EOq,
- kc3=\EOs,
- kcbt=\E[Z,
- kcub1=\E[D,
- kcud1=\E[B,
- kcuf1=\E[C,
- kcuu1=\E[A,
- kdch1=\E[3~,
- kel=\E[8\^,
- kend=\E[8~,
- kent=\EOM,
- kf10=\E[21~,
- kf11=\E[23~,
- kf12=\E[24~,
- kf13=\E[25~,
- kf14=\E[26~,
- kf15=\E[28~,
- kf16=\E[29~,
- kf17=\E[31~,
- kf18=\E[32~,
- kf19=\E[33~,
- kf1=\E[11~,
- kf20=\E[34~,
- kf2=\E[12~,
- kf3=\E[13~,
- kf4=\E[14~,
- kf5=\E[15~,
- kf6=\E[17~,
- kf7=\E[18~,
- kf8=\E[19~,
- kf9=\E[20~,
- kfnd=\E[1~,
- khome=\E[7~,
- kich1=\E[2~,
- km,
- kmous=\E[M,
- knp=\E[6~,
- kpp=\E[5~,
- kslt=\E[4~,
- lines#24,
- lm#0,
- mc0=\E[i,
- mc4=\E[4i,
- mc5=\E[5i,
- mc5i,
- mir,
- msgr,
- ncv#0,
- npc,
- op=\E[39;49m,
- pairs#7744,
- rc=\E8,
- rev=\E[7m,
- ri=\EM,
- rin=\E[%p1%dT,
- ritm=\E[23m,
- rmacs=\E(B,
- rmam=\E[?7l,
- rmcup=\E[r\E[?1049l,
- rmir=\E[4l,
- rmkx=\E>,
- rmso=\E[27m,
- rmul=\E[24m,
- rs1=\Ec,
- rs2=\E[r\E[m\E[?7;25h\E[?1;3;4;5;6;9;66;1000;1001;1049l\E[4l,
- s0ds=\E(B,
- s1ds=\E(0,
- s2ds=\E*B,
- s3ds=\E+B,
- sc=\E7,
- setab=\E[48;5;%p1%dm,
- setaf=\E[38;5;%p1%dm,
- setb=%?%p1%{7}%>%t\E[48;5;%p1%dm%e\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m%;,
- setf=%?%p1%{7}%>%t\E[38;5;%p1%dm%e\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m%;,
- sgr0=\E[m\E(B,
- sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\E(0%e\E(B%;,
- sitm=\E[3m,
- smacs=\E(0,
- smam=\E[?7h,
- smcup=\E[?1049h,
- smir=\E[4h,
- smkx=\E=,
- smso=\E[7m,
- smul=\E[4m,
- tbc=\E[3g,
- tsl=\E]2;,
- u6=\E[%i%d;%dR,
- u7=\E[6n,
- u8=\E[?1;2c,
- u9=\E[c,
- vpa=\E[%i%p1%dd,
- xenl,
- xon,
-
-rxvt-unicode-256color| rxvt-unicode with 256 colors,
- use=rxvt-unicode,
- colors#256,
- pairs#32767,
diff --git a/terminfo/screen-256color.ti b/terminfo/screen-256color.ti
new file mode 100644
index 00000000..1cfabaf9
--- /dev/null
+++ b/terminfo/screen-256color.ti
@@ -0,0 +1,7 @@
+screen-256color| GNU Screen or tmux with 256 colors,
+ use=screen,
+ colors#256,
+ initc@,
+ pairs#32767,
+ setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m,
+ setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,
diff --git a/terminfo/screen.ti b/terminfo/screen.ti
index 574e78e0..3f51e9fd 100644
--- a/terminfo/screen.ti
+++ b/terminfo/screen.ti
@@ -98,11 +98,3 @@ screen| GNU Screen or tmux,
smul=\E[4m,
tbc=\E[3g,
xenl,
-
-screen-256color| GNU Screen or tmux with 256 colors,
- use=screen,
- colors#256,
- initc@,
- pairs#32767,
- setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m,
- setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,
diff --git a/terminfo/tmux-256color.ti b/terminfo/tmux-256color.ti
new file mode 100644
index 00000000..a242b7c1
--- /dev/null
+++ b/terminfo/tmux-256color.ti
@@ -0,0 +1,6 @@
+tmux-256color| tmux with 256 colors,
+ use=tmux,
+ colors#256,
+ pairs#32767,
+ setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m,
+ setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,
diff --git a/terminfo/tmux.ti b/terminfo/tmux.ti
new file mode 100644
index 00000000..fc86d773
--- /dev/null
+++ b/terminfo/tmux.ti
@@ -0,0 +1,104 @@
+tmux| tmux terminal multiplexer,
+ acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
+ am,
+ bel=^G,
+ blink=\E[5m,
+ bold=\E[1m,
+ cbt=\E[Z,
+ civis=\E[?25l,
+ clear=\E[H\E[J,
+ cnorm=\E[34h\E[?25h,
+ colors#8,
+ cols#80,
+ cr=^M,
+ csr=\E[%i%p1%d;%p2%dr,
+ cub1=^H,
+ cub=\E[%p1%dD,
+ cud1=^J,
+ cud=\E[%p1%dB,
+ cuf1=\E[C,
+ cuf=\E[%p1%dC,
+ cup=\E[%i%p1%d;%p2%dH,
+ cuu1=\EM,
+ cuu=\E[%p1%dA,
+ cvvis=\E[34l,
+ dch1=\E[P,
+ dch=\E[%p1%dP,
+ dim=\E[2m,
+ dl1=\E[M,
+ dl=\E[%p1%dM,
+ dsl=\E]0;\007,
+ ed=\E[J,
+ el1=\E[1K,
+ el=\E[K,
+ enacs=\E(B\E)0,
+ flash=\Eg,
+ fsl=^G,
+ home=\E[H,
+ hs,
+ ht=^I,
+ hts=\EH,
+ ich=\E[%p1%d@,
+ il1=\E[L,
+ il=\E[%p1%dL,
+ ind=^J,
+ is2=\E)0,
+ it#8,
+ kbs=\177,
+ kcbt=\E[Z,
+ kcub1=\EOD,
+ kcud1=\EOB,
+ kcuf1=\EOC,
+ kcuu1=\EOA,
+ kdch1=\E[3~,
+ kend=\E[4~,
+ kf10=\E[21~,
+ kf11=\E[23~,
+ kf12=\E[24~,
+ kf1=\EOP,
+ kf2=\EOQ,
+ kf3=\EOR,
+ kf4=\EOS,
+ kf5=\E[15~,
+ kf6=\E[17~,
+ kf7=\E[18~,
+ kf8=\E[19~,
+ kf9=\E[20~,
+ khome=\E[1~,
+ kich1=\E[2~,
+ km,
+ kmous=\E[M,
+ knp=\E[6~,
+ kpp=\E[5~,
+ lines#24,
+ mir,
+ msgr,
+ nel=\EE,
+ op=\E[39;49m,
+ pairs#64,
+ rc=\E8,
+ rev=\E[7m,
+ ri=\EM,
+ ritm=\E[23m,
+ rmacs=^O,
+ rmcup=\E[?1049l,
+ rmir=\E[4l,
+ rmkx=\E[?1l\E>,
+ rmso=\E[27m,
+ rmul=\E[24m,
+ rs2=\Ec\E[?1000l\E[?25h,
+ sc=\E7,
+ setab=\E[4%p1%dm,
+ setaf=\E[3%p1%dm,
+ sgr0=\E[m\017,
+ sgr=\E[0%?%p6%t;1%;%?%p1%t;3%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;2%;m%?%p9%t\016%e\017%;,
+ sitm=\E[3m,
+ smacs=^N,
+ smcup=\E[?1049h,
+ smir=\E[4h,
+ smkx=\E[?1h\E=,
+ smso=\E[7m,
+ smul=\E[4m,
+ tbc=\E[3g,
+ tsl=\E]0;,
+ xenl,
diff --git a/tmux/tmux.conf b/tmux/tmux.conf
index 2eb1665a..257cee5f 100644
--- a/tmux/tmux.conf
+++ b/tmux/tmux.conf
@@ -14,7 +14,7 @@ set-option -g update-environment 'COLORFGBG COLORTERM'
set-option -g default-command "$SHELL"
# Expect a 256-color terminal
-set-option -g default-terminal 'screen-256color'
+set-option -g default-terminal 'tmux-256color'
# Change the prefix to ^A rather than the default of ^B, because I'm a godless
# GNU Screen refugee, and also I like using ^B in my shell and in Vim more
diff --git a/vim/after/ftplugin/c.vim b/vim/after/ftplugin/c.vim
index b5989410..bc531a61 100644
--- a/vim/after/ftplugin/c.vim
+++ b/vim/after/ftplugin/c.vim
@@ -1,14 +1,18 @@
-" Set 'commentstring' and 'include' back to their default C-friendly values
-setlocal commentstring&vim
-setlocal include&vim
+" Set 'commentstring', 'define', and 'include' back to their default C-friendly values
+setlocal commentstring&vim define&vim include&vim
+let b:undo_ftplugin .= '|setlocal commentstring< define< include<'
" Include macros in completion
setlocal complete+=d
+let b:undo_ftplugin .= '|setlocal complete<'
+
+" Fold based on indent level, and start with all folds closed
+setlocal foldmethod=indent
+setlocal foldlevel=0
+let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<'
" Include system headers on UNIX
if has('unix')
setlocal path+=/usr/include
+ let b:undo_ftplugin .= '|setlocal path<'
endif
-
-" Undo all of the above
-let b:undo_ftplugin .= '|setlocal commentstring< complete< include< path<'
diff --git a/vim/after/ftplugin/html.vim b/vim/after/ftplugin/html.vim
index 93845a80..7866f31b 100644
--- a/vim/after/ftplugin/html.vim
+++ b/vim/after/ftplugin/html.vim
@@ -1,3 +1,9 @@
+" None of this is appropriate for other filetypes that are just sourcing this
+" filetype's scripts in, e.g. Markdown, PHP, so cut that off here
+if &filetype !=# 'html'
+ finish
+endif
+
" Spellcheck documents we're actually editing (not just viewing)
if &modifiable && !&readonly
setlocal spell
@@ -35,8 +41,3 @@ endif
nnoremap <buffer> <LocalLeader>r
\ :<C-U>call html#UrlLink()<CR>
let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>r'
-
-" Switch to PHP filetype for templated PHP
-nnoremap <buffer> <LocalLeader>f
- \ :<C-U>setlocal filetype=php<CR>
-let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>f'
diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim
index f4a4c91d..9f8fc608 100644
--- a/vim/after/ftplugin/mail.vim
+++ b/vim/after/ftplugin/mail.vim
@@ -3,8 +3,7 @@
let b:quote_space = 0
let b:undo_ftplugin .= '|unlet b:quote_space'
-" If something hasn't already moved the cursor, we'll move to an optimal point
-" to start writing
+" Attempt to move to a good spot to start writing
function! s:SuggestStart() abort
" Move to top of buffer
@@ -49,38 +48,13 @@ let b:undo_ftplugin .= '|delcommand SuggestStart'
SuggestStart
" Normalise quoting
-function! s:StrictQuote() abort
- let body = 0
- for lnum in range(1, line('$'))
-
- " Get current line
- let line = getline(lnum)
-
- " Skip lines until we hit a blank line, meaning body text
- let body = body || !strlen(line)
- if !body
- continue
- endif
-
- " Get the leading quote string, if any; skip if there isn't one
- let quote = matchstr(line, '^>[> ]*')
- if !strlen(quote)
- continue
- endif
-
- " Normalise the quote with no spaces
- let quote = substitute(quote, '[^>]', '', 'g')
-
- " Re-set the line
- let line = substitute(line, '^[> ]\+', quote, '')
- call setline(lnum, line)
-
- endfor
-endfunction
-command -bar -buffer StrictQuote
- \ call s:StrictQuote()
+command -buffer -bar -range=% StrictQuote
+ \ call mail#StrictQuote(<q-line1>, <q-line2>)
+nnoremap <LocalLeader>s
+ \ :StrictQuote<CR>
+xnoremap <LocalLeader>s
+ \ :StrictQuote<CR>
let b:undo_ftplugin .= '|delcommand StrictQuote'
-StrictQuote
" Add a space to the end of wrapped lines for format-flowed mail
setlocal formatoptions+=w
@@ -88,17 +62,8 @@ let b:undo_ftplugin .= '|setlocal formatoptions<'
" Mail-specific handling for custom vim-squeeze-repeat-blanks plugin
if exists('loaded_squeeze_repeat_blanks')
-
- " Set the blank line pattern
let b:squeeze_repeat_blanks_blank = '^[ >]*$'
let b:undo_ftplugin .= '|unlet b:squeeze_repeat_blanks_blank'
-
- " If there is anything quoted in this message (i.e. it looks like a reply),
- " squeeze blanks, but don't report lines deleted
- if search('\m^>', 'cnw')
- silent SqueezeRepeatBlanks
- endif
-
endif
" Spellcheck documents we're actually editing (not just viewing)
diff --git a/vim/after/ftplugin/perl.vim b/vim/after/ftplugin/perl.vim
index a303fa75..5c9cf8a0 100644
--- a/vim/after/ftplugin/perl.vim
+++ b/vim/after/ftplugin/perl.vim
@@ -4,6 +4,11 @@ setlocal equalprg=perltidy
let b:undo_ftplugin .= '|unlet b:current_compiler'
\ . '|setlocal equalprg< errorformat< makeprg<'
+" Fold based on indent level, but start with all folds open
+setlocal foldmethod=indent
+setlocal foldlevel=99
+let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<'
+
" Add angle brackets to pairs of matched characters for q<...>
setlocal matchpairs+=<:>
let b:undo_ftplugin .= '|setlocal matchpairs<'
diff --git a/vim/after/ftplugin/php.vim b/vim/after/ftplugin/php.vim
index 58d83c49..c7f77ece 100644
--- a/vim/after/ftplugin/php.vim
+++ b/vim/after/ftplugin/php.vim
@@ -8,6 +8,11 @@ setlocal comments=s1:/*,m:*,ex:*/,://,:#
setlocal formatoptions+=or
let b:undo_ftplugin .= '|setlocal comments< formatoptions<'
+" Fold based on indent level, but start with all folds open
+setlocal foldmethod=indent
+setlocal foldlevel=99
+let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<'
+
" Use pman as 'keywordprg'
setlocal keywordprg=pman
let b:undo_ftplugin .= '|setlocal keywordprg<'
@@ -16,12 +21,7 @@ let b:undo_ftplugin .= '|setlocal keywordprg<'
let b:regex_escape_flavor = 'ere'
let b:undo_ftplugin .= '|unlet b:regex_escape_flavor'
-" Stop here if the user doesn't want ftplugin mappings
-if exists('no_plugin_maps') || exists('no_php_maps')
- finish
+" Set HTML as an alternative filetype
+if !exists('b:alternate_filetypes')
+ let b:alternate_filetypes = [&filetype, 'html']
endif
-
-" Switch to HTML filetype for templated PHP
-nnoremap <buffer> <LocalLeader>f
- \ :<C-U>setlocal filetype=html<CR>
-let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>f'
diff --git a/vim/after/ftplugin/sh.vim b/vim/after/ftplugin/sh.vim
index 8468b133..39b8d0d6 100644
--- a/vim/after/ftplugin/sh.vim
+++ b/vim/after/ftplugin/sh.vim
@@ -3,6 +3,11 @@ setlocal comments=:#
setlocal formatoptions+=or
let b:undo_ftplugin .= '|setlocal comments< formatoptions<'
+" Fold based on indent level, but start with all folds open
+setlocal foldmethod=indent
+setlocal foldlevel=99
+let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<'
+
" If subtype is Bash, set 'keywordprg' to han(1df)
if exists('b:is_bash')
setlocal keywordprg=han
diff --git a/vim/after/ftplugin/vim.vim b/vim/after/ftplugin/vim.vim
index 30182bba..481af0ec 100644
--- a/vim/after/ftplugin/vim.vim
+++ b/vim/after/ftplugin/vim.vim
@@ -9,6 +9,11 @@ endif
let b:regex_escape_flavor = 'vim'
let b:undo_ftplugin .= '|unlet b:regex_escape_flavor'
+" Fold based on indent level, but start with all folds open
+setlocal foldmethod=indent
+setlocal foldlevel=99
+let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<'
+
" Use :help as 'keywordprg' if not already set; this is the default since Vim
" v8.1.1290
if &keywordprg !=# ':help'
diff --git a/vim/after/ftplugin/zsh.vim b/vim/after/ftplugin/zsh.vim
index 5aa2600a..880c2c39 100644
--- a/vim/after/ftplugin/zsh.vim
+++ b/vim/after/ftplugin/zsh.vim
@@ -2,3 +2,8 @@
compiler zsh
let b:undo_ftplugin .= '|unlet b:current_compiler'
\ . '|setlocal errorformat< makeprg<'
+
+" Fold based on indent level, but start with all folds open
+setlocal foldmethod=indent
+setlocal foldlevel=99
+let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<'
diff --git a/vim/after/indent/c.vim b/vim/after/indent/c.vim
new file mode 100644
index 00000000..9cea0a2d
--- /dev/null
+++ b/vim/after/indent/c.vim
@@ -0,0 +1,19 @@
+" Use plain old tabs for indent in C files
+setlocal noexpandtab
+let b:undo_indent .= '|setlocal expandtab<'
+if v:version > 703
+ \ || v:version == 703 && has('patch629')
+ setlocal shiftwidth=0
+else
+ let &l:shiftwidth = &l:tabstop
+endif
+let b:undo_indent .= '|setlocal shiftwidth<'
+if &softtabstop != -1
+ let &l:softtabstop = &l:shiftwidth
+ let b:undo_indent .= '|setlocal softtabstop<'
+endif
+
+" If the path to the file looks like the Vim sources, set 'shiftwidth' to 4
+if expand('%:p') =~# '/vim.*src/'
+ setlocal shiftwidth=4
+endif
diff --git a/vim/after/indent/gitconfig.vim b/vim/after/indent/gitconfig.vim
index 16a948ab..943e78ea 100644
--- a/vim/after/indent/gitconfig.vim
+++ b/vim/after/indent/gitconfig.vim
@@ -1,6 +1,15 @@
" Use tabs for indent in Git config files, rather than fighting with the
" frontend tool
setlocal noexpandtab
-setlocal softtabstop=0
-let &shiftwidth = &tabstop
-let b:undo_indent .= '|setlocal expandtab< softtabstop< shiftwidth<'
+let b:undo_indent .= '|setlocal expandtab<'
+if v:version > 703
+ \ || v:version == 703 && has('patch629')
+ setlocal shiftwidth=0
+else
+ let &l:shiftwidth = &l:tabstop
+endif
+let b:undo_indent .= '|setlocal shiftwidth<'
+if &softtabstop != -1
+ let &l:softtabstop = &l:shiftwidth
+ let b:undo_indent .= '|setlocal softtabstop<'
+endif
diff --git a/vim/after/indent/make.vim b/vim/after/indent/make.vim
index 341cd7f6..116ea25c 100644
--- a/vim/after/indent/make.vim
+++ b/vim/after/indent/make.vim
@@ -1,4 +1,14 @@
-" Use 'tabstop' (8 columns, a full tab) for indent operations in Makefiles.
-" It seems odd that the stock plugin doesn't force this on its own.
-setlocal shiftwidth=0
-let b:undo_indent = 'setlocal shiftwidth<'
+" Use plain old tabs for Makefiles (of course)
+setlocal noexpandtab
+let b:undo_indent = 'setlocal expandtab<'
+if v:version > 703
+ \ || v:version == 703 && has('patch629')
+ setlocal shiftwidth=0
+else
+ let &l:shiftwidth = &l:tabstop
+endif
+let b:undo_indent .= '|setlocal shiftwidth<'
+if &softtabstop != -1
+ let &l:softtabstop = &l:shiftwidth
+ let b:undo_indent .= '|setlocal softtabstop<'
+endif
diff --git a/vim/autoload/alternate_filetypes.vim b/vim/autoload/alternate_filetypes.vim
new file mode 100644
index 00000000..08ac88dc
--- /dev/null
+++ b/vim/autoload/alternate_filetypes.vim
@@ -0,0 +1,13 @@
+function! alternate_filetypes#() abort
+ if exists('b:alternate_filetypes')
+ let filetypes = b:alternate_filetypes
+ let index = index(filetypes, &filetype)
+ if index >= 0
+ let &filetype = filetypes[
+ \ (index + 1) % len(filetypes)
+ \]
+ else
+ unlet b:alternate_filetypes
+ endif
+ endif
+endfunction
diff --git a/vim/autoload/colorscheme.vim b/vim/autoload/colorscheme.vim
new file mode 100644
index 00000000..9ee9f24d
--- /dev/null
+++ b/vim/autoload/colorscheme.vim
@@ -0,0 +1,8 @@
+" Reset colorscheme based on current colorscheme name
+function! colorscheme#UpdateCursorline(colors_name, list) abort
+ if index(a:list, a:colors_name) >= 0
+ set cursorline
+ else
+ set nocursorline
+ endif
+endfunction
diff --git a/vim/autoload/escape.vim b/vim/autoload/escape.vim
new file mode 100644
index 00000000..0fdfba99
--- /dev/null
+++ b/vim/autoload/escape.vim
@@ -0,0 +1,13 @@
+function! escape#Arg(arg) abort
+ return exists('*fnameescape')
+ \ ? fnameescape(a:arg)
+ \ : escape(a:arg, "\n\r\t".' *?[{`$\%#''"|!<')
+endfunction
+
+function! escape#Item(item) abort
+ return escape(a:item, ',')
+endfunction
+
+function! escape#Wild(string) abort
+ return escape(a:string, '\*?[{`''$~')
+endfunction
diff --git a/vim/autoload/fortune.vim b/vim/autoload/fortune.vim
new file mode 100644
index 00000000..6bbe6b3b
--- /dev/null
+++ b/vim/autoload/fortune.vim
@@ -0,0 +1,46 @@
+let s:paths = [
+ \ $HOME.'/.fortunes',
+ \ $HOME.'/.local/share/games/fortunes',
+ \]
+
+let s:executables = [
+ \ 'fortune',
+ \ 'timeout',
+ \]
+
+function! fortune#() abort
+
+ for executable in s:executables
+ if !executable(executable)
+ echoerr 'Missing executable "'.executable.'"'
+ endif
+ endfor
+
+ let limit = &columns - 1
+
+ let command = [
+ \ 'timeout',
+ \ '0.3s',
+ \ 'fortune',
+ \ '-s',
+ \ '-n',
+ \ limit,
+ \]
+
+ for path in s:paths
+ if isdirectory(path)
+ call add(command, path)
+ break
+ endif
+ endfor
+
+ let fortune = substitute(
+ \ system(join(command)),
+ \ '[[:cntrl:][:space:]]\+',
+ \ ' ',
+ \ 'g',
+ \)
+
+ echomsg fortune
+
+endfunction
diff --git a/vim/autoload/has.vim b/vim/autoload/has.vim
new file mode 100644
index 00000000..0100e913
--- /dev/null
+++ b/vim/autoload/has.vim
@@ -0,0 +1,16 @@
+function! has#(feature) abort
+ if has('patch-7.4.237')
+ return has(a:feature)
+ endif
+ let feature = a:feature
+ let pattern = 'patch-\(\d\+\)\.\(\d\+\)\.\(\d\+\)'
+ let matchlist = matchlist(feature, pattern)
+ if empty(matchlist)
+ return has(a:feature)
+ endif
+ let [major, minor, patch] = matchlist[1:3]
+ let l:version = major * 100 + minor
+ return v:version != l:version
+ \ ? v:version > l:version
+ \ : has('patch-'.patch)
+endfunction
diff --git a/vim/autoload/html.vim b/vim/autoload/html.vim
index 9466be33..7ac4f9d3 100644
--- a/vim/autoload/html.vim
+++ b/vim/autoload/html.vim
@@ -28,11 +28,11 @@ function! html#TimestampUpdate() abort
endif
let cv = winsaveview()
call cursor(1,1)
- let li = search('\C^\s*<em>Last updated: .\+</em>$', 'n')
+ let li = search('\m\C^\s*<em>Last updated: .\+</em>$', 'n')
if li
- let date = substitute(system('date -u'), '\C\n$', '', '')
+ let date = substitute(system('date -u'), '\n$', '', '')
let line = getline(li)
- call setline(li, substitute(line, '\C\S.*',
+ call setline(li, substitute(line, '\S.*',
\ '<em>Last updated: '.date.'</em>', ''))
endif
call winrestview(cv)
diff --git a/vim/autoload/mail.vim b/vim/autoload/mail.vim
index 40b7fb7f..3fbba860 100644
--- a/vim/autoload/mail.vim
+++ b/vim/autoload/mail.vim
@@ -79,3 +79,26 @@ function! mail#NewBlank(count, up, visual) abort
endif
endfunction
+
+function! mail#StrictQuote(start, end) abort
+ let body = 0
+ for lnum in range(a:start, a:end)
+
+ " Get current line
+ let line = getline(lnum)
+
+ " Get the leading quote string, if any; skip if there isn't one
+ let quote = matchstr(line, '^>[> ]*')
+ if !strlen(quote)
+ continue
+ endif
+
+ " Normalise the quote with no spaces
+ let quote = substitute(quote, '[^>]', '', 'g')
+
+ " Re-set the line
+ let line = substitute(line, '^[> ]\+', quote, '')
+ call setline(lnum, line)
+
+ endfor
+endfunction
diff --git a/vim/autoload/map.vim b/vim/autoload/map.vim
new file mode 100644
index 00000000..d4bd90a2
--- /dev/null
+++ b/vim/autoload/map.vim
@@ -0,0 +1,12 @@
+" We declare a wrapper around map() to allow us always to call it with
+" a Funcref as the second function parameter, which isn't directly supported
+" by map() until Vim v7.4.1989. If the running version is older than that,
+" apply string() to the Funcref to use the older calling convention.
+"
+" <https://github.com/vim/vim/releases/tag/v7.4.1989>
+"
+function! map#(list, Func) abort
+ return has('patch-7.4.1989')
+ \ ? map(a:list, a:Func)
+ \ : map(a:list, string(a:Func).'(0, v:val)')
+endfunction
diff --git a/vim/autoload/markdown.vim b/vim/autoload/markdown.vim
index c0818246..8bac8045 100644
--- a/vim/autoload/markdown.vim
+++ b/vim/autoload/markdown.vim
@@ -11,8 +11,13 @@ function! markdown#Heading(char) abort
" heading text
let underline = repeat(a:char, strlen(heading))
- " Append the heading text to the buffer on a new line after the heading
- call append(pos[1], underline)
+ " If the line after this one looks like it's already an underline, replace
+ " it; otherwise, create a new underline
+ if getline(pos[1] + 1) =~# '^[-=]\{2,}$'
+ call setline(pos[1] + 1, underline)
+ else
+ call append(pos[1], underline)
+ endif
" Move to the first column of the underline we just inserted
let pos[1] += 1
diff --git a/vim/autoload/paste_insert.vim b/vim/autoload/paste_insert.vim
deleted file mode 100644
index ada11456..00000000
--- a/vim/autoload/paste_insert.vim
+++ /dev/null
@@ -1,12 +0,0 @@
-function! paste_insert#() abort
- augroup paste_insert
- autocmd!
- autocmd CursorHold,CursorMoved,User *
- \ set nopaste paste?
- \|autocmd! paste_insert
- autocmd InsertEnter *
- \ set paste paste?
- \|autocmd paste_insert InsertLeave *
- \ doautocmd paste_insert User
- augroup END
-endfunction
diff --git a/vim/autoload/path.vim b/vim/autoload/path.vim
new file mode 100644
index 00000000..83102138
--- /dev/null
+++ b/vim/autoload/path.vim
@@ -0,0 +1,12 @@
+function! path#Create(name, ...) abort
+ if a:0 > 2
+ echoerr 'Too many arguments'
+ endif
+ if isdirectory(a:name)
+ return 1
+ endif
+ let name = a:name
+ let path = 'p'
+ let prot = a:0 == 1 && a:1 ? 0700 : 0755
+ return mkdir(name, path, prot)
+endfunction
diff --git a/vim/autoload/plugin.vim b/vim/autoload/plugin.vim
new file mode 100644
index 00000000..68e3d54b
--- /dev/null
+++ b/vim/autoload/plugin.vim
@@ -0,0 +1,4 @@
+function! plugin#Ready(name) abort
+ return &loadplugins
+ \ && globpath(&runtimepath, 'plugin/'.a:name.'.vim') !=# ''
+endfunction
diff --git a/vim/autoload/put_date.vim b/vim/autoload/put_date.vim
new file mode 100644
index 00000000..c9f52c12
--- /dev/null
+++ b/vim/autoload/put_date.vim
@@ -0,0 +1,19 @@
+let s:rfc_2822 = '%a, %d %b %Y %T %z'
+
+function! put_date#(line, utc, format) abort
+ let line = a:line
+ let utc = a:utc
+ let format = strlen(a:format)
+ \ ? substitute(a:format, '\a', '%&', 'g')
+ \ : s:rfc_2822
+ if utc
+ if exists('$TZ')
+ let tz = $TZ
+ endif
+ let $TZ = 'UTC'
+ endif
+ execute line.'put =strftime(format)'
+ if exists('tz')
+ let $TZ = tz
+ endif
+endfunction
diff --git a/vim/autoload/reload.vim b/vim/autoload/reload.vim
new file mode 100644
index 00000000..558f24d6
--- /dev/null
+++ b/vim/autoload/reload.vim
@@ -0,0 +1,12 @@
+function! reload#FileType() abort
+ if exists('g:did_load_filetypes')
+ doautocmd filetypedetect BufRead
+ endif
+endfunction
+
+function! reload#Vimrc() abort
+ noautocmd source $MYVIMRC
+ call reload#FileType()
+ redraw
+ echomsg fnamemodify($MYVIMRC, ':p:~').' reloaded'
+endfunction
diff --git a/vim/autoload/scratch_buffer.vim b/vim/autoload/scratch_buffer.vim
new file mode 100644
index 00000000..c0ef7cfc
--- /dev/null
+++ b/vim/autoload/scratch_buffer.vim
@@ -0,0 +1,11 @@
+function! scratch_buffer#(mods, count, ...) abort
+ let command = []
+ call add(command, a:mods)
+ if a:count
+ call add(command, a:count)
+ endif
+ call add(command, 'new')
+ call extend(command, a:000)
+ execute join(command)
+ set buftype=nofile
+endfunction
diff --git a/vim/autoload/spellfile_local.vim b/vim/autoload/spellfile_local.vim
index aafe64ef..e119b718 100644
--- a/vim/autoload/spellfile_local.vim
+++ b/vim/autoload/spellfile_local.vim
@@ -1,11 +1,72 @@
+function! s:SplitOption(string) abort
+ return map(
+ \ split(a:string, '\\\@<!,[, ]*')
+ \,'substitute(v:val, ''\\,'', '''', ''g'')'
+ \)
+endfunction
+
+function! s:JoinOption(list) abort
+ return join(map(
+ \ a:list
+ \,'substitute(v:val, ''\\\@<!,'', ''\\,'', ''g'')'
+ \), ',')
+endfunction
+
+function! s:Establish(path) abort
+ return isdirectory(a:path)
+ \ || exists('*mkdir') && mkdir(a:path, 'p', 0700)
+endfunction
+
function! spellfile_local#() abort
- let spellfile = join([
- \ substitute(expand('%:p'), '[^0-9A-Za-z_.-]', '%', 'g'),
- \ substitute(v:lang, '_.*', '', ''),
- \ &encoding
- \ ], '.') . '.add'
- Establish $MYVIM/cache/spell/local
- execute 'setlocal spellfile+=$MYVIM/cache/spell/local/'.spellfile
- nnoremap <buffer> zG 2zg
- xnoremap <buffer> zG 2zg
+
+ set spellfile<
+
+ let spelllangs = s:SplitOption(&spelllang)
+ if !len(spelllangs) || spelllangs[0] ==# ''
+ echoerr 'Blank ''spelllang'''
+ endif
+ let spelllang = substitute(spelllangs[0], '_.*', '', '')
+
+ if !len(&encoding)
+ echoerr 'Blank ''encoding'''
+ endif
+
+ let spellfiles = s:SplitOption(&spellfile)
+ if len(spellfiles) != 1 || spellfiles[0] ==# ''
+ return
+ endif
+
+ let spelldir = fnamemodify(spellfiles[0], ':h')
+ if spelldir ==# ''
+ echoerr 'Blank directory'
+ endif
+
+ try
+ let path = tr(expand('%:p'), '/', '%')
+ if path ==# ''
+ echoerr 'Blank path'
+ endif
+ call s:Establish(spelldir.'/path')
+ call add(spellfiles, spelldir.'/path/'.join([
+ \ path
+ \,spelllang
+ \,&encoding
+ \,'add'
+ \], '.'))
+
+ if &filetype ==# ''
+ echoerr 'Blank filetype'
+ endif
+ call s:Establish(spelldir.'/filetype')
+ call add(spellfiles, spelldir.'/filetype/'.join([
+ \ &filetype
+ \,spelllang
+ \,&encoding
+ \,'add'
+ \], '.'))
+ catch
+ endtry
+
+ let &l:spellfile = s:JoinOption(spellfiles)
+
endfunction
diff --git a/vim/autoload/split.vim b/vim/autoload/split.vim
new file mode 100644
index 00000000..44065094
--- /dev/null
+++ b/vim/autoload/split.vim
@@ -0,0 +1,12 @@
+if v:version < 702 || v:version == 702 && !has('patch-61')
+ runtime autoload/unescape.vim
+endif
+
+function! split#Option(expr, ...) abort
+ if a:0 > 2
+ echoerr 'Too many arguments'
+ endif
+ let keepempty = a:0 ? a:1 : 0
+ let parts = split(a:expr, '\\\@<!,[, ]*', keepempty)
+ return map#(parts, function('unescape#Item'))
+endfunction
diff --git a/vim/autoload/unescape.vim b/vim/autoload/unescape.vim
new file mode 100644
index 00000000..a809827d
--- /dev/null
+++ b/vim/autoload/unescape.vim
@@ -0,0 +1,3 @@
+function! unescape#Item(key, val) abort
+ return substitute(a:val, '\\,', ',', 'g')
+endfunction
diff --git a/vim/autoload/utc.vim b/vim/autoload/utc.vim
deleted file mode 100644
index 1a464342..00000000
--- a/vim/autoload/utc.vim
+++ /dev/null
@@ -1,4 +0,0 @@
-function! utc#(command) abort
- let tz = expand('$TZ')
- let $TZ = 'UTC' | execute a:command | let $TZ = tz
-endfunction
diff --git a/vim/bundle/cursorline_current b/vim/bundle/cursorline_current
-Subproject 39dca4f5c795766837dfdc1d868b2cd365c1f7f
+Subproject 4ab61f5dfa9a2868c529c75a50219dac6619080
diff --git a/vim/bundle/digraph_search b/vim/bundle/digraph_search
-Subproject 005fb8c6e4042e8eca2af224b9ada2d61824f9b
+Subproject 06eb698192dfa4ea64458aa1483d024d251e82e
diff --git a/vim/bundle/paste_insert b/vim/bundle/paste_insert
new file mode 160000
+Subproject 0365dd11c050f885050cd6dd22405c81aba5f46
diff --git a/vim/bundle/quickfix_auto_open b/vim/bundle/quickfix_auto_open
-Subproject b3b1385490c60ad624d631b4cf99f84e058637b
+Subproject 2e1caf2a9af5c61a53bac0027131c9ea4b03071
diff --git a/vim/bundle/select_old_files b/vim/bundle/select_old_files
new file mode 160000
+Subproject c9ed42c145e09ea121b8e3ff94061253fe4dbd9
diff --git a/vim/bundle/write_mkpath b/vim/bundle/write_mkpath
-Subproject 9f12c7a85e4a2f1cd6f6ba39c5a55a45fe4ea79
+Subproject 2e8372a1c589ccd03207010c7777e155f2f7823
diff --git a/vim/filetype.vim b/vim/filetype.vim
index 19f65e23..7852c37e 100644
--- a/vim/filetype.vim
+++ b/vim/filetype.vim
@@ -44,6 +44,7 @@ augroup filetypedetect
autocmd BufNewFile,BufRead
\ ?*.c
\,?*.h
+ \,*/proto/?*.pro
\ setfiletype c
" C++ files
autocmd BufNewFile,BufRead
@@ -72,9 +73,11 @@ augroup filetypedetect
\,?*.patch
\,?*.rej
\ setfiletype diff
- " INI files
+ " INI format files
autocmd BufNewFile,BufRead
\ ?*.ini
+ \,perlcriticrc
+ \,.perlcriticrc
\ setfiletype dosini
" DOT graphs
autocmd BufNewFile,BufRead
@@ -132,6 +135,7 @@ augroup filetypedetect
autocmd BufNewFile,BufRead
\ ~/.vim/doc/?*.txt
\,*/vim-*/doc/?*.txt
+ \,*/vim/*/doc/?*.txt
\,*/*.vim/doc/?*.txt
\,$VIMRUNTIME/doc/?*.txt
\ setfiletype help
@@ -394,15 +398,13 @@ augroup filetypedetect
" VimL files
autocmd BufNewFile,BufRead
\ ?*.vim
- \,*.exrc
- \,*.gvimrc
- \,*.vimrc
- \,_exrc
- \,_gvimrc
- \,_vimrc
- \,exrc
- \,gvimrc
+ \,.exrc
\,vimrc
+ \,vimrc.*
+ \,[._]vimrc
+ \,gvimrc
+ \,gvimrc.*
+ \,[._]gvimrc
\ setfiletype vim
" .viminfo files
autocmd BufNewFile,BufRead
diff --git a/vim/ftplugin/awk.vim b/vim/ftplugin/awk.vim
index 663ba810..dbefa5cd 100644
--- a/vim/ftplugin/awk.vim
+++ b/vim/ftplugin/awk.vim
@@ -9,6 +9,11 @@ setlocal comments=:#
setlocal formatoptions+=or
let b:undo_ftplugin = 'setlocal comments< formatoptions<'
+" Fold based on indent level, but start with all folds open
+setlocal foldmethod=indent
+setlocal foldlevel=99
+let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<'
+
" Specify ERE flavor for regex_escape.vim
let b:regex_escape_flavor = 'ere'
let b:undo_ftplugin .= '|unlet b:regex_escape_flavor'
diff --git a/vim/ftplugin/markdown.vim b/vim/ftplugin/markdown.vim
index d119e599..da2228b3 100644
--- a/vim/ftplugin/markdown.vim
+++ b/vim/ftplugin/markdown.vim
@@ -39,9 +39,11 @@ function! MarkdownFold()
return '='
endfunction
+let b:undo_ftplugin .= '|delfunction MarkdownFold'
setlocal foldexpr=MarkdownFold()
setlocal foldmethod=expr
-let b:undo_ftplugin .= '|delfunction MarkdownFold|setlocal foldexpr< foldmethod<'
+setlocal foldlevel=99
+let b:undo_ftplugin .= '|setlocal foldexpr< foldmethod< foldlevel<'
" Spellcheck documents we're actually editing (not just viewing)
if &modifiable && !&readonly
diff --git a/vim/ftplugin/sed.vim b/vim/ftplugin/sed.vim
index 9627941d..35e705a4 100644
--- a/vim/ftplugin/sed.vim
+++ b/vim/ftplugin/sed.vim
@@ -8,3 +8,8 @@ let b:did_ftplugin = 1
setlocal comments=:#
setlocal formatoptions+=or
let b:undo_ftplugin = 'setlocal comments< formatoptions<'
+
+" Fold based on indent level, but start with all folds open
+setlocal foldmethod=indent
+setlocal foldlevel=99
+let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<'
diff --git a/vim/ftplugin/textarea.vim b/vim/ftplugin/textarea.vim
index 872ae4c6..4db97b58 100644
--- a/vim/ftplugin/textarea.vim
+++ b/vim/ftplugin/textarea.vim
@@ -1,10 +1,12 @@
+" Set mail message as an alternative filetype
+if !exists('b:alternate_filetypes')
+ let b:alternate_filetypes = [&filetype, 'mail']
+endif
+
" Stop here if the user doesn't want ftplugin mappings
if exists('no_plugin_maps') || exists('no_textarea_maps')
finish
endif
-" Switch to mail filetype, just because that's very often the contents of text
-" areas I edit using TextEditorAnywhere
-nnoremap <buffer> <LocalLeader>f
- \ :<C-U>setlocal filetype=mail<CR>
-let b:undo_ftplugin = 'nunmap <buffer> <LocalLeader>f'
+" #s expands to the #signature tag used in Cerb
+inoreabbrev #s #signature
diff --git a/vim/indent/csv.vim b/vim/indent/csv.vim
index 78bddd33..e97ab29e 100644
--- a/vim/indent/csv.vim
+++ b/vim/indent/csv.vim
@@ -10,6 +10,15 @@ let b:undo_indent = 'setlocal autoindent<'
" Literal tabs
setlocal noexpandtab
-setlocal softtabstop=0
-let &shiftwidth = &tabstop
-let b:undo_indent = 'setlocal expandtab< softtabstop< shiftwidth<'
+let b:undo_indent .= '|setlocal expandtab<'
+if v:version > 703
+ \ || v:version == 703 && has('patch629')
+ setlocal shiftwidth=0
+else
+ let &l:shiftwidth = &l:tabstop
+endif
+let b:undo_indent .= '|setlocal shiftwidth<'
+if &softtabstop != -1
+ let &l:softtabstop = &l:shiftwidth
+ let b:undo_indent .= '|setlocal softtabstop<'
+endif
diff --git a/vim/indent/help.vim b/vim/indent/help.vim
new file mode 100644
index 00000000..78de85d0
--- /dev/null
+++ b/vim/indent/help.vim
@@ -0,0 +1,20 @@
+" Only do this when not done yet for this buffer
+if exists('b:did_indent')
+ finish
+endif
+let b:did_indent = 1
+
+" Literal tabs
+setlocal noexpandtab
+let b:undo_indent = 'setlocal expandtab<'
+if v:version > 703
+ \ || v:version == 703 && has('patch629')
+ setlocal shiftwidth=0
+else
+ let &l:shiftwidth = &l:tabstop
+endif
+let b:undo_indent .= '|setlocal shiftwidth<'
+if &softtabstop != -1
+ let &l:softtabstop = &l:shiftwidth
+ let b:undo_indent .= '|setlocal softtabstop<'
+endif
diff --git a/vim/plugin/alternate_filetypes.vim b/vim/plugin/alternate_filetypes.vim
new file mode 100644
index 00000000..e024c9b2
--- /dev/null
+++ b/vim/plugin/alternate_filetypes.vim
@@ -0,0 +1,4 @@
+command -bar AlternateFileType
+ \ call alternate_filetypes#() | set filetype?
+nnoremap <silent> <Plug>(AlternateFileType)
+ \ :<C-U>AlternateFileType<CR>
diff --git a/vim/plugin/fortune.vim b/vim/plugin/fortune.vim
new file mode 100644
index 00000000..efc03467
--- /dev/null
+++ b/vim/plugin/fortune.vim
@@ -0,0 +1,4 @@
+command! -bar Fortune
+ \ call fortune#()
+nnoremap <silent> <Plug>(Fortune)
+ \ :<C-U>Fortune<CR>
diff --git a/vim/plugin/paste_insert.vim b/vim/plugin/paste_insert.vim
deleted file mode 100644
index 9cd5415e..00000000
--- a/vim/plugin/paste_insert.vim
+++ /dev/null
@@ -1,8 +0,0 @@
-if exists('loaded_paste_insert')
- finish
-endif
-let loaded_paste_insert = 1
-command! -bar PasteInsert
- \ call paste_insert#()
-nnoremap <Plug>PasteInsert
- \ :<C-U>PasteInsert<CR>
diff --git a/vim/plugin/put_date.vim b/vim/plugin/put_date.vim
index d911486e..7848e95f 100644
--- a/vim/plugin/put_date.vim
+++ b/vim/plugin/put_date.vim
@@ -1,6 +1,6 @@
-if exists('loaded_put_date')
+if exists('loaded_put_date') || &compatible || !exists('*strftime')
finish
endif
let loaded_put_date = 1
-command! -bar -range PutDate
- \ <line1>put =strftime('%a, %d %b %Y %T %z')
+command! -bang -bar -nargs=* -range PutDate
+ \ call put_date#(<q-line1>, <q-bang> ==# '!', <q-args>)
diff --git a/vim/plugin/scratch_buffer.vim b/vim/plugin/scratch_buffer.vim
new file mode 100644
index 00000000..c209c8b1
--- /dev/null
+++ b/vim/plugin/scratch_buffer.vim
@@ -0,0 +1,2 @@
+command! -bar -count=0 -nargs=* ScratchBuffer
+ \ call scratch_buffer#(<q-mods>, <q-count>, <f-args>)
diff --git a/vim/plugin/spellfile_local.vim b/vim/plugin/spellfile_local.vim
index c026d626..f6918bfb 100644
--- a/vim/plugin/spellfile_local.vim
+++ b/vim/plugin/spellfile_local.vim
@@ -1,19 +1,12 @@
-if exists('loaded_spellfile_local')
+if exists('loaded_spellfile_local') || &compatible
finish
endif
let loaded_spellfile_local = 1
-let s:spellfile = join([
- \ substitute(v:lang, '_.*', '', ''),
- \ &encoding
- \ ], '.') . '.add'
-Establish $MYVIM/cache/spell
-execute 'set spellfile=$MYVIM/cache/spell/'.s:spellfile
-
-command! -bar AddLocalSpellFile
+command! -bar SetLocalSpellFiles
\ call spellfile_local#()
augroup spellfile_local
autocmd BufNew,BufRead *
- \ AddLocalSpellFile
+ \ SetLocalSpellFiles
augroup END
diff --git a/vim/plugin/utc.vim b/vim/plugin/utc.vim
deleted file mode 100644
index 9b8b647a..00000000
--- a/vim/plugin/utc.vim
+++ /dev/null
@@ -1,6 +0,0 @@
-if exists('loaded_utc')
- finish
-endif
-let loaded_utc = 1
-command! -bar -complete=command -nargs=1 UTC
- \ call utc#(<q-args>)
diff --git a/vim/vimrc b/vim/vimrc
index 2175f114..609a1331 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -1,319 +1,163 @@
-" Tom Ryder (tejr)'s Literate Vimrc
-" =================================
-"
-" <https://sanctum.geek.nz/cgit/dotfiles.git>
-"
-" This is an attempt at something like a 'literate vimrc', in the tradition of
-" Donald Knuth's "literate programming".
-"
+" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+" Tom Ryder (tejr)’s Literate Vimrc
+" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+"
+" Last updated: Tue, 09 Jul 2019 13:11:16 +1200
+"
+" │ And I was lifted up in heart, and thought
+" │ Of all my late-shown prowess in the lists,
+" │ How my strong lance had beaten down the knights,
+" │ So many and famous names; and never yet
+" │ Had heaven appeared so blue, nor earth so green,
+" │ For all my blood danced in me, and I knew
+" │ That I should light upon the Holy Grail.
+" │
+" │ —Tennyson
+"
+" This file is an attempt at something like a “literate vimrc”, in the
+" tradition of Donald Knuth’s “literate programming”:
" <http://www.literateprogramming.com/>
"
-" It's a long file, and comments abound. If this bothers you, you can do
-" something like this to strip out all the blank lines and lines with only
-" comments:
-"
-" :g/\m^$\|^\s*"/d
-"
-" This file should be saved as "vimrc" in the user runtime directory. On
-" Unix-like operating systems, this is ~/.vim; on Windows, it's ~/vimfiles.
-" It requires Vim 7.0 or newer with +eval, with 'nocompatible'. The vimrc
-" stub at ~/.vimrc on Unix or ~/_vimrc on Windows should checks that these
-" conditions are met before loading this file with `:runtime vimrc`.
-"
-" > And I was lifted up in heart, and thought
-" > Of all my late-shown prowess in the lists,
-" > How my strong lance had beaten down the knights,
-" > So many and famous names; and never yet
-" > Had heaven appeared so blue, nor earth so green,
-" > For all my blood danced in me, and I knew
-" > That I should light upon the Holy Grail.
-" >
-" > --Tennyson
-"
-
-" This file has characters outside the ASCII character set, which makes the
-" Vim script linter vim-vint recommend declaring the file encoding with
-" a :scriptencoding command. The :help for this command specifies that it
-" should be done after 'encoding' is set, so we'll do that here at the top of
-" the file too.
-"
-" On Unix, I keep LANG defined in my environment, and it's almost always set
-" to a multibyte (UTF-8) locale. This informs Vim's choice of internal
-" character encoding, but the default for the 'encoding' option in LANG's
-" absence is "latin1". Nowadays, this is never what I want, so we'll manually
-" choose "utf-8" as an encoding instead if LANG is not defined.
-"
-if !exists('$LANG')
- set encoding=utf-8
-endif
-scriptencoding utf-8
-
-" With encoding handled, the next thing we'll do is ensure we have an
-" environment variable MYVIM set that specifies the path to the directory
-" holding user runtime files. We'll only set our own if such a variable does
-" not already exist in the environment.
-"
-" We'll use the path nominated in the MYVIM variable as the root of our
-" 'backupdir', 'directory', 'undodir', and 'viminfofile' caches, and anywhere
-" else we need a sensible writable location for Vim-related files. Having it
-" available as an environment variable makes assignments with :set and
-" escaping much more convenient, without requiring awkward :execute wrappers.
-"
-" I think the absence of a variable like this is a glaring omission from Vim.
-" We have VIM, VIMRUNTIME, and MYVIMRC, so why is there not an environment
-" variable for the user's Vim runtime directory? It is a mystery.
-"
-" The default value for MYVIM will be the first path in &runtimepath. This is
-" similar to what Vim does internally for situating its spelling database
-" files, in the absence of a specific setting for 'spellfile'.
-"
-" Splitting the values of a comma-separated option like 'runtimepath'
-" correctly is surprisingly complicated. The list separator for such options
-" is more accurately defined as follows:
+" The dotfiles project that comprises it is maintained here:
+" <https://sanctum.geek.nz/cgit/dotfiles.git>
"
-" > A comma not preceded by a backslash, and possibly followed by an arbitrary
-" > number of spaces and commas.
+" This is a long file, and comments abound within. Should this be bothersome,
+" one could execute this command in Vim itself to strip out all lines either
+" blank or comprising solely comments:
"
-" The pattern required for the split breaks down like this:
+" :g/\m^$\|^\s*"/d
"
-" \\ <- Literal backslash
-" \@<! <- Negative lookbehind assertion; means that whatever occurred
-" before this pattern, here a backslash, cannot precede what
-" follows, but anything that does precede it is not removed from
-" the data as part of the split delimiter
-" , <- Literal comma
-" [, ]* <- Any number of commas and spaces
-"
-" For the edge case of a blank 'runtimepath', MYVIM will be set to the empty
-" string, due to the way that split() works by default without its third
-" parameter {keepempty} set to false.
-"
-" Once we have the path elements, we have to remove the escaping for periods,
-" specifically remove up to one backslash before all periods. We do that with
-" a map() over substitute(), string-eval style to accommodate older Vim before
-" Funcref variables were added.
-"
-" We don't, however, have to deal with escaped backslashes, or any other
-" character; you can read the source code for the ad-hoc tokenizer in
-" copy_option_part() in src/misc2.c in Vim's source code and test it with some
-" values of your own if you want to understand why.
-"
-" I'll factor this out into a global function if I ever need it anywhere else.
-"
-" Vim, I love you, but you are really weird.
-"
-let s:runtimepath = map(
- \ split(&runtimepath, '\\\@<!,[, ]*'),
- \ "substitute(v:val, '\\\\,', '', 'g')"
- \ )
-if !exists('$MYVIM')
- let $MYVIM = s:runtimepath[0]
-endif
-
-" Having either imported or defined a value for the MYVIM environment
-" variable, we now need to ensure it's not going to cause problems for the
-" rest of this file. If any of those conditions are met, we'll throw an
-" explanatory error and stop reading this file. Most of the file doesn't
-" depend on MYVIM, but there's not much point accommodating these edge cases.
+" This file should be saved as ‘vimrc’—no leading period—in the user runtime
+" directory. On Unix-like operating systems, hereinafter referred to as
+" “*nix”, that directory is ‘~/.vim’; on Windows, it’s ‘~/vimfiles’.
+" Fortunately, those are the only two kinds of operating systems that exist,
+" anywhere in the world.
"
-
-" Firstly, MYVIM can't be an empty string. We need a real path.
+" It requires Vim v7.0.0 or newer, with the +eval feature, and the
+" 'compatible' option turned off, chiefly to allow line continuations. The
+" vimrc stub at ~/.vimrc (Unix) or ~/_vimrc (Windows) should check that these
+" conditions are met before loading this file with ‘:runtime vimrc’.
"
-if $MYVIM ==# ''
- echoerr 'Blank user runtime path'
- finish
-endif
-
-" Secondly, if MYVIM's value contains a comma, its use in comma-separated
-" option values will confuse Vim into thinking more than one directory is
-" being specified, splitting our value into parts. This is normal :set
-" behavior. It's possible to work around this with some careful escaping or
-" :execute abstraction, but it's not really worth the extra complexity for
-" such a niche situation.
+" All of this should survive a pass of the Vim script linter Vint with no
+" errors, warnings, or style problems: <https://github.com/Kuniwak/vint>
"
-if $MYVIM =~# ','
- echoerr 'Illegal comma in user runtime path'
- finish
-endif
-" Thirdly, Vim v7 prior to v7.1.055 had a nasty bug with escaping with
-" multiple backslash characters on the command line, and so on these older
-" versions of Vim, we'll need to forbid that character in the value of MYVIM
-" in order to be confident that we're stashing files in the correct path.
-"
-" To reproduce this bug on these older versions, try this command:
+" We’ll begin by making sure that we and Vim are speaking the same language.
+" Since it’s been the future for a few years now, this file has characters
+" outside the ASCII character set, which prompts Vint to suggest declaring the
+" file encoding with a :scriptencoding command. The :help for that command
+" specifies that this should be done after 'encoding' is set, so we’ll do that
+" here, too.
"
-" :file foo\ bar\ baz
+" On *nix, I define the primary locale environment variable $LANG, almost
+" always specifying a multibyte locale. This informs Vim’s choice of internal
+" character encoding, but the default for the 'encoding' option in the absence
+" of a valid $LANG is ‘latin1’. Since this is almost never what I want, we’ll
+" manually choose the UTF-8 encoding for Unicode in the absence of any other
+" explicit specification.
"
-" It should rename the buffer as "foo bar aaz"; note the change in the first
-" letter of the last word of the filename.
-"
-" <https://github.com/vim/vim/releases/tag/v7.1.055>
-"
-if $MYVIM =~# '\\'
- \ && (v:version < 701 || v:version == 701 && !has('patch55'))
- echoerr 'Illegal backslash in user runtime path on Vim < v7.1.055'
- finish
+if &encoding ==# 'latin1' && !exists('$LANG')
+ set encoding=utf-8
endif
+scriptencoding utf-8
-" Now that we have a bit more confidence in our runtime environment, set up
-" all of the filetype detection, plugin, and indent hooks.
-"
-filetype plugin indent on
-
-" There are a couple of contexts in which it's useful to reload filetypes for
-" the current buffer, quietly doing nothing if filetypes aren't enabled.
-" We'll set up a user command named :ReloadFileType to do this, with
-" a script-local function backing it.
-"
-function! s:ReloadFileType() abort
- if exists('g:did_load_filetypes')
- doautocmd filetypedetect BufRead
- endif
-endfunction
-command! -bar ReloadFileType
- \ call s:ReloadFileType()
-
-" We'll also define a :ReloadVimrc command. This may seem like overkill, at
-" first. Surely just `:source $MYVIMRC` would be good enough?
-"
-" The problem is there are potential side effects to the current buffer when
-" the vimrc is reloaded. The :set commands for options like 'expandtab' and
-" 'shiftwidth' may trample over different buffer-local settings that were
-" specified by filetype and indent plugins. To ensure these local values are
-" reinstated, we'll define the new command wrapper to issue a :ReloadFileType
-" command after the vimrc file is sourced.
-"
-" We can't put the actual :source command into the script-local function we
-" define here, because Vim would get upset that we're trying to redefine
-" a function as it executes!
-"
-" Just to be on the safe side, we also suppress any further ##SourceCmd hooks
-" from running the :source command with a :noautocmd wrapper. This is
-" a defensive measure to avoid infinite recursion. It may not actually be
-" necessary.
-"
-" We emit a faked display of the command, as well, just to make it clear that
-" something has happened. The :redraw just before that message seems to be
-" necessary for this message to display correctly. I'm not sure why.
-"
-function! s:ReloadVimrc() abort
- ReloadFileType
- redraw
- echomsg fnamemodify($MYVIMRC, ':p:~').' reloaded'
-endfunction
-command! -bar ReloadVimrc
- \ noautocmd source $MYVIMRC | call s:ReloadVimrc()
-
-" We'll now create or reset a group of automatic command hooks specific to
-" matters related to reloading the vimrc itself, or maintaining and managing
-" options set within it.
+" With encoding handled, we’ll turn our attention to the value of the
+" 'runtimepath' option, since any scripts loaded from the paths specified
+" therein control so much of the behavior of Vim. I’d like to do this as
+" accurately as possible, even with Vim’s unusual behavior around escaping of
+" these variables. One of the first things we’ll need to be able to do is
+" split the value of 'runtimepath' into its constituent path parts.
"
-augroup vimrc
- autocmd!
-augroup END
-
-" Reload the stub vimrc, and thereby this main one, each time either of them
-" is saved. This often makes errors in the file immediately apparent, and
-" saves restarting Vim or running the :source command manually, which
-" I almost always want to do after changing my vimrc file anyway.
+" Splitting the values of comma-separated options correctly is surprisingly
+" complicated. The list separator for such options is more accurately defined
+" as follows:
"
-autocmd vimrc BufWritePost $MYVIMRC,$MYVIM/vimrc
- \ ReloadVimrc
-
-" If Vim is new enough (v7.0.187) to support the ##SourceCmd event for
-" automatic command hooks, we'll also apply a hook for that event to catch
-" invocations of :source of either vimrc file, and translate that into
-" reloading the stub vimrc.
+" │ A comma not preceded by a backslash, and possibly followed by an arbitrary
+" │ number of spaces and commas.
"
-" <https://github.com/vim/vim/releases/tag/v7.0.187>
+" The pattern required for the split breaks down like this:
"
-if exists('##SourceCmd')
- autocmd vimrc SourceCmd $MYVIMRC,$MYVIM/vimrc
- \ ReloadVimrc
+" \\ ← Literal backslash
+" \@<! ← Negative lookbehind assertion; means that whatever occurred
+" before this pattern, here a backslash, cannot precede what
+" follows, but anything that does precede it is not removed from
+" the data as part of the split delimiter
+" , ← Literal comma
+" [, ]* ← Any number of commas and spaces
+"
+" We don’t, however, have to deal with backslashes before other backslashes,
+" nor before any other character. You can read the source code for the ad-hoc
+" tokenizer in copy_option_part() in src/misc2.c in Vim’s source code, and
+" test it with some values of your own, if you want to understand why. Vim,
+" I love you, but you are really weird sometimes.
+"
+" We do all this with an autoloaded function split#Option().
+"
+" If an environment variable MYVIM exists, and it isn’t blank, apply its value
+" as the first value of 'runtimepath', after escaping it appropriately.
+" Otherwise, do it the other way around: the first path in the 'runtimepath'
+" list becomes MYVIM.
+"
+if exists('$MYVIM') && $MYVIM !=# ''
+ execute 'set runtimepath^='.escape#Arg(escape#Item(escape#Wild($MYVIM)))
+elseif &runtimepath !=# ''
+ let $MYVIM = split#Option(&runtimepath)[0]
endif
-" We're going to be creating a few directories now. The code to do so in
-" a compatible way is verbose, mostly because we need to check whether the
-" directory already exists, even though we're specifying the special 'p' value
-" for its optional {path} argument. This is because until v8.0.1708, mkdir()
-" raises an error if the directory to be created already exists, even with
-" a {path} of 'p', where the analogous `mkdir` shell command does not do so
-" with its -p option included.
-"
-" <https://github.com/vim/vim/releases/tag/v8.0.1708>
-"
-" So, let's wrap that logic in a script-local function s:Establish(), and then
-" hide it behind a user command :Establish. We'll lock down all the
-" directories that we create with restrictive permissions, too. Who knows
-" what secrets are in your file buffers?
-"
-" We set the command's tab completion to provide directory names as
-" candidates, and specify that there must be only one argument, which we'll
-" provide as a quoted parameter to the function.
-"
-function! s:Establish(name) abort
- let name = expand(a:name)
- let path = 'p'
- let prot = 0700
- if !isdirectory(name) && exists('*mkdir')
- call mkdir(name, path, prot)
- endif
-endfunction
-command! -bar -complete=dir -nargs=1 Establish
- \ call s:Establish(<f-args>)
-
-" Now that we have a clean means to create directories if they don't already
-" exist, let's apply it for the first time to the user runtime directory.
-" Note that we aren't checking whether this actually succeeded. We do want
-" errors raised if there were problems with the creation, but we'll barrel on
-" ahead regardless after warning the user about our failure.
+" We need a command to reliably establish a full path, whether or not the
+" directories already exist. We create a wrapper for the autoloaded function
+" path#Create() with similar calling conventions to mkdir(), but with the ‘p’
+" value for the second parameter {prot} forced on. Calling it with a bang
+" like :CreatePath! creates a private directory (permissions 0700).
"
-Establish $MYVIM
+command! -bang -bar -complete=dir -nargs=1 CreatePath
+ \ call path#Create(expand(<q-args>), <q-bang> ==# '!')
-" Our next application of our new :Establish command is to configure the path
-" for the viminfo metadata file, putting it in a cache subdirectory of the
-" user runtime directory set in MYVIM.
+" Now that we have a way to create directories if they don’t already exist,
+" let’s apply it for the first time to the user runtime directory. Note that
+" we aren’t checking whether this actually succeeded. We do want errors
+" raised if there were problems with the creation, but we’ll barrel on ahead
+" regardless after warning the user about our failure.
"
-" Using this non-default location for viminfo has the nice benefit of
+" Using a logical but non-default location for viminfo has the nice benefit of
" preventing command and search history from getting clobbered when something
" runs Vim without using this vimrc, because such an instance will safely
-" write its history to the default viminfo path instead. It also contributes
-" to our aim of having everything related to the Vim runtime process in one
-" dedicated directory tree.
+" write its own history to the default viminfo path instead. It also
+" contributes to our aim of having everything related to the Vim runtime
+" process in one dedicated directory tree.
"
" The normal method of specifying the path to the viminfo file, as applied
-" here, is an addendum of the path to the 'viminfo' option with an "n" prefix.
+" here, is an addendum of the path to the 'viminfo' option with an ‘n’ prefix.
" Vim v8.1.716 introduced a nicer way to set this with an option named
-" 'viminfofile', which is too new for us to use just yet.
+" 'viminfofile', but that’s still too new for us to use just yet.
"
" <https://github.com/vim/vim/releases/tag/v8.1.0716>
"
-Establish $MYVIM/cache
-set viminfo+=n$MYVIM/cache/viminfo
+execute 'set viminfo+='.escape#Arg('n'.$MYVIM.'/viminfo')
+CreatePath $MYVIM
" Speaking of recorded data in viminfo files, the default Vim limit of a mere
-" 50 entries for command and search history is pretty mean. Because I don't
-" think I'm ever likely to be in a situation where remembering several
+" 50 entries for command and search history is pretty stingy. Because I don’t
+" think I’m ever likely to be in a situation where remembering several
" thousand Vim commands and search patterns is going to severely tax memory,
-" let alone disk space, I'd rather this limit were much higher. It's
+" let alone disk space, I’d rather this limit were much higher. It’s
" sometimes really handy to dig up commands from many days ago.
"
-" The maximum value for the 'history' option is documented in `:help
-" 'history'` as 10000, so let's just use that, and see if anything breaks.
+" The maximum value for the 'history' option is documented in ‘:help
+" 'history'’ as 10000, so let’s just use that, and see if anything breaks.
"
set history=10000
-" We'll now enable automatic backups of most file buffers, since that's off by
-" default. In practice, I don't need these backups very much, at least if I'm
+" We’ll now enable automatic backups of most file buffers, since that’s off by
+" default. In practice, I don’t need these backups very much, at least if I’m
" using version control sensibly, but they have still saved my bacon a few
" times.
"
-" We'll try to keep the backup files in a dedicated cache directory, to stop
+" We’ll try to keep the backup files in a dedicated cache directory, to stop
" them popping up next to the file to which they correspond, and getting
" accidentally committed to version control.
"
-" If Vim is new enough, we'll add two trailing slashes to the path we're
+" If Vim is new enough, we’ll add two trailing slashes to the path we’re
" inserting, which prompts Vim to incorporate the full escaped path of the
" relevant buffer in the backup filename, avoiding collisions.
"
@@ -321,24 +165,24 @@ set history=10000
" this trailing slashes hint for a long time before 'backupdir' caught up to
" them. The 'directory' option for swap files has supported it at least as
" far back as v5.8.0 (2001), and 'undodir' appears to have supported it since
-" its creation in v7.2.438. Even though the :help for 'backupdir' didn't say
-" so, people assumed it would work the same way, when in fact Vim simply
-" ignored it until v8.1.0251. I don't want to add the slashes to the option
-" value in older versions of Vim where they don't do anything, so we'll check
-" the version ourselves to see if there's any point in including them.
+" its creation in v7.2.438. Even though ‘:help 'backupdir'’ didn’t say so,
+" people assumed it would work the same way, when in fact Vim simply ignored
+" it until v8.1.0251.
+"
+" I don’t want to add the slashes to the option value in older versions of Vim
+" where they don’t do anything, so we’ll check the version ourselves to see if
+" there’s any point in including them.
"
" <https://github.com/vim/vim/releases/tag/v8.1.0251>
"
-" It's all so awkward. Surely separate options named something like
+" It’s all so awkward. Surely separate options named something like
" 'backupfullname', 'swapfilefullname' would have been clearer.
"
set backup
-Establish $MYVIM/cache/backup
-if has('patch-8.1.251')
- set backupdir^=$MYVIM/cache/backup//
-else
- set backupdir^=$MYVIM/cache/backup
-endif
+execute 'set backupdir^='.escape#Arg(escape#Item(
+ \ $MYVIM.'/backup'.(has#('patch-8.1.251') ? '//' : ''),
+ \))
+CreatePath! $MYVIM/backup
" Files in certain directories on Unix-compatible filesystems should not be
" backed up, for security reasons. This is particularly important if editing
@@ -346,22 +190,22 @@ endif
" a few paths to the default value of 'backupskip' in order to prevent the
" creation of such undesired backup files.
"
-" * /dev/shm: RAM disk, default path for password-store's temporary files
+" * /dev/shm: RAM disk, default path for password-store’s temporary files
" * /usr/tmp: Hard-coded path for sudoedit(8) [1/2]
" * /var/tmp: Hard-coded path for sudoedit(8) [2/2]
"
-" Prior to v8.1.1519, Vim didn't check patterns added to 'backupskip' for
+" Prior to v8.1.1519, Vim didn’t check patterns added to 'backupskip' for
" uniqueness, so adding the same path repeatedly resulted in duplicate strings
" in the value. This was due to the absence of the P_NODUP flag for the
-" option's definition in src/option.c in the Vim source code. If we're using
-" a version older than v8.1.1519, we'll need to explicitly reset 'backupskip'
+" option’s definition in src/option.c in the Vim source code. If we’re using
+" a version older than v8.1.1519, we’ll need to explicitly reset 'backupskip'
" to its default value before adding patterns to it, so that reloading this
-" file doesn't stack up multiple copies of any added paths.
+" file doesn’t stack up multiple copies of any added paths.
"
" <https://github.com/vim/vim/releases/tag/v8.1.1519>
"
-if has('unix')
- if !has('patch-8.1.1519')
+if has#('unix')
+ if !has#('patch-8.1.1519')
set backupskip&
endif
set backupskip^=/dev/shm/*,/usr/tmp/*,/var/tmp/*
@@ -372,10 +216,10 @@ endif
" trailing slashes to the path to prompt Vim to use the full escaped path in
" its name, in order to avoid filename collisions, since the 'directory'
" option has supported that hint for much longer than 'backupdir' has. We
-" apply :Establish to attempt to create the path first, if needed.
+" apply path#Create() to attempt to create the path, if needed.
"
-Establish $MYVIM/cache/swap
-set directory^=$MYVIM/cache/swap//
+execute 'set directory^='.escape#Arg(escape#Item($MYVIM.'/swap//'))
+CreatePath! $MYVIM/swap
" Keep tracked undo history for files permanently, in a dedicated cache
" directory, so that the u/:undo and CTRL-R/:redo commands will work between
@@ -385,63 +229,165 @@ set directory^=$MYVIM/cache/swap//
" if we have a user runtime directory, create a sub-subdirectory within it
" dedicated to the undo files cache. Note also the trailing double-slash as
" a signal to Vim to use the full path of the original file in its undo file
-" cache's name.
+" cache’s name.
"
" Support for these persistent undo file caches was not released until v7.3.0,
-" so we need to check for the feature's presence before we enable it.
+" so we need to check for the feature’s presence before we enable it.
"
-if has('persistent_undo')
- Establish $MYVIM/cache/undo
+if has#('persistent_undo')
set undofile
- set undodir^=$MYVIM/cache/undo//
+ execute 'set undodir^='.escape#Arg(escape#Item($MYVIM.'/undo//'))
+ CreatePath! $MYVIM/undo
+endif
+
+" Now that we have a bit more confidence in our runtime environment, set up
+" all of the filetype detection, plugin, and indent hooks.
+"
+filetype plugin indent on
+
+" There are a couple of contexts in which it's useful to reload filetypes for
+" the current buffer, quietly doing nothing if filetypes aren't enabled.
+" We'll set up a user command named :ReloadFileType to do this, with
+" a script-local function backing it.
+"
+command! -bar ReloadFileType
+ \ call reload#FileType()
+
+" We'll also define a :ReloadVimrc command. This may seem like overkill, at
+" first. Surely just `:source $MYVIMRC` would be good enough?
+"
+" The problem is there are potential side effects to the current buffer when
+" the vimrc is reloaded. The :set commands for options like 'expandtab' and
+" 'shiftwidth' may trample over different buffer-local settings that were
+" specified by filetype and indent plugins. To ensure these local values are
+" reinstated, we'll define the new command wrapper around an autoloaded
+" function that itself issues a :ReloadFileType command after the vimrc file
+" is sourced.
+"
+" We can't put the actual :source command into the script-local function we
+" define here, because Vim would get upset that we're trying to redefine
+" a function as it executes!
+"
+command! -bar ReloadVimrc
+ \ call reload#Vimrc()
+
+" We'll now create or reset a group of automatic command hooks specific to
+" matters related to reloading the vimrc itself, or maintaining and managing
+" options set within it.
+"
+augroup vimrc
+ autocmd!
+augroup END
+
+" Reload the stub vimrc, and thereby this main one, each time either of them
+" is written. This often makes errors in the file immediately apparent, and
+" saves restarting Vim or running the :source command manually, which I almost
+" always want to do after changing my vimrc file anyway.
+"
+autocmd vimrc BufWritePost $MYVIMRC,$MYVIM/vimrc
+ \ ReloadVimrc
+
+" If Vim is new enough (v7.0.187) to support the ##SourceCmd event for
+" automatic command hooks, we'll also apply a hook for that event to catch
+" invocations of :source of either vimrc file, and translate that into
+" reloading the stub vimrc.
+"
+" <https://github.com/vim/vim/releases/tag/v7.0.187>
+"
+if exists('##SourceCmd')
+ autocmd vimrc SourceCmd $MYVIMRC,$MYVIM/vimrc
+ \ ReloadVimrc
+endif
+
+" For spelling, use New Zealand English by default, but later on we’ll
+" configure a leader mapping to switch to United States English, since I so
+" often have to write for Yankees. We’ll set the 'spellfile' option too, to
+" place it in the cache directory into which we’ve been putting everything.
+" We’ll follow Vim’s standard naming convention for the file itself, though.
+" If available, my plugin spellfile_local.vim will extend this later to add
+" more spelling word lists per filetype and per file.
+"
+" We briefly set 'isfname' to every character but NUL if we’re using Unix,
+" since Vim uses it internally for 'spellfile' assignment to decide whether
+" the path is valid. We put it back immediately afterwards.
+"
+set spelllang=en_nz
+let s:spelllang = split#Option(&spelllang)
+let s:spellfile = $MYVIM.'/spell/'.join([
+ \ split(s:spelllang[0], '_')[0], &encoding, 'add',
+ \], '.')
+if has#('unix')
+ let s:isfname = &isfname
+ set isfname=1-255
+endif
+set spellfile&
+execute 'set spellfile^='.escape#Arg(escape#Item(s:spellfile))
+if exists('s:isfname')
+ execute 'set isfname='.escape#Arg(s:isfname)
+ unlet s:isfname
endif
+CreatePath $MYVIM/spell
+
+" Spell checking includes optional support for catching lower case letters at
+" the start of sentences, and defines a pattern in 'spellcapcheck' for the end
+" of a sentence. The default is pretty good, but with two-spacing with
+" 'cpoptions' including ‘J’ and 'formatoptions' including ‘p’ as set later in
+" this file, we can be less ambiguous in this pattern. We require two
+" consecutive spaces, a newline, a carriage return, or a tab to mark the end
+" of a sentence. This means that we could make abbreviations like “i.e.
+" something” without flagging “something” as a spelling error.
+"
+set spellcapcheck=[.?!]\\%(\ \ \\\|[\\n\\r\\t]\\)
" For word completion in insert mode with CTRL-X CTRL-K, or if 'complete'
-" includes the 'k' flag, the 'dictionary' option specifies the path to the
+" includes the ‘k’ flag, the 'dictionary' option specifies the path to the
" system word list. This makes the dictionary completion work consistently,
-" even if 'spell' isn't set at the time to coax it into using 'spellfile'.
+" even if 'spell' isn’t set at the time to coax it into using 'spellfile'.
"
-" It's not an error if the system directory file added first doesn't exist;
-" it's just a common location that often yields a workable word list, and does
+" It’s not an error if the system directory file added first doesn’t exist;
+" it’s just a common location that often yields a workable word list, and does
" so on all of my main machines.
"
" At some point, I may end up having to set this option along with 'spellfile'
" a bit more intelligently to ensure that spell checking and dictionary
" function consistently, and with reference to the same resources. For the
-" moment, I've just added another entry referring to a directory in the user
-" runtime directory, but I don't have anything distinct to put there yet.
+" moment, I’ve just added another entry referring to a directory in the user
+" runtime directory, but I don’t have anything distinct to put there yet.
"
" In much the same way, we add an expected path to a thesaurus, for completion
-" with CTRL-X CTRL-T in insert mode, or with 't' added to 'completeopt'. The
-" thesaurus data isn't installed as part of the default `install-vim` target
-" in tejr's dotfiles, but it can be retrieved and installed with
-" `install-vim-thesaurus`.
+" with CTRL-X CTRL-T in insert mode, or with ‘t’ added to 'completeopt'. The
+" thesaurus data isn’t installed as part of the default ‘install-vim’ target
+" in tejr’s dotfiles, but it can be retrieved and installed with
+" ‘install-vim-thesaurus’.
"
" I got the thesaurus itself from the link in the :help for 'thesaurus' in
-" v8.1. It's from WordNet and MyThes-1. I maintain a mirror on my own
+" v8.1. It’s from WordNet and MyThes-1. I maintain a mirror on my own
" website that the Makefile recipe attempts to retrieve. I had to remove the
" first two metadata lines from thesaurus.txt, as Vim appeared to interpret
" them as part of the body data.
"
" Extra checks for appending the 'dictionary' and 'thesaurus' paths in MYVIM
" need to be made, because the P_NDNAME property is assigned to them, which
-" enforces a character blacklist in the option value. We check for the same
-" set of blacklist characters here, and if the MYVIM path offends, we just
-" skip the setting entirely, rather than throwing cryptic errors at the user.
-" None of them are particularly wise characters to have in paths, anyway,
-" legal though they may be on Unix filesystems.
+" enforces a character blacklist in the option value. We check for the
+" expected Vim error code here, and if the MYVIM path offends, we just skip
+" the setting entirely, rather than throwing cryptic errors at the user. None
+" of the blacklisted characters are particularly wise characters to have in
+" paths, anyway, legal though they may be on Unix filesystems. We can’t work
+" around this one with 'isfname'; the blacklist is hard-coded.
"
set dictionary^=/usr/share/dict/words
-if $MYVIM !~# '[*?[|;&<>\r\n]'
- set dictionary^=$MYVIM/ref/dictionary.txt
- set thesaurus^=$MYVIM/ref/thesaurus.txt
-endif
+let s:ref = $MYVIM.'/ref'
+try
+ execute 'set dictionary^='.escape#Arg(escape#Item(s:ref.'/dictionary.txt'))
+ execute 'set thesaurus^='.escape#Arg(escape#Item(s:ref.'/thesaurus.txt'))
+catch /^Vim\%((\a\+)\)\=:E474:/
+endtry
-" Next, we'll modernize a little in adjusting some options with old
+" Next, we’ll modernize a little in adjusting some options with old
" language-specific defaults.
"
" Traditional vi was often used for development in the C programming language.
-" The default values for a lot of Vim's options still reflect this common use
+" The default values for a lot of Vim’s options still reflect this common use
" pattern. In this case, the 'comments' and 'commentstring' options reflect
" the C syntax for comments:
"
@@ -456,20 +402,20 @@ endif
"
" #include "baz.h"
"
-" Times change, however, and I don't get to work with C nearly as much as I'd
+" Times change, however, and I don’t get to work with C nearly as much as I’d
" like. The defaults for these options no longer make sense, and so we blank
" them, compelling filetype plugins to set them as they need instead.
"
" The default value for the 'path' option is similar, in that it has an aged
" default; this option specifies directories in which project files and
" includes can be unearthed by navigation commands like 'gf'. Specifically,
-" its default value comprises /usr/include, which is another C default. Let's
+" its default value comprises /usr/include, which is another C default. Let’s
" get rid of that, too.
"
set comments= commentstring= define= include=
set path-=/usr/include
-" Next, we'll adjust the global indentation settings. In general and as
+" Next, we’ll adjust the global indentation settings. In general and as
" a default, I prefer spaces to tabs, and I like to use four of them, for
" a more distinct visual structure. Should you happen to disagree with this,
" I cordially invite you to fite me irl.
@@ -481,9 +427,10 @@ set path-=/usr/include
" the Go programming language. For another, two-space indents are more
" traditional for Vim script.
"
-set autoindent " Use indent of previous line on new lines
-set expandtab " Insert spaces when tab key is pressed in insert mode
-set shiftwidth=4 " Indent command like < and > use four-space indents
+set autoindent
+set expandtab
+set shiftwidth=4
+set smarttab
" Apply 'softtabstop' option to make a tab key press in insert mode insert the
" same number of spaces as defined by the indent depth in 'shiftwidth'. If
@@ -492,13 +439,10 @@ set shiftwidth=4 " Indent command like < and > use four-space indents
"
" <https://github.com/vim/vim/releases/tag/v7.3.693>
"
-if v:version > 730 || v:version == 730 && has('patch693')
- set softtabstop=-1
-else
- let &softtabstop = &shiftwidth
-endif
+execute 'set softtabstop='
+ \ . escape#Arg(has#('patch-7.3.693') ? -1 : &shiftwidth)
-" Relax traditional vi's harsh standards over what regions of the buffer can
+" Relax traditional vi’s harsh standards over what regions of the buffer can
" be removed with backspace in insert mode. While this admittedly allows bad
" habits to continue, since insert mode by definition is not really intended
" for deleting text, I feel the convenience outweighs that in this case.
@@ -508,7 +452,7 @@ set backspace+=indent " Leading whitespace characters created by 'autoindent'
set backspace+=start " Text before the start of the current insertion
" When soft-wrapping text with the 'wrap' option on, which is off by default,
-" break the lines between words, rather than within them; it's much easier to
+" break the lines between words, rather than within them; it’s much easier to
" read.
"
set linebreak
@@ -521,11 +465,11 @@ set linebreak
" … U+2026 HORIZONTAL ELLIPSIS
"
" Note that we test for the presence of a multi-byte encoding with a special
-" feature from `:help feature-list`, as recommended by `:help encoding`.
-" Checking that `&encoding ==# 'utf-8'` is not quite the same thing, though
-" it's unlikely I'll ever use a different Unicode encoding by choice.
+" feature from ‘:help feature-list’, as recommended by ‘:help encoding’.
+" Checking that ‘&encoding ==# 'utf-8'’ is not quite the same thing, though
+" it’s unlikely I’ll ever use a different Unicode encoding by choice.
"
-if has('multi_byte_encoding')
+if has#('multi_byte_encoding')
set showbreak=…
else
set showbreak=...
@@ -533,16 +477,16 @@ endif
" The visual structure of code provided by indents breaks down if a lot of the
" lines wrap. Ideally, most if not all lines would be kept below 80
-" characters, but in cases where this isn't possible, soft-wrapping longer
+" characters, but in cases where this isn’t possible, soft-wrapping longer
" lines when 'wrap' is on so that the indent is preserved in the following
" line mitigates this breakdown somewhat.
"
-" With this 'breakindent' option set, it's particularly important to have
+" With this 'breakindent' option set, it’s particularly important to have
" 'showbreak' set to something besides an empty string, as done above,
-" otherwise without line numbers it's hard to tell what's a logical line and
-" what's not.
+" otherwise without line numbers it’s hard to tell what’s a logical line and
+" what’s not.
"
-" The 'breakindent' option wasn't added until v7.4.338, so we need to check it
+" The 'breakindent' option wasn’t added until v7.4.338, so we need to check it
" exists before we set it.
"
" <https://github.com/vim/vim/releases/tag/v7.4.338>
@@ -553,147 +497,129 @@ endif
" Rather than rejecting operations like :write or :saveas when 'readonly' is
" set or in other situations in which data might be lost, Vim should give me
-" a prompt to allow me to confirm that I know what I'm doing.
+" a prompt to allow me to confirm that I know what I’m doing.
"
set confirm
-" If Vim receives an Escape key code in insert mode, it shouldn't wait to see
-" if it's going to be followed by another key code, despite this being how the
+" If Vim receives an Escape key code in insert mode, it shouldn’t wait to see
+" if it’s going to be followed by another key code, despite this being how the
" function keys and Meta/Alt modifier are implemented for many terminal types.
-" Otherwise, if I press Escape, there's an annoying delay before 'showmode'
+" Otherwise, if I press Escape, there’s an annoying delay before 'showmode'
" stops showing '--INSERT--'.
"
" This breaks the function keys and the Meta/Alt modifier in insert mode in
-" most or maybe all of the terminals I use, but I don't want those keys in
+" most or maybe all of the terminals I use, but I don’t want those keys in
" insert mode, anyway. All of this works fine in the GUI, of course.
"
set noesckeys
-" By default, I prefer that figuring out where a region of text to fold away
-" should be done by the indent level of its lines, since I tend to be careful
-" about my indentation even in languages where it has no semantic meaning.
-"
-set foldmethod=indent
-
-" That said, I don't want any of these indent-based folds to start off closed.
-" Therefore, we set the depth level at which folds should automatically start
-" as closed to a rather high number, per the documentation's recommendations.
-"
-" I think of a Vim window with a file buffer loaded into it as
-" a two-dimensional, planar view of the file, so that moving down one screen
-" line means moving down one buffer line, at least when 'wrap' is unset.
-" Folds break that mental model, and so I usually enable them explicitly only
-" when I'm struggling to grasp some code with very long functions or loops.
-"
-set foldlevelstart=99
-
" Automatic text wrapping options using flags in the 'formatoptions' option
-" begin here. I rely on the filetype plugins to set the 't' and 'c' flags for
+" begin here. I rely on the filetype plugins to set the ‘t’ and ‘c’ flags for
" this option to configure whether text or comments should be wrapped, as
-" appropriate for the document type or language, and so I don't mess with
+" appropriate for the document type or language, and so I don’t mess with
" either of those flags here.
" If a line is already longer than 'textwidth' would otherwise limit when
-" editing of that line begins in insert mode, don't suddenly automatically
-" wrap it; I'll break it apart myself with a command like 'gq'. This doesn't
-" seem to stop paragraph reformatting with 'a', if that's set.
+" editing of that line begins in insert mode, don’t suddenly automatically
+" wrap it; I’ll break it apart myself with a command like 'gq'. This doesn’t
+" seem to stop paragraph reformatting with ‘a’, if that’s set.
"
set formatoptions+=l
-" Don't wrap a line in such a way that a single-letter word like "I" or "a" is
+" Don’t wrap a line in such a way that a single-letter word like “I” or “a” is
" at the end of it. Typographically, as far as I can tell, this seems to be
-" a stylistic preference rather than a rule, rather like avoiding "widow" and
-" "orphan" lines in typesetting. I think it generally looks better to have
-" the short word start the line, so we'll switch it on.
+" a stylistic preference rather than a rule, rather like avoiding “widow” and
+" “orphan” lines in typesetting. I think it generally looks better to have
+" the short word start the line, so we’ll switch it on.
"
set formatoptions+=1
" If the filetype plugins have correctly described what the comment syntax for
-" the buffer's language looks like, it makes sense to use that to figure out
+" the buffer’s language looks like, it makes sense to use that to figure out
" how to join lines within comments without redundant comment syntax cropping
-" up. For example, with this set, joining lines in this very comment with 'J'
-" would remove the leading '"' characters.
+" up. For example, with this set, joining lines in this very comment with ‘J’
+" would remove the leading ‘"’ characters.
"
-" This 'formatoptions' flag wasn't added until v7.3.541. Because we can't
+" This 'formatoptions' flag wasn’t added until v7.3.541. Because we can’t
" test for the availability of option flags directly, we resort to a version
-" number check before attempting to set it. I don't like using :silent! to
+" number check before attempting to set it. I don’t like using :silent! to
" suppress errors for this sort of thing when I can reasonably avoid it, even
" if the tests are somewhat more verbose.
"
" <https://github.com/vim/vim/releases/tag/v7.3.541>
"
-if v:version > 730 || v:version == 730 && has('patch541')
+if has#('patch-7.3.541')
set formatoptions+=j
endif
-" A momentary digression here into the doldrums of 'cpoptions'--after
-" staunchly opposing it for years, I have converted to two-spacing. You can
-" blame Steve Losh:
+" A momentary digression here into the doldrums of 'cpoptions'—after staunchly
+" opposing it for years, I have converted to two-spacing. You can blame Steve
+" Losh:
"
" <http://stevelosh.com/blog/2012/10/why-i-two-space/>
"
-" Consequently, we specify that sentence objects for the purposes of the 's'
-" text object, the '(' and ')' sentence motions, and formatting with the 'gq'
+" Consequently, we specify that sentence objects for the purposes of the ‘s’
+" text object, the ‘(’ and ‘)’ sentence motions, and formatting with the 'gq'
" command must be separated by *two* spaces. One space does not suffice.
"
" My defection to the two-spacers is also the reason I now leave 'joinspaces'
" set, per its default, so that two spaces are inserted when consecutive
-" sentences separated by a line break are joined onto one line by the 'J'
+" sentences separated by a line break are joined onto one line by the ‘J’
" command.
"
set cpoptions+=J
" Separating sentences with two spaces has an advantage in making a clear
" distinction between two different types of periods: periods that abbreviate
-" longer words, as in "Mr. Moolenaar", and periods that terminate sentences,
+" longer words, as in “Mr. Moolenaar”, and periods that terminate sentences,
" like this one.
"
-" If we're using two-period spacing for sentences, Vim can interpret the
+" If we’re using two-period spacing for sentences, Vim can interpret the
" different spacing to distinguish between the two types, and can thereby
" avoid breaking a line just after an abbreviating period. For example, the
-" two words in "Mr. Moolenaar" should never be split apart, preventing
-" confusion on the reader's part lest the word "Mr." look too much like the
-" end of a sentence, and also preserving the semantics of that same period for
-" subsequent reformatting; its single-space won't get lost.
+" two words in “Mr. Moolenaar” should never be split apart, lest the
+" abbreviation “Mr.” look too much like the end of a sentence. This also
+" preserves the semantics of that same period for subsequent reformatting; its
+" single-space won’t get lost.
"
-" So, getting back to our 'formatoptions' settings, that is what the 'p' flag
+" So, getting back to our 'formatoptions' settings, that is what the ‘p’ flag
" does. I wrote the patch that added it, after becoming envious of an
" analogous feature during an ill-fated foray into GNU Emacs usage.
"
" <https://github.com/vim/vim/releases/tag/v8.1.1523>
"
-if has('patch-8.1.728')
+if has#('patch-8.1.728')
set formatoptions+=p
endif
" In an effort to avoid loading unnecessary files, we add a flag to the
" 'guioptions' option to prevent the menu.vim runtime file from being loaded.
-" It doesn't do any harm, but I never use it, and it's easy to turn it off.
+" It doesn’t do any harm, but I never use it, and it’s easy to turn it off.
"
-" The documentation for this flag in `:help 'go-M'` includes a note saying the
+" The documentation for this flag in ‘:help 'go-M'’ includes a note saying the
" flag should be set here, rather that in the GUI-specific gvimrc file, as one
" might otherwise think.
"
-if has('gui_running')
+if has#('gui_running')
set guioptions+=M
endif
-" By default, Vim doesn't allow a file buffer to have unsaved changes if it's
-" not displayed in a window. Setting this option removes that restriction so
-" that buffers can remain in a modified state while not actually displayed
-" anywhere.
+" By default, Vim doesn’t allow a file buffer to have unwritten changes if
+" it’s not displayed in a window. Setting this option removes that
+" restriction so that buffers can remain in a modified state while not
+" actually displayed anywhere.
"
-" This option is set in almost every vimrc I read; it's so pervasive that
-" I sometimes see comments expressing astonishment or annoyance that it isn't
-" set by default. However, I didn't actually need this option for several
+" This option is set in almost every vimrc I read; it’s so pervasive that
+" I sometimes see comments expressing astonishment or annoyance that it isn’t
+" set by default. However, I didn’t actually need this option for several
" years of Vim usage, because I instinctively close windows onto buffers only
-" after the buffers within them were saved anyway.
+" after the buffers within them have been written anyway.
"
" However, the option really is required for batch operations performed with
-" commands like :argdo or :bufdo, because Vim won't otherwise tolerate unsaved
-" changes to a litany of buffers that are not displayed in any window. After
-" I started using such command maps a bit more often, I realized I finally had
-" a reason to turn this on permanently.
+" commands like :argdo or :bufdo, because Vim won’t otherwise tolerate
+" unwritten changes to a litany of buffers that are not displayed in any
+" window. After I started using such command maps a bit more often,
+" I realized I finally had a reason to turn this on permanently.
"
set hidden
@@ -705,16 +631,16 @@ set hidden
set hlsearch
nohlsearch
-" Highlight search matches in my text while I'm still typing my pattern,
+" Highlight search matches in my text while I’m still typing my pattern,
" including scrolling the screen to show the first such match if necessary.
" This can be somewhat jarring, particularly when the cursor ends up scrolling
" a long way from home in a large file, but I think the benefits of being able
-" to see instances of what I'm trying to match as I type the pattern do
+" to see instances of what I’m trying to match as I type the pattern do
" outweigh that discomfort.
"
set incsearch
-" Don't waste cycles and bandwidth redrawing the screen during execution of
+" Don’t waste cycles and bandwidth redrawing the screen during execution of
" macro recordings and scripts.
"
set lazyredraw
@@ -731,39 +657,39 @@ set listchars+=trail:- " Trailing spaces
set listchars+=nbsp:+ " Non-breaking spaces
" The next pair of 'list' characters are arguably somewhat misplaced, in that
-" they don't really represent invisible characters in the same way as the
+" they don’t really represent invisible characters in the same way as the
" others, but are hints for the presence of other characters on unwrapped
-" lines that are wider than the screen. They're very useful, though.
+" lines that are wider than the screen. They’re very useful, though.
"
" If the current encoding supports it, use these non-ASCII characters for the
-" markers, as they're visually distinctive:
+" markers, as they’re visually distinctive:
"
" extends: Signals presence of unwrapped text to screen right
" » U+00BB RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
" precedes: Signals presence of unwrapped text to screen left
" « U+00BB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
"
-" Failing that, '<' and '>' will do the trick.
+" Failing that, ‘<’ and ‘>’ will do the trick.
"
-if has('multi_byte_encoding')
+if has#('multi_byte_encoding')
set listchars+=extends:»,precedes:«
else
set listchars+=extends:>,precedes:<
endif
-" Don't let your editor's options be configured by content in arbitrary files!
-" Down with modelines! Purge them from your files! Écrasez l'infâme!
+" Don’t let your editor’s options be configured by content in arbitrary files!
+" Down with modelines! Purge them from your files! Écrasez l’infâme!
"
-" I think that modelines are Vim's worst misfeature, and that 'nomodeline'
-" should be the default. It's enabled pretty bad security vulnerabilities
-" over the years, and it's a lot more effective to use filetype detection,
+" I think that modelines are Vim’s worst misfeature, and that 'nomodeline'
+" should be the default. It’s enabled pretty bad security vulnerabilities
+" over the years, and it’s a lot more effective to use filetype detection,
" other automatic command hooks, or methods like .editorconfig to set
" variables specifically for a buffer or project.
"
set nomodeline
" The only octal numbers I can think of that I ever even encounter are Unix
-" permissions masks, and I'd never use CTRL-A or CTRL-X to increment them.
+" permissions masks, and I’d never use CTRL-A or CTRL-X to increment them.
" Numbers with leading zeroes are far more likely to be decimals.
"
set nrformats-=octal
@@ -779,7 +705,7 @@ set nrformats-=octal
set noruler
" Sessions preserve window, tab, and buffer layout, and are thereby great for
-" more complex and longer-term projects like books, but they don't play
+" more complex and longer-term projects like books, but they don’t play
" together well with plugins and filetype plugins. Restoring the same
" settings from both reloaded plugins and from the session causes screeds of
" errors. Adjusting session behavior to stop it trying to restore the sorts
@@ -788,21 +714,35 @@ set noruler
set sessionoptions-=localoptions " No buffer options or mappings
set sessionoptions-=options " No global options or mappings
-" The 'I' flag for the 'shortmess' option prevents the display of the Vim
+" Turn 'showcmd' off if a system vimrc has been rude enough to set it; I don’t
+" like how it can interfere with the display of longer lines.
+"
+set noshowcmd
+
+" The ‘I’ flag for the 'shortmess' option prevents the display of the Vim
" startup screen with version information, :help hints, and donation
-" suggestion. After I registered Vim and donated to Uganda per the screen's
-" plea, I didn't feel bad about turning this off anymore. Even with this
-" setting in place, I wouldn't normally see it too often anyway, as I seldom
+" suggestion. After I registered Vim and donated to Uganda per the screen’s
+" plea, I didn’t feel bad about turning this off anymore. Even with this
+" setting in place, I wouldn’t normally see it too often anyway, as I seldom
" start Vim with no file arguments.
"
-" I haven't felt the need to mess with the other flags in this option.
-" I don't have any problems with spurious Enter prompts, which seems to be the
+" I haven’t felt the need to mess with the other flags in this option.
+" I don’t have any problems with spurious Enter prompts, which seems to be the
" main reason people pile it full of letters.
"
set shortmess+=I
+" We’ll only use the old 'showmatch' method of a brief jump to the matching
+" bracket under the cursor if the much-preferred matchparen.vim standard
+" plugin doesn’t look like it’s going to load, whether because plugins have
+" been disabled, or it’s not in any of the plugin directories.
+"
+if !plugin#Ready('matchparen')
+ set showmatch matchtime=3
+endif
+
" I find the defaults of new windows opening above or to the left of the
-" previous window too jarring, because I'm used to both the i3 window manager
+" previous window too jarring, because I’m used to both the i3 window manager
" and the tmux terminal multiplexer doing it the other way around, in reading
" order. I prefer the visual effect of the previous text staying where it is,
" and the new window occupying previously blank space.
@@ -817,7 +757,7 @@ set synmaxcol=500
" Vim has an internal list of terminal types that support using smoother
" terminal redrawing, and for which 'ttyfast' is normally set, described in
-" `:help 'ttyfast'`. That list includes most of the terminals I use, but
+" ‘:help 'ttyfast'’. That list includes most of the terminals I use, but
" there are a couple more for which the 'ttyfast' option should apply: the
" windows terminal emulator PuTTY, and the terminal multiplexer tmux, both of
" which I use heavily.
@@ -826,28 +766,28 @@ if &term =~# '^putty\|^tmux'
set ttyfast
endif
-" We really don't want a mouse; while I use it a lot for cut and paste in X,
+" We really don’t want a mouse; while I use it a lot for cut and paste in X,
" it just gets in the way if the tool running in the terminal tries to use it
" too. Mouse events should be exclusively handled by the terminal emulator
-" application, so Vim shouldn't try to give me terminal mouse support, even if
+" application, so Vim shouldn’t try to give me terminal mouse support, even if
" it would work.
"
" The manual suggests that disabling this should be done by clearing 't_RV',
-" but that didn't actually seem to work when I tried it.
+" but that didn’t actually seem to work when I tried it.
"
set ttymouse=
" While using virtual block mode, allow me to navigate to any column of the
-" buffer window; don't confine the boundaries of the block to the coordinates
+" buffer window; don’t confine the boundaries of the block to the coordinates
" of characters that actually exist in the buffer text. While working with
-" formatted columnar data with this off is generally OK, it's a hassle for
+" formatted columnar data with this off is generally OK, it’s a hassle for
" more subtle applications of visual block mode.
"
set virtualedit+=block
-" I can't recall a time that Vim's error beeping or flashing was actually
+" I can’t recall a time that Vim’s error beeping or flashing was actually
" useful to me, and so we turn it off in the manner that the manual instructs
-" in `:help 'visualbell'`. This enables visual rather than audio error bells,
+" in ‘:help 'visualbell'’. This enables visual rather than audio error bells,
" but in the same breath, blanks the terminal attribute that would be used to
" trigger such screen blinking, indirectly disabling the bell altogether.
"
@@ -866,7 +806,7 @@ set visualbell t_vb=
"
" The default value of 'full' for the 'wildmode' option puts the full
" completion onto the line immediately, which I tolerate for insert mode
-" completion but don't really like on the Ex command line. Instead, I arrange
+" completion but don’t really like on the Ex command line. Instead, I arrange
" for that to happen only with a second key press.
"
set wildmenu
@@ -874,7 +814,7 @@ set wildmode=list:longest,full
" Define a list of patterns to ignore for file and directory command line
" completion. Files and directories with names matching any of these patterns
-" won't be presented as candidates for tab completion on the command line.
+" won’t be presented as candidates for tab completion on the command line.
"
" To make this list, I went right through my home directory with
" a `find`-toothed comb; counted the occurrences of every extension, forced
@@ -883,7 +823,7 @@ set wildmode=list:longest,full
"
" The following incantation does the trick with POSIX-compatible shell tools,
" giving patterns for the top 100 alphanumeric extensions for files from the
-" running user's home directory:
+" running user’s home directory:
"
" $ (LC_ALL=C find "$HOME" ! -type d -name '*.?*' -exec \
" sh -c 'for fn ; do
@@ -898,19 +838,14 @@ set wildmode=list:longest,full
"
" I turned out to have rather a lot of .html and .vim files.
"
-" If you're scoffing at that and thinking "I could write a much simpler one",
+" If you’re scoffing at that and thinking “I could write a much simpler one,”
" please do so, and send it to me at <tom@sanctum.geek.nz> to have yours put
-" in here instead, with appropriate credit. Don't forget to handle more than
+" in here instead, with appropriate credit. Don’t forget to handle more than
" ARG_MAX files, include filenames with newlines, and that the -z or -0 null
" separator extensions are not standardized in POSIX.
"
" <https://mywiki.wooledge.org/UsingFind#Complex_actions>
"
-" It's tempting to put the list of patterns here into a separate file--or at
-" least into a more readily editable intermediate list variable--rather than
-" the minor maintenance hassle it presently constitutes in this compact form.
-" I'm not sure whether I'll do that just yet.
-"
set wildignore=*~,#*#,*.7z,.DS_Store,.git,.hg,.svn,*.a,*.adf,*.asc,*.au,*.aup
\,*.avi,*.bin,*.bmp,*.bz2,*.class,*.db,*.dbm,*.djvu,*.docx,*.exe
\,*.filepart,*.flac,*.gd2,*.gif,*.gifv,*.gmo,*.gpg,*.gz,*.hdf,*.ico
@@ -924,12 +859,12 @@ set wildignore=*~,#*#,*.7z,.DS_Store,.git,.hg,.svn,*.a,*.adf,*.asc,*.au,*.aup
" appropriate case, like the Readline setting completion-ignore-case can be
" used for GNU Bash.
"
-" As far as I can tell, despite its name, the 'wildignore' case option doesn't
+" As far as I can tell, despite its name, the 'wildignore' case option doesn’t
" have anything to do with the 'wildignore' option, and so files that would
" match any of those patterns only with case insensitivity implied will still
" be candidates for completion.
"
-" The option wasn't added until v7.3.72, so we need to check it exists before
+" The option wasn’t added until v7.3.72, so we need to check it exists before
" we try to set it.
"
" <https://github.com/vim/vim/releases/tag/v7.3.072>
@@ -938,7 +873,7 @@ if exists('+wildignorecase')
set wildignorecase
endif
-" Enable syntax highlighting, but only if it's not already on, to save
+" Enable syntax highlighting, but only if it’s not already on, to save
" reloading the syntax files unnecessarily.
"
" <https://sanctum.geek.nz/blinkenlights/syntax-on.jpg>
@@ -946,50 +881,57 @@ endif
" For several months in 2018, as an experiment, I tried using terminals with
" no color at all, imitating a phenomenally productive BSD purist co-worker
" who abhorred color in any form on his terminals. He only drank black
-" coffee, too. If you're reading this: Hello, bdh!
+" coffee, too. If you’re reading this: Hello, bdh!
"
" That experiment was instructive and interesting, and I found I had been
" leaning on color information in some surprising ways. However, some months
" later, I found I still missed my colors, and so I went back to my
-" Kodachrome roots, and didn't pine at all for that monochrome world.
+" Kodachrome roots, and didn’t pine at all for that monochrome world.
"
" The thing I most like about syntax highlighting is detecting runaway
" strings, which generally works in even the most threadbare language syntax
-" highlighting definitions. I kept missing such errors when I didn't have the
-" colors. I don't have high standards for it otherwise, except maybe for
+" highlighting definitions. I kept missing such errors when I didn’t have the
+" colors. I don’t have high standards for it otherwise, except maybe for
" shell script.
"
if !exists('syntax_on')
syntax enable
endif
-" Before we attempt to pick a syntax highlighting color scheme, we'll set up
+" Before we attempt to pick a syntax highlighting color scheme, we’ll set up
" a couple of hooks for color scheme loading. In this case, we turn
-" 'cursorline' on if my 'sahara' color scheme is loaded, since I've configured
-" it to be a very dark gray that doesn't stand out too much against a black
+" 'cursorline' on if my 'sahara' color scheme is loaded, since I’ve configured
+" it to be a very dark gray that doesn’t stand out too much against a black
" background. For any other color scheme, turn the option off, because it
" almost always stands out too much for my liking.
"
+" You’d think the pattern here could be used to match the color scheme name,
+" and it can be...after patch v7.4.108, when Christian Brabandt fixed it.
+" Until that version, it matched against the current buffer name, so we’re
+" forced to have an explicit test in the command instead.
+"
+" <https://github.com/vim/vim/releases/tag/v7.4.108>
+"
autocmd vimrc ColorScheme *
- \ set nocursorline
-autocmd vimrc ColorScheme sahara
- \ set cursorline
+ \ call colorscheme#UpdateCursorline(g:colors_name, ['sahara'])
-" We'll have Vim try to use my 'sahara' fork of the 'desert256' color scheme.
-" If we fail to load the color scheme, for whatever reason, suppress the
-" error, and ensure a dark background for the default color scheme.
+" Use 'dark' as my default value for 'background', in the absence of an
+" environment variable COLORFGBG or a response in v:termrbgresp that would set
+" it specifically.
"
-" There's also a very simple grayscale color scheme I occasionally use instead
-" called 'juvenile', which is included as a Git submodule with this dotfiles
-" distribution.
+if !exists('$COLORFGBG') && get(v:, 'termrbgresp', '') ==# ''
+ set background=dark
+endif
+
+" If the background seems to be dark, and I have either the GUI or a 256 color
+" terminal, and my custom sahara.vim color scheme looks to be available, load
+" it.
"
-try
+if &background ==# 'dark'
+ \ && (has#('gui_running') || &t_Co >= 256)
+ \ && globpath(&runtimepath, 'colors/sahara.vim') !=# ''
colorscheme sahara
-catch
- if &background !=# 'dark'
- set background=dark
- endif
-endtry
+endif
" My mapping definitions begin here. I have some general personal rules for
" approaches to mappings:
@@ -1007,26 +949,32 @@ endtry
" use selection mode directly.
"
" * Avoid mapping in insert mode; let characters be literal to the greatest
-" extent possible, and avoid "doing more" in insert mode besides merely
-" inserting text as it's typed.
+" extent possible, and avoid “doing more” in insert mode besides merely
+" inserting text as it’s typed.
"
" * Avoid key chords with Ctrl in favor of leader keys.
"
" * Never use Alt/Meta key chords; the terminal support for them is just too
" confusing and flaky.
"
-" * Don't suppress display of mapped commands for no reason; it's OK to show
-" the user the command that's being run under the hood. Do avoid HIT-ENTER
+" * Don’t suppress display of mapped commands for no reason; it’s OK to show
+" the user the command that’s being run under the hood. Do avoid HIT-ENTER
" prompts, though.
"
-" * Avoid shadowing any of Vim's existing functionality. If possible, extend
+" * 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 find the space bar's default behavior in normal mode of moving right one
+" Use backspace as an even quicker way to switch to the current buffer’s
+" alternate buffer. User nickspoons of #vim was incredulous that I had never
+" used CTRL-^ and indeed did not know about it. I have since repented.
+"
+nnoremap <Backspace> <C-^>
+
+" I find the space bar’s default behavior in normal mode of moving right one
" character to be useless. Instead, I remap it to be a lazy way of paging
" through the argument list buffers, scrolling a page until the last line of
" the buffer is visible, and then moving to the :next buffer.
@@ -1038,12 +986,12 @@ nnoremap <expr> <Space>
\ ? "\<PageDown>"
\ : ":\<C-U>next\<CR>"
-" I hate CTRL-C's default insert mode behavior. It ends the insert session
+" I hate CTRL-C’s default insert mode behavior. It ends the insert session
" without firing the InsertLeave event for automatic command hooks. Why would
" anyone want that? It breaks plugins that hinge on mirrored functionality
-" between the InsertEnter and InsertLeave events, and doesn't otherwise differ
-" from Escape or :stopinsert. Even worse, people think it's a *synonym* for
-" Escape, and use it because it's easier to reach than the Escape key or
+" between the InsertEnter and InsertLeave events, and doesn’t otherwise differ
+" from Escape or :stopinsert. Even worse, people think it’s a *synonym* for
+" Escape, and use it because it’s easier to reach than the Escape key or
" CTRL-[. Terrible!
"
" Instead, I apply a custom plugin named insert_cancel.vim to make it cancel
@@ -1055,15 +1003,15 @@ nnoremap <expr> <Space>
" <https://sanctum.geek.nz/cgit/vim-insert-cancel.git/about/>
"
" You might think on a first look, as I did, that a plugin is overkill, and
-" that a mapping like this would be all that's required:
+" that a mapping like this would be all that’s required:
"
" :inoremap <C-C> <Esc>u
"
" Indeed, it *mostly* works, but there are some subtle problems with it. The
-" primary issue is that if you didn't make any changes during the insert mode
-" session that you're terminating, it *still* reverses the previous change,
-" which will be something else entirely that you probably *didn't* mean to be
-" undone. The plugin's way of working around this and the other shortcomings
+" primary issue is that if you didn’t make any changes during the insert mode
+" session that you’re terminating, it *still* reverses the previous change,
+" which will be something else entirely that you probably *didn’t* mean to be
+" undone. The plugin’s way of working around this and the other shortcomings
" of the simple mapping above is not too much more complicated, but it was not
" easy to figure out.
"
@@ -1071,17 +1019,17 @@ nnoremap <expr> <Space>
" plugin to load, so test that 'loadplugins' is set and that the plugin file
" exists with the expected filename.
"
-" If the plugin isn't available, I just abandon CTRL-C to continue its
+" If the plugin isn’t available, I just abandon CTRL-C to continue its
" uselessness.
"
-if &loadplugins && globpath(&runtimepath, 'plugin/insert_cancel.vim') !=# ''
+if plugin#Ready('insert_cancel')
imap <C-C> <Plug>(InsertCancel)
endif
-" I often can't remember (or guess) digraph codes, and want to look up how to
+" I often can’t remember (or guess) digraph codes, and want to look up how to
" compose a specific character that I can name, at least in part. The table
-" in `:help digraph-table` is what to use for that situation, and it solves
-" the problem, but I didn't like the overhead of repeated lookups therein.
+" in ‘:help digraph-table’ is what to use for that situation, and it solves
+" the problem, but I didn’t like the overhead of repeated lookups therein.
"
" Steve Losh has a solution I liked where a double-tap of CTRL-K in insert
" mode brought up the applicable :help window:
@@ -1103,10 +1051,10 @@ endif
" <https://sanctum.geek.nz/cgit/vim-digraph-search.git/about/>
"
" This leaves you in insert mode, ready to hit CTRL-K one more time and then
-" type the digraph that you've hopefully found.
+" type the digraph that you’ve hopefully found.
"
-" Since a double-tap of CTRL-K does nothing in default Vim, we don't bother
-" checking that the plugin's available before we map to it; it'll just quietly
+" Since a double-tap of CTRL-K does nothing in default Vim, we don’t bother
+" checking that the plugin’s available before we map to it; it’ll just quietly
" do nothing.
"
imap <C-K><C-K> <Plug>(DigraphSearch)
@@ -1115,53 +1063,53 @@ imap <C-K><C-K> <Plug>(DigraphSearch)
" 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
-" insert and visual modes, too, where it's occasionally useful, especially on
+" This gets by far the most use in normal mode, but I’d like it to work in
+" insert and visual modes, 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 behavior.
+" extending rather than replacing Vim’s normal behavior.
"
nnoremap <C-L>
\ :<C-U>nohlsearch<CR><C-L>
" The insert mode wrapper for normal CTRL-L uses i_CTRL-O to issue a single
-" normal mode command. We intentionally use `:normal` rather than `:normal!`
+" normal mode command. We intentionally use ‘:normal’ rather than ‘:normal!’
" so that the mapping works recursively. I tried using <C-O><C-L> with :imap
-" for this, but it didn't work. Maybe i_CTRL-O doesn't respect mappings.
-" I couldn't find any documentation about it.
+" for this, but it didn’t work. Maybe i_CTRL-O doesn’t respect mappings.
+" I couldn’t find any documentation about it.
"
inoremap <C-L> <C-O>:execute "normal \<C-L>"<CR>
" We use :vnoremap here 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 make it work, even though I don't actually
+" apply to select mode as well, because CTRL-L doesn’t reflect a printable
+" character, and so we may as well make it work, even though I don’t actually
" use select mode directly.
"
vmap <C-L> <Esc><C-L>gv
-" 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.
+" 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 &
+noremap &
\ :&&<CR>
+ounmap &
+sunmap &
-" I really like using the '!' command in normal mode as an operator to filter
+" 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
+" didn’t seem to be an analogue for a motion to filter text through an
" internal command like :sort, so I wrote one.
"
" <https://sanctum.geek.nz/cgit/vim-colon-operator.git/about/>
"
nmap g: <Plug>(ColonOperator)
-" 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
+" 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.
@@ -1187,9 +1135,9 @@ nnoremap [l
nnoremap ]l
\ :lnext<CR>
-" Here's another mapping I particularly liked from unimpaired.vim; insert
+" Here’s another mapping I particularly liked from unimpaired.vim; 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
+" put_blank_lines.vim. These use operator functions so that they’re
" repeatable without repeat.vim. They accept count prefixes, too.
"
" <https://sanctum.geek.nz/cgit/vim-put-blank-lines.git/about/>
@@ -1197,98 +1145,110 @@ nnoremap ]l
nmap [<Space> <Plug>(PutBlankLinesAbove)
nmap ]<Space> <Plug>(PutBlankLinesBelow)
-" We're on to the leader maps, now. It's difficult to know in what order to
+" We’re on to the leader maps, now. It’s difficult to know in what order to
" describe and specify these. I used to have them in alphabetical order, but
" it seems much more useful to group them by the type of action they take.
"
-" 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
+" 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
+" 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 I sometimes wonder if
" I would use the key for its original function more, had I not shadowed it.
"
let mapleader = '\'
let maplocalleader = ','
-" 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
+" If the local leader is a comma, map double-tap comma to its original
+" function in the relevant modes so that I can still use it quickly without
+" relying on mapping 'timeout'.
+"
+if maplocalleader ==# ','
+ noremap ,, ,
+ sunmap ,,
+endif
+
+" 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
+" These are sometimes applicable in visual mode, and sometimes not. We’ll
" start with the ones that only make sense as normal mode maps. Annoyingly,
-" a visual mode mapping for 'cursorline' toggling doesn't work at all;
+" 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,TAB toggles automatic indentation based on the previous line
+nnoremap <Leader><Tab>
+ \ :<C-U>set autoindent! autoindent?<CR>
+"" Leader,c toggles highlighted cursor row; doesn’t work in visual mode
+nnoremap <Leader>c
+ \ :<C-U>set cursorline! cursorline?<CR>
"" 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,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,s toggles spell checking
nnoremap <Leader>s
- \ :<C-U>setlocal spell! spell?<CR>
+ \ :<C-U>set 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,N toggles position display in bottom right
-nnoremap <Leader>N
- \ :<C-U>set ruler! ruler?<CR>
-xmap <Leader>N <Esc><Leader>Ngv
"" Leader,C toggles highlighted cursor column; works in visual mode
-nnoremap <Leader>C
- \ :<C-U>setlocal cursorcolumn! cursorcolumn?<CR>
-xmap <Leader>C <Esc><Leader>Cgv
+noremap <Leader>C
+ \ :<C-U>set cursorcolumn! cursorcolumn?<CR>
+ounmap <Leader>C
+sunmap <Leader>C
"" 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
+noremap <Leader>l
+ \ :<C-U>set list! list?<CR>
+ounmap <Leader>l
+sunmap <Leader>l
"" Leader,n toggles line number display
-nnoremap <Leader>n
- \ :<C-U>setlocal number! number?<CR>
-xmap <Leader>n <Esc><Leader>ngv
+noremap <Leader>n
+ \ :<C-U>set number! number?<CR>
+ounmap <Leader>n
+sunmap <Leader>n
+"" Leader,N toggles position display in bottom right
+noremap <Leader>N
+ \ :<C-U>set ruler! ruler?<CR>
+ounmap <Leader>N
+sunmap <Leader>N
"" Leader,w toggles soft wrapping
-nnoremap <Leader>w
- \ :<C-U>setlocal wrap! wrap?<CR>
-xmap <Leader>w <Esc><Leader>wgv
+noremap <Leader>w
+ \ :<C-U>set wrap! wrap?<CR>
+ounmap <Leader>w
+sunmap <Leader>w
" This next one just shows option state of the 'formatoptions' affecting how
-" text is automatically formatted; it doesn't change its value.
+" 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>
+ \ :<C-U>set 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
+" 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>
+ \ :<C-U>set spelllang=en_nz<CR>
+nnoremap <Leader>u
+ \ :<C-U>set spelllang=en_us<CR>
-" The next mapping is also for toggling an option, but it's more complicated;
+" The next mapping is also for toggling an option, 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
+" 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,
+" 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
@@ -1302,24 +1262,25 @@ nnoremap <Leader>z
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
+" simple, but there isn’t a way to toggle single flags within option strings
" with just the :set command, 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
+"" 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
+noremap <Leader>L
\ :<C-U>ToggleFlagLocal colorcolumn +1<CR>
-xmap <Leader>L <Esc><Leader>Lgv
+ounmap <Leader>L
+sunmap <Leader>L
" This mapping uses my paste_insert.vim plugin to queue up automatic commands
-" for the next insert operation. It's still pretty new. It replaces my old
+" for the next insert operation. It’s still pretty new. It replaces my old
" paste_open.vim plugin which did this only for opening new lines, and which
-" kept confusing me. I'm hoping this will be better.
+" kept confusing me. I’m hoping this will be better.
"" Leader,p prepares the next insert for paste mode
nmap <Leader>p <Plug>PasteInsert
@@ -1333,36 +1294,36 @@ nnoremap <Leader>F
\ :<C-U>ReloadFileType<CR>
"" Leader,t shows current filetype
nnoremap <Leader>t
- \ :<C-U>setlocal filetype?<CR>
+ \ :<C-U>set filetype?<CR>
"" Leader,T clears filetype
nnoremap <Leader>T
- \ :<C-U>setlocal filetype=<CR>
+ \ :<C-U>set filetype=<CR>
-" These mappings use my put_date.vim and utc.vim plugins for date insertion
-" into the buffer.
+" These mappings use my put_date.vim plugin for date insertion into the
+" buffer.
"" Leader,d inserts the local date (RFC 2822)
nnoremap <Leader>d
\ :PutDate<CR>
"" Leader,D inserts the UTC date (RFC 2822)
nnoremap <Leader>D
- \ :<Home>UTC<End> PutDate<CR>
+ \ :PutDate!<CR>
" This group contains mappings that are to do with file and path management
" relative to the current buffer. The Leader,P mapping that creates
-" directory hierarchies uses the :Establish command created earlier.
+" directory hierarchies uses the :CreatePath command created earlier.
-"" 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 if it doesn't exist
+"" Leader,P creates the path to the current file if it doesn’t exist
nnoremap <Leader>P
- \ :<C-U>Establish %:h<CR>
+ \ :<C-U>CreatePath %:h<CR>
-" This group contains mappings that show information about Vim's internals:
+" This group contains mappings that show information about Vim’s internals:
" marks, registers, variables, and the like.
"" Leader,H shows command history
@@ -1397,8 +1358,8 @@ nnoremap <Leader>y
\ :<C-U>registers<CR>
" This group contains mappings concerned with buffer navigation and
-" management. I use the "jetpack" buffer jumper one a lot. I got it from one
-" of bairui's "Vim and Vigor" comics:
+" management. I use the “jetpack” buffer jumper one a lot. I got it from one
+" of bairui’s “Vim and Vigor” comics:
"
" <http://of-vim-and-vigor.blogspot.com/p/vim-vigor-comic.html>
@@ -1410,15 +1371,23 @@ 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>
+ \ :<C-U>set 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")
+ \ :<C-U>set nomodifiable readonly<CR>
+"" Leader,j jumps to buffers—the “jetpack”
nnoremap <Leader>j
\ :<C-U>buffers<CR>:buffer<Space>
-" This ground defines mappings for filtering and batch operations to clean up
+" Leader,o hacks up the list of old files from viminfo just long enough to
+" ensure that :browse :oldfiles fits in a screen, avoiding an Enter or ‘q’
+" keystroke before entering the number. This one is handy followed by
+" <Leader>,\ to jump back to the last remembered position in that file, since
+" by definition viminfo remembers that mark, too.
+"
+nmap <Leader>o <Plug>(SelectOldFiles)
+
+" This group defines mappings for filtering and batch operations to clean up
" buffer text. All of these mappings use commands from my custom plugins:
"
" :KeepPosition
@@ -1430,15 +1399,16 @@ nnoremap <Leader>j
"
"" Leader,x strips trailing whitespace
-nnoremap <Leader>x
- \ :StripTrailingWhitespace<CR>
-xnoremap <Leader>x
+noremap <Leader>x
\ :StripTrailingWhitespace<CR>
+ounmap <Leader>x
+sunmap <Leader>x
+
"" Leader,X squeezes repeated blank lines
-nnoremap <Leader>X
- \ :SqueezeRepeatBlanks<CR>
-xnoremap <Leader>X
+noremap <Leader>X
\ :SqueezeRepeatBlanks<CR>
+ounmap <Leader>X
+sunmap <Leader>X
"" Leader,= runs the whole buffer through =, preserving position
nnoremap <Leader>=
\ :<C-U>KeepPosition execute 'normal! 1G=G'<CR>
@@ -1447,15 +1417,16 @@ nnoremap <Leader>+
\ :<C-U>KeepPosition execute 'normal! 1GgqG'<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
+" 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
onoremap <Leader>_
\ :<C-U>execute 'normal! `[v`]'<CR>
-"" Leader,% uses entire buffer as an object
+"" Leader,% or Leader,5 uses entire buffer as an object
onoremap <Leader>%
\ :<C-U>execute 'normal! 1GVG'<CR>
+omap <Leader>5 <Leader>%
" This group defines some useful motions, including navigating by indent
" block using a custom plugin:
@@ -1468,7 +1439,7 @@ 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?"
+"" Leader,\ jumps to the last edit position mark; think “Now, where was I?”
noremap <Leader>\ `"
sunmap <Leader>\
@@ -1489,12 +1460,14 @@ nnoremap <Leader>/
nnoremap <Leader>?
\ :<C-U>lhelpgrep \c<S-Left>
-" This group contains miscellaneous mappings for which I couldn't find any
+" 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.
"
-" * <https://sanctum.geek.nz/cgit/vim-replace-operator.git/about/>
+" * <https://sanctum.geek.nz/cgit/vim-alternate-filetype.git/about/>
" * <https://sanctum.geek.nz/cgit/vim-regex-escape.git/about/>
+" * <https://sanctum.geek.nz/cgit/vim-replace-operator.git/about/>
+" * <https://sanctum.geek.nz/cgit/vim-scratch-buffer.git/about/>
"
"" Leader,. runs the configured make program into the location list
@@ -1503,24 +1476,47 @@ nnoremap <Leader>.
"" 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)
-
-" And last, but definitely not least, I'm required by Vim fanatic law to
+map <Leader>r <Plug>(ReplaceOperator)
+ounmap <Leader>r
+sunmap <Leader>r
+"" Leader,!/1 repeats the last command, adding a bang
+nnoremap <Leader>!
+ \ :<Up><Home><S-Right>!<CR>
+nmap <Leader>1 <Leader>!
+"" Leader,#/3 gives me my fortune
+nmap <Leader># <Plug>(AlternateFileType)
+nmap <Leader>3 <Leader>#
+"" Leader,$/4 gives me my fortune
+nmap <Leader>$ <Plug>(Fortune)
+nmap <Leader>4 <Leader>$
+"" Leader,&/7 escapes regex metacharacters
+map <Leader>& <Plug>(RegexEscape)
+ounmap <Leader>&
+sunmap <Leader>&
+map <Leader>7 <Leader>&
+ounmap <Leader>7
+sunmap <Leader>7
+"" Leader,*/8 is sticky-star: search, highlight, but don’t move
+nnoremap <silent> <Leader>* *N
+nmap <Leader>8 <Leader>*
+"" Leader,` opens a scratch buffer, horizontally split
+nnoremap <silent> <Leader>`
+ \ :<C-U>ScratchBuffer<CR>
+"" Leader,~ opens a scratch buffer, vertically split
+nnoremap <silent> <Leader>~
+ \ :<C-U>vertical ScratchBuffer<CR>
+
+" And last, but definitely not least, I’m required by Vim fanatic law to
" include a mapping that reloads my whole configuration. This uses the
" command wrapper defined much earlier in the file, so that filetypes also get
-" reloaded afterwards, meaning I don't need to follow <Leader>R with
+" reloaded afterwards, meaning I don’t need to follow <Leader>R with
" a <Leader>F to fix up broken global settings.
-
-"" Leader,R reloads ~/.vimrc
+"
nnoremap <Leader>R
\ :<C-U>ReloadVimrc<CR>
-" 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
+" 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:
"
@@ -1538,9 +1534,10 @@ inoreabbrev THere There
" Here endeth the literate vimrc. Let us praise God.
"
-" > Consequently, it is soon recognized that they write for the sake of
-" > filling up the paper, and this is the case sometimes with the best
-" > authors...as soon as this is perceived the book should be thrown away,
-" > for time is precious.
-" >
-" > -- Schopenhauer
+" │ Consequently, it is soon recognized that they write for the sake of
+" │ filling up the paper, and this is the case sometimes with the best
+" │ authors…as soon as this is perceived the book should be thrown away,
+" │ for time is precious.
+" │
+" │ —Schopenhauer
+"
diff --git a/vim/vimrc.stub b/vim/vimrc.stub
new file mode 100644
index 00000000..1e496033
--- /dev/null
+++ b/vim/vimrc.stub
@@ -0,0 +1,25 @@
+" We have a big, important decision to make here.
+"
+" Check that we're not running in 'compatible' mode, nor that the environment
+" calls for the same, and that we're running Vim v7.0.0 or newer. If it's all
+" clear, we can load the main vimrc file from ~/.vim/vimrc to use Vim in all
+" of its incompatible glory, and then stop sourcing the rest of this file.
+"
+if !&compatible && !exists('$POSIXLY_CORRECT') && v:version >= 700
+ runtime vimrc
+ finish
+endif
+
+" If we got this far, it means we're running a tiny, 'compatible', and/or
+" ancient version of Vim.
+"
+" So, strip out the user runtime directories from 'runtimepath', force
+" 'compatible' on, source your trusty ~/.exrc, put on your dubbed cassette
+" copy of Kraftwerk's 'Computerwelt', and start using vi v3.7 on your
+" engineering department's Sun OS 4.x server via your VT220 terminal. It's
+" July 1985, you grok ANSI C, and it's good for you, like raisin bran.
+"
+set runtimepath-=~/.vim
+set runtimepath-=~/.vim/after
+set compatible shortmess+=I t_Co=0
+silent! source ~/.exrc
diff --git a/vim/vimrc.stub.vim b/vim/vimrc.stub.vim
deleted file mode 100644
index 1d8d3d9a..00000000
--- a/vim/vimrc.stub.vim
+++ /dev/null
@@ -1,11 +0,0 @@
-" If we have non-tiny Vim version >=7, source real vimrc; this works because
-" tiny and/or ancient builds of Vim quietly ignore all code in :if blocks
-if v:version >= 700 && !&compatible
- runtime vimrc
- finish
-endif
-
-" Otherwise, prevent an old and/or tiny Vim from using any part of our
-" configuration, because parts of it will break
-set runtimepath-=~/.vim
-set runtimepath-=~/.vim/after