From 7cc8c94df33327faca1fb9bdbfa712016c0a0c2d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 18 Jun 2018 08:48:23 +1200 Subject: Correct a filetype.vim comment --- vim/filetype.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/filetype.vim b/vim/filetype.vim index 3cd2b203..80c93412 100644 --- a/vim/filetype.vim +++ b/vim/filetype.vim @@ -246,7 +246,7 @@ augroup filetypedetect \,?*.[1-9] \,*/man[1-9]*/?*.[1-9]* \ setfiletype nroff - " UNIX pass file + " UNIX password and shadow files autocmd BufNewFile,BufRead \ /etc/passwd \,/etc/passwd- -- cgit v1.2.3 From e050c970bfdbbdc65f9c6135ac021a10a8b8b168 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 18 Jun 2018 08:48:30 +1200 Subject: Add fallback log filetype --- vim/filetype.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vim/filetype.vim b/vim/filetype.vim index 80c93412..fdf75d59 100644 --- a/vim/filetype.vim +++ b/vim/filetype.vim @@ -458,7 +458,7 @@ augroup filetypedetect \,zshrc \ setfiletype zsh - " Generic text and config files, if no type assigned yet + " Generic text, config, and log files, if no type assigned yet autocmd BufNewFile,BufRead \ ?*.text \,?*.txt @@ -473,6 +473,10 @@ augroup filetypedetect \,?*.config \,/etc/* \ setfiletype config + autocmd BufNewFile,BufRead + \ */log/* + \,*.log + \ setf messages " Load any extra rules in ftdetect directories runtime! ftdetect/*.vim -- cgit v1.2.3 From b82351c91f4842b3bbc48fb310cb6bdf160a2235 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 19 Jun 2018 15:08:52 +1200 Subject: Rearrange filetype.vim final stanzas --- vim/filetype.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vim/filetype.vim b/vim/filetype.vim index fdf75d59..6c40dec1 100644 --- a/vim/filetype.vim +++ b/vim/filetype.vim @@ -458,6 +458,9 @@ augroup filetypedetect \,zshrc \ setfiletype zsh + " Load any extra rules in ftdetect directories + runtime! ftdetect/*.vim + " Generic text, config, and log files, if no type assigned yet autocmd BufNewFile,BufRead \ ?*.text @@ -478,9 +481,6 @@ augroup filetypedetect \,*.log \ setf messages - " Load any extra rules in ftdetect directories - runtime! ftdetect/*.vim - " Clumsy attempt at typing files in `sudo -e` if a filename hasn't already " been found; strip temporary extension and re-run autocmd BufNewFile,BufRead -- cgit v1.2.3 From 19fa3b0b57f2daf48d443a2d90b88bd3046f002f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 19 Jun 2018 16:12:09 +1200 Subject: Simplify syntax settings --- vim/vimrc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 69a05cd0..e56fdd84 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -24,9 +24,8 @@ endif " Options dependent on the syntax feature if has('syntax') && !has('g:syntax_on') - " Use syntax highlighting with 150 lines of context - silent! syntax enable - silent! syntax sync minlines=150 + " Use syntax highlighting + syntax enable " Opinionated; if the author is using color at all, it will probably be with " a dark background -- cgit v1.2.3 From a1b8cb8d2ef2c2b9967f40bd53609e77d08915e2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 19 Jun 2018 17:02:28 +1200 Subject: Move filetype print mapping to more logical place --- vim/vimrc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index e56fdd84..84c347c8 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -16,9 +16,11 @@ if has('eval') let g:maplocalleader = '_' endif -" Load filetype settings, including filetype plugins and indent settings +" Load filetype-specific plugins, indent settings, and syntax highlighting +" Bind \p to show filetype at a glance if has('autocmd') filetype plugin indent on + nnoremap p :set filetype? endif " Options dependent on the syntax feature @@ -157,9 +159,6 @@ nnoremap l :set list! list? set nonumber nnoremap n :set number! number? -" Bind \p to show filetype -nnoremap p :set filetype? - " Use all ancestors of current directory for :find if has('file_in_path') set path=** -- cgit v1.2.3 From 8ffc87ef5145b1ec76fd594938b257ea792236d7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 19 Jun 2018 17:03:03 +1200 Subject: Remove unneeded --- vim/vimrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/vimrc b/vim/vimrc index 84c347c8..decd756c 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -20,7 +20,7 @@ endif " Bind \p to show filetype at a glance if has('autocmd') filetype plugin indent on - nnoremap p :set filetype? + nnoremap p :set filetype? endif " Options dependent on the syntax feature -- cgit v1.2.3 From 059b40033e9041667a85be6bf18beda33b5dd20a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 19 Jun 2018 17:11:18 +1200 Subject: Remove some unneeded silencing --- vim/vimrc | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index decd756c..450e1317 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -63,8 +63,8 @@ if v:version >= 701 endif " Cycle back and forth through buffers. -nnoremap [b :bprevious -nnoremap ]b :bnext +nnoremap [b :bprevious +nnoremap ]b :bnext " Keep plenty of command and search history, because disk space is cheap set history=2000 @@ -89,9 +89,9 @@ endif " Current date and time insertion commands, requiring POSIX date(1) if has('unix') " \d: Local - nnoremap d :read !date + nnoremap d :read !date " \D: UTC - nnoremap D :read !date -u + nnoremap D :read !date -u endif " Start with blank comment strings rather than the old default; let the @@ -153,11 +153,11 @@ set shortmess+=x " [dos format] -> [dos] " Don't show whitespace characters or end-of-line characters visually by " default, but make \l toggle between them set nolist -nnoremap l :set list! list? +nnoremap l :set list! list? " Don't show line numbers by default, but \n toggles them set nonumber -nnoremap n :set number! number? +nnoremap n :set number! number? " Use all ancestors of current directory for :find if has('file_in_path') @@ -179,8 +179,8 @@ set nomodeline " I really like ZZ and ZQ, so I wrote a couple more mappings; ZW forces a " write of the current buffer, but doesn't quit, and ZA forces a write of all " buffers but doesn't quit -nnoremap ZW :write! -nnoremap ZA :wall! +nnoremap ZW :write! +nnoremap ZA :wall! " Don't assume a number with a leading zero is octal; it's far more likely a " zero-padded decimal, so increment and decrement with ^A and ^X on that basis @@ -193,7 +193,7 @@ if v:version >= 704 || v:version == 703 && has('patch541') endif " \f shows the current formatoptions at a glance -nnoremap f :setlocal formatoptions? +nnoremap f :setlocal formatoptions? " Match all forms of brackets in pairs (including angle brackets) set matchpairs+=<:> @@ -217,11 +217,11 @@ if has('extra_search') " Searching as I enter my pattern, \i toggles this set incsearch - nnoremap i :set incsearch! incsearch? + nnoremap i :set incsearch! incsearch? " Highlight search results, \h toggles this set hlsearch - nnoremap h :set hlsearch! hlsearch? + nnoremap h :set hlsearch! hlsearch? " Pressing ^L will clear highlighting until the next search-related " operation; quite good because the highlighting gets distracting after @@ -235,14 +235,14 @@ if has('spell') " Don't check spelling by default, but bind \s to toggle this set nospell - nnoremap s :setlocal spell! spell? + nnoremap s :setlocal spell! spell? " Use New Zealand English for spelling by default (it's almost identical " to British English), but bind \u to switch to US English and \z to " switch back set spelllang=en_nz - nnoremap u :setlocal spelllang=en_us spelllang? - nnoremap z :setlocal spelllang=en_nz spelllang? + nnoremap u :setlocal spelllang=en_us spelllang? + nnoremap z :setlocal spelllang=en_nz spelllang? endif @@ -363,7 +363,7 @@ endif " Don't wrap by default, but use \w to toggle it on or off quickly set nowrap -nnoremap w :set wrap! wrap? +nnoremap w :set wrap! wrap? " When wrapping text, if a line is so long that not all of it can be shown on " the screen, show as much as possible anyway; by default Vim fills the left @@ -445,20 +445,20 @@ nmap x StripTrailingWhitespace if has('user_commands') " \a: Reformat paragraphs to 'textwidth' on all insert or delete operations - nnoremap a :ToggleOptionFlagLocal formatoptions a + nnoremap a :ToggleOptionFlagLocal formatoptions a " \c: Reformat comments to 'textwidth' - nnoremap c :ToggleOptionFlagLocal formatoptions c + nnoremap c :ToggleOptionFlagLocal formatoptions c " \j: Delete comment leaders when joining lines - nnoremap j :ToggleOptionFlagLocal formatoptions j + nnoremap j :ToggleOptionFlagLocal formatoptions j " \t: Reformat non-comment text to 'textwidth' - nnoremap t :ToggleOptionFlagLocal formatoptions t + nnoremap t :ToggleOptionFlagLocal formatoptions t endif " Add the packaged version of matchit.vim included in the distribution, if " possible; plugin/macros.vim loads this for older Vims if has('packages') - silent! packadd! matchit + packadd! matchit endif " Source all .vim files from ~/.vim/config, which may override any of the -- cgit v1.2.3 From 29bd85016d16e3b48de35dc904b651f59bedda91 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 21:55:32 +1200 Subject: Refine colorscheme selection logic --- vim/vimrc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 450e1317..3ac53e2c 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -29,15 +29,17 @@ if has('syntax') && !has('g:syntax_on') " Use syntax highlighting syntax enable - " Opinionated; if the author is using color at all, it will probably be with - " a dark background - set background=dark - - " The 'sahara' colorscheme only works in the GUI or with 256 colors + " Use the 'sahara' colorscheme if using the GUI or if we have 256 colors if has('gui_running') || &t_Co >= 256 silent! colorscheme sahara endif + " If we couldn't use 'sahara', just flag a dark background (the author is + " almost certainly using one), and we'll use the default colorscheme + if !exists('g:colors_name') || g:colors_name != 'sahara' + set background=dark + endif + endif " Let me backspace over pretty much anything -- cgit v1.2.3 From 181a03de03d793922033a8362fdc04cffd09d21b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 21:57:54 +1200 Subject: Remove .vimrc 'backup', 'writebackup' settings 'backup' is off by default, and :help 'writebackup' recommends against disabling it: > WARNING: Switching this option off means that when Vim fails to write > your buffer correctly and then, for whatever reason, Vim exits, you > lose both the original file and what you were writing. Only reset > this option if your file system is almost full and it makes the write > fail (and make sure not to exit Vim until the write was successful). The auto_cache_dirs.vim plugin turns this on if it sensibly can, anyway. --- vim/vimrc | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 3ac53e2c..e348b602 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -48,13 +48,7 @@ set backspace+=indent " Spaces from 'audoindent' set backspace+=eol " Line breaks set backspace+=start " The start of current insertion -" Default to no backup files at all, in a way that even ancient/tiny Vims will -" understand; the auto_cache_dirs.vim plugin will take care of re-enabling -" this with a 'backupdir' setting -set nobackup -set nowritebackup - -" If backups are enabled, use a more explicit and familiar backup suffix +" If a plugin enables backups, use a more explicit and familiar backup suffix set backupext=.bak " Allow jumping between windows and tabs to find an open instance of a given -- cgit v1.2.3 From 6a26b3d67ddf8ccd097ae1fbf7e96b1f22b10880 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:12:27 +1200 Subject: Use case sensitivity explicit operator in .vimrc --- vim/vimrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/vimrc b/vim/vimrc index e348b602..35d8de82 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -36,7 +36,7 @@ if has('syntax') && !has('g:syntax_on') " If we couldn't use 'sahara', just flag a dark background (the author is " almost certainly using one), and we'll use the default colorscheme - if !exists('g:colors_name') || g:colors_name != 'sahara' + if !exists('g:colors_name') || g:colors_name !=# 'sahara' set background=dark endif -- cgit v1.2.3 From fba5153485bdc6b4ffc650f6da07c0b84abba7b4 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:12:57 +1200 Subject: Add after/ftplugin for gitcommit to quote with > I love the way this works when writing mail, and find myself missing it when writing Git commits that include block quotes. This is ported from ftplugin/mail.vim. --- vim/after/ftplugin/gitcommit/quote.vim | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 vim/after/ftplugin/gitcommit/quote.vim diff --git a/vim/after/ftplugin/gitcommit/quote.vim b/vim/after/ftplugin/gitcommit/quote.vim new file mode 100644 index 00000000..61fa0509 --- /dev/null +++ b/vim/after/ftplugin/gitcommit/quote.vim @@ -0,0 +1,25 @@ +" gitcommit/quote.vim: Make angle-bracket quote characters behave like they do +" in mail messages, inserting the comment leader automatically on new lines +" and auto-formatting them. + +" Don't load if running compatible or too old +if &compatible || v:version < 700 + finish +endif + +" Don't load if already loaded +if exists('b:did_ftplugin_gitcommit_quote') + finish +endif + +" Flag as loaded +let b:did_ftplugin_gitcommit_quote = 1 +let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:did_ftplugin_gitcommit_quote' + +" Use trailing whitespace to denote continued paragraph +setlocal comments+=n:> +setlocal formatoptions+=c +let b:undo_ftplugin = b:undo_ftplugin + \ . '|setlocal comments<' + \ . '|setlocal formatoptions<' -- cgit v1.2.3 From 9131bb9696b3ff669df20717b352fc7f12f72a29 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:15:35 +1200 Subject: Use a simpler test for colorscheme absence --- vim/vimrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/vimrc b/vim/vimrc index 35d8de82..d8a6b693 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -36,7 +36,7 @@ if has('syntax') && !has('g:syntax_on') " If we couldn't use 'sahara', just flag a dark background (the author is " almost certainly using one), and we'll use the default colorscheme - if !exists('g:colors_name') || g:colors_name !=# 'sahara' + if !exists('g:colors_name') set background=dark endif -- cgit v1.2.3 From e3614a46746695c99da07c84fad162ec4b3057eb Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:16:03 +1200 Subject: Remove .vimrc 'backupext' setting The default is fine, since any backups will be tucked away in a directory chosen by auto_cache_dirs.vim anyway, if possible. --- vim/vimrc | 3 --- 1 file changed, 3 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index d8a6b693..335db1c0 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -48,9 +48,6 @@ set backspace+=indent " Spaces from 'audoindent' set backspace+=eol " Line breaks set backspace+=start " The start of current insertion -" If a plugin enables backups, use a more explicit and familiar backup suffix -set backupext=.bak - " Allow jumping between windows and tabs to find an open instance of a given " buffer with :sbuffer. set switchbuf=useopen -- cgit v1.2.3 From 91c69750e01f898191063d30a6c2d12372581497 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:18:17 +1200 Subject: Remove .vimrc 'switchbuf' settings I never use it. --- vim/vimrc | 7 ------- 1 file changed, 7 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 335db1c0..ac886ed0 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -48,13 +48,6 @@ set backspace+=indent " Spaces from 'audoindent' set backspace+=eol " Line breaks set backspace+=start " The start of current insertion -" Allow jumping between windows and tabs to find an open instance of a given -" buffer with :sbuffer. -set switchbuf=useopen -if v:version >= 701 - set switchbuf+=usetab -endif - " Cycle back and forth through buffers. nnoremap [b :bprevious nnoremap ]b :bnext -- cgit v1.2.3 From 60ae46507ecbbda598b1ebcde4fac726263f5c39 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:19:00 +1200 Subject: Remove .vimrc 'history' setting I don't think I can actually remember an instance of having needed to recall beyond the 50th command or search pattern. --- vim/vimrc | 3 --- 1 file changed, 3 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index ac886ed0..bdcc51cb 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -52,9 +52,6 @@ set backspace+=start " The start of current insertion nnoremap [b :bprevious nnoremap ]b :bnext -" Keep plenty of command and search history, because disk space is cheap -set history=2000 - " Always tell me the number of lines changed by a command set report=0 -- cgit v1.2.3 From 2f79332726a3dd1307cd5824e4213aa579850629 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:23:24 +1200 Subject: Remove Vim 'showcmd' setting I don't actually look at the keys I'm entering that often, if ever. --- vim/vimrc | 3 --- 1 file changed, 3 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index bdcc51cb..5d951c62 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -61,9 +61,6 @@ if has('cmdline_info') " Show my current position in the status bar set ruler - " Show the keystrokes being entered in the screen - set showcmd - " Show the mode we're using if not normal mode (e.g. --INSERT--) set showmode -- cgit v1.2.3 From 65105753fc0dee372d0a106cc705ae92cb66a6d2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:23:52 +1200 Subject: Remove .vimrc 'showmode' setting It defaults to being on in Vim. --- vim/vimrc | 3 --- 1 file changed, 3 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 5d951c62..72d2ba3c 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -61,9 +61,6 @@ if has('cmdline_info') " Show my current position in the status bar set ruler - " Show the mode we're using if not normal mode (e.g. --INSERT--) - set showmode - endif " Current date and time insertion commands, requiring POSIX date(1) -- cgit v1.2.3 From d5c4e4d1b9947837d1978fde8d17906d96246a68 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:28:37 +1200 Subject: Tidy 'ruler' setting in .vimrc --- vim/vimrc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 72d2ba3c..a80c5737 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -55,12 +55,9 @@ nnoremap ]b :bnext " Always tell me the number of lines changed by a command set report=0 -" Command-line based features +" Show my current position in the status bar, default format is fine if has('cmdline_info') - - " Show my current position in the status bar set ruler - endif " Current date and time insertion commands, requiring POSIX date(1) -- cgit v1.2.3 From ea7aba37737c13244c542e2e79bf337365457a7b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:28:55 +1200 Subject: Remove 'complete' setting in .vimrc I nearly never use completion anyway, so best just to leave this out. --- vim/vimrc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index a80c5737..a836038f 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -72,10 +72,6 @@ endif " filetype handle it set comments= -" Don't try to complete strings from included files, just use the strings in -" the open buffers; I'll open the file if I want to complete from it -set complete-=i - " Configuration for the command completion feature; rather than merely cycling " through possible completions with Tab, show them above the command line if has('wildmenu') -- cgit v1.2.3 From 92c703ee68bf96015d31c143207007fda54a824c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:35:39 +1200 Subject: Simplify boolean toggle options in .vimrc 'list', 'number', and 'spell' all default to off with a .vimrc, so they don't need to be set and can just have the mapping. --- vim/vimrc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index a836038f..65a88dc4 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -120,13 +120,10 @@ set shortmess+=T " Truncate other message in midle if too long set shortmess+=w " written -> [w], appended -> [a] set shortmess+=x " [dos format] -> [dos] -" Don't show whitespace characters or end-of-line characters visually by -" default, but make \l toggle between them -set nolist +" \l toggles showing tab, end-of-line, and trailing whitespace nnoremap l :set list! list? -" Don't show line numbers by default, but \n toggles them -set nonumber +" \n toggles line numbers nnoremap n :set number! number? " Use all ancestors of current directory for :find @@ -203,8 +200,7 @@ endif " Configure spell checking features, if available if has('spell') - " Don't check spelling by default, but bind \s to toggle this - set nospell + " \s toggles spell checking nnoremap s :setlocal spell! spell? " Use New Zealand English for spelling by default (it's almost identical @@ -331,7 +327,7 @@ if has('windows') endif -" Don't wrap by default, but use \w to toggle it on or off quickly +" Don't wrap by default, but use \w to toggle it on or off set nowrap nnoremap w :set wrap! wrap? -- cgit v1.2.3 From f30bd44de4ed27defee1c1d764230d8bc2f28a89 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:38:22 +1200 Subject: Add '**' to Vim 'path' rather than replacing it --- vim/vimrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/vimrc b/vim/vimrc index 65a88dc4..ce1e88cf 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -128,7 +128,7 @@ nnoremap n :set number! number? " Use all ancestors of current directory for :find if has('file_in_path') - set path=** + set path+=** endif " If the Vim buffer for a file doesn't have any changes and Vim detects the -- cgit v1.2.3 From d00c2b6f4c49515e06514386c1d6941e85bfd6a3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:39:12 +1200 Subject: Remove 'autoread' and 'autowrite' .vimrc settings These seem like antipatterns, on reflection. --- vim/vimrc | 8 -------- 1 file changed, 8 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index ce1e88cf..449fbab1 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -131,14 +131,6 @@ if has('file_in_path') set path+=** endif -" If the Vim buffer for a file doesn't have any changes and Vim detects the -" file has been altered, quietly update it -set autoread - -" Save a file automatically if I change buffers or perform operations with the -" argument list; this is particularly helpful for me as I don't use 'hidden' -set autowrite - " Don't use modelines at all, they're apparently potential security problems " and I've never used them anyway set nomodeline -- cgit v1.2.3 From 753f0533711ca148992b5cc9e843510614822058 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:42:07 +1200 Subject: Remove 'scrolloff' and 'sidescrolloff' .vimrc set 'scrolloff' defaults to 0 anyway, and I don't often run into 'sidescrolloff' at all. --- vim/vimrc | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 449fbab1..aab44c87 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -154,7 +154,7 @@ endif " \f shows the current formatoptions at a glance nnoremap f :setlocal formatoptions? -" Match all forms of brackets in pairs (including angle brackets) +" Add angle brackets to pairs of characters to match set matchpairs+=<:> " Change and delete with C and D both cut off the remainder of the line from @@ -162,12 +162,6 @@ set matchpairs+=<:> " done with yy anyway); this fixes it so it only yanks the rest of the line nnoremap Y y$ -" Allow the cursor to get to the top or bottom of the screen before scrolling -" vertically, but set a reasonably wide gutter for scrolling horizontally; no -" particular reason, just suits me better -set scrolloff=0 -set sidescrolloff=16 - " Rebind in normal mode as a lazy scroll nnoremap -- cgit v1.2.3 From 323f11bcfb8814cce300777750db335be342723f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:45:09 +1200 Subject: Simplify .vim 'paste' and 'pastetoggle' settings 'paste' is off by default, obviously, and a terser comment can describe 'pastetoggle'. --- vim/vimrc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index aab44c87..2ac81c8c 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -211,11 +211,7 @@ vnoremap & :&& " this with a 'directory' setting set noswapfile -" Start paste mode with F10 to prevent console Vim from confusing a swathe of -" pre-formatted pasted text with actual keyboard input, and thereby attempting -" to indent it inappropriately. If unimpaired.vim is available, it's generally -" nicer to use yo or yO. -set nopaste +" Press F10 to stop console Vim from formatting pasted text set pastetoggle= " Don't bother about checking whether Escape is being used as a means to enter -- cgit v1.2.3 From 22e7edc534dfb05d3914facd262b1dcfd651b4cb Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:47:15 +1200 Subject: Reduce 'formatoptions' flag toggling to just 'a' The other three that I've removed are almost certainly better in filetype plugins. --- vim/vimrc | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 2ac81c8c..2f2b8a52 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -388,19 +388,10 @@ nmap b CopyLinebreakToggle " \x strips trailing whitespace via a custom plugin nmap x StripTrailingWhitespace -" Use toggle_option_flag.vim plugin to bind quick toggle actions for some -" 'formatoptions' flags +" \a toggles 'f' flag in 'formatoptions' to reformat paragraphs to 'textwidth' +" on all insert or delete operations if has('user_commands') - - " \a: Reformat paragraphs to 'textwidth' on all insert or delete operations nnoremap a :ToggleOptionFlagLocal formatoptions a - " \c: Reformat comments to 'textwidth' - nnoremap c :ToggleOptionFlagLocal formatoptions c - " \j: Delete comment leaders when joining lines - nnoremap j :ToggleOptionFlagLocal formatoptions j - " \t: Reformat non-comment text to 'textwidth' - nnoremap t :ToggleOptionFlagLocal formatoptions t - endif " Add the packaged version of matchit.vim included in the distribution, if -- cgit v1.2.3 From 5e3de51622b610e0380b4c6941a5eb68e513ca41 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:52:17 +1200 Subject: Remove 'ttyfast' setting It defaults to on based on the terminal type, which seems pretty sensible, and seems to work fine with my tmux settings. --- vim/vimrc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 2f2b8a52..27276b8a 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -225,10 +225,6 @@ endif " completes set lazyredraw -" Improve redrawing smoothness by assuming that my terminal is reasonably -" fast -set ttyfast - " Never use any kind of bell, visual or not set visualbell t_vb= -- cgit v1.2.3 From eca768bdd712b752df5e0b93c59b55ae8f222b36 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:55:26 +1200 Subject: Remove 'timeout' and related Vim settings More over-setting, for a problem I'm not sure I ever actually had. --- vim/vimrc | 9 --------- 1 file changed, 9 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 27276b8a..5e149878 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -228,15 +228,6 @@ set lazyredraw " Never use any kind of bell, visual or not set visualbell t_vb= -" Require less than one second between keys for mappings to work correctly -set timeout -set timeoutlen=1000 - -" Require less than a twentieth of a second between keys for key codes to work -" correctly; I don't use Escape as a meta key anyway -set ttimeout -set ttimeoutlen=50 - " Rebind Ctrl-C in insert mode to undo the current insert operation inoremap u -- cgit v1.2.3 From a2291ed6c366d1d4af7579a6da6cc3c3025f28a1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:57:47 +1200 Subject: Remove 'esckeys' .vimrc setting I don't think this has ever actually caused or fixed a problem. --- vim/vimrc | 6 ------ 1 file changed, 6 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 5e149878..874159b9 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -214,12 +214,6 @@ set noswapfile " Press F10 to stop console Vim from formatting pasted text set pastetoggle= -" Don't bother about checking whether Escape is being used as a means to enter -" a Meta-key combination, just register Escape immediately -if exists('+esckeys') - set noesckeys -endif - " Don't bother drawing the screen while executing macros or other automated or " scripted processes, just draw the screen as it is when the operation " completes -- cgit v1.2.3 From 98f8b4cdef2b20b8d6505a02312e6cb523897163 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 22:59:30 +1200 Subject: Remove unnecessary 'undofile' settings On Unix, 'undolevels' defaults to 1000, and 'undofile' defaults to off. --- vim/vimrc | 9 --------- 1 file changed, 9 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 874159b9..b5a84d59 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -225,15 +225,6 @@ set visualbell t_vb= " Rebind Ctrl-C in insert mode to undo the current insert operation inoremap u -" Keep screeds of undo history -set undolevels=2000 - -" 'undodir' and 'undofile' settings will be taken care of by the -" auto_cache_dirs.vim plugin if applicable/possible -if has('persistent_undo') - set noundofile -endif - " When in visual block mode, let me move the cursor anywhere in the buffer; " don't restrict me only to regions with text if has('virtualedit') -- cgit v1.2.3 From 10a49511325c57bbc5e08ce4d550a68b261e2c29 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 23:12:00 +1200 Subject: Use more idiomatic `if 1` in .vimrc These blocks are to exclude vim-tiny from trying to run :let commands, which it can't do; the usual way this seems to be turned off is checking the value "1", rather than the 'eval' feature. --- vim/vimrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index b5a84d59..49f1194b 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -11,7 +11,7 @@ if has('multi_byte') endif " Use different keys for global and local leaders -if has('eval') +if 1 let g:mapleader = '\' let g:maplocalleader = '_' endif @@ -321,7 +321,7 @@ endif " Disable most core plugin stuff that I don't use; after/plugin/dist.vim " clears these variables later -if has('eval') +if 1 " 2html.vim is often useful, so keep that " matchparen.vim I use constantly -- cgit v1.2.3 From ac37f00a6b1ed6821eb30657b8dcf235f473c08d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 23:13:11 +1200 Subject: Restructure indent settings in .vimrc --- vim/vimrc | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 49f1194b..d2ae653a 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -231,22 +231,12 @@ if has('virtualedit') set virtualedit+=block endif -" Adopt the indent of the last line on new lines -set autoindent - -" Use spaces instead of tabs -set expandtab - -" Indent with four spaces when an indent operation is used -set shiftwidth=4 - -" Insert four spaces when Tab is pressed -set softtabstop=4 - -" When indenting lines with < or >, round the indent to a multiple of -" 'shiftwidth', so even if the line is indented by one space it will indent -" up to 4 and down to 0, for example -set shiftround +" The all-important default indent settings; filetypes to tweak +set autoindent " Use indent of previous line on new lines +set expandtab " Use spaces instead of tabs +set shiftround " Round indenting to multiples of 4 +set shiftwidth=4 " Indent with four spaces +set softtabstop=4 " Insert four spaces for a Tab press " Don't join lines with two spaces at the end of sentences; I don't two-space, " despite the noble Steve Losh's exhortations -- cgit v1.2.3 From 2458c23fe9262f465706c64d9d6f4739ed31d034 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 23:13:44 +1200 Subject: Remove unneeded 'laststatus' .vimrc set This is the default anyway. --- vim/vimrc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index d2ae653a..e35ce7b3 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -245,10 +245,6 @@ set nojoinspaces " Configuration for window features if has('windows') - " Show the status in a distinct bar above the command line only if there's - " more than one window on the screen or in the current tab - set laststatus=1 - " Don't resize windows we're not splitting (Tmux-like; think Mondrian) set noequalalways -- cgit v1.2.3 From d24bbf1ddcb2c6beca06ae192cbac2878490ef89 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 23:14:37 +1200 Subject: Correct "Tmux" to "tmux" in a comment. --- vim/vimrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/vimrc b/vim/vimrc index e35ce7b3..14c019a4 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -245,7 +245,7 @@ set nojoinspaces " Configuration for window features if has('windows') - " Don't resize windows we're not splitting (Tmux-like; think Mondrian) + " Don't resize windows we're not splitting (tmux-like; think Mondrian) set noequalalways " New split windows appear below or to the right of the existing window, -- cgit v1.2.3 From ce4148e6c5a15f7cc00684971896eacbbbf19045 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 23:14:47 +1200 Subject: Remove unneeded 'showtabline' .vimrc setting This is the default anyway. --- vim/vimrc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 14c019a4..0fd8c192 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -255,11 +255,6 @@ if has('windows') set splitright endif - " Only show the tab bar if there's more than one tab - if exists('+showtabline') - set showtabline=1 - endif - " Get rid of visually noisy folding characters if has('folding') let &fillchars = 'diff: ,fold: ,vert: ' -- cgit v1.2.3 From 1c5dec8486ad0cbd2d3547b8f32b44d59b1765fd Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 20 Jun 2018 23:56:16 +1200 Subject: Reorder .vimrc file Put options up the top, starting with core ones and then feature-dependent ones, in alphabetical order, then mappings, then digraphs, then plugin-specific settings. --- vim/vimrc | 372 ++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 178 insertions(+), 194 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 0fd8c192..721e6af6 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -10,17 +10,9 @@ if has('multi_byte') scriptencoding utf-8 endif -" Use different keys for global and local leaders -if 1 - let g:mapleader = '\' - let g:maplocalleader = '_' -endif - " Load filetype-specific plugins, indent settings, and syntax highlighting -" Bind \p to show filetype at a glance if has('autocmd') filetype plugin indent on - nnoremap p :set filetype? endif " Options dependent on the syntax feature @@ -42,67 +34,62 @@ if has('syntax') && !has('g:syntax_on') endif +" The all-important default indent settings; filetypes to tweak +set autoindent " Use indent of previous line on new lines +set expandtab " Use spaces instead of tabs +set shiftround " Round indenting to multiples of 4 +set shiftwidth=4 " Indent with four spaces +set softtabstop=4 " Insert four spaces for a Tab press + " Let me backspace over pretty much anything set backspace= set backspace+=indent " Spaces from 'audoindent' set backspace+=eol " Line breaks set backspace+=start " The start of current insertion -" Cycle back and forth through buffers. -nnoremap [b :bprevious -nnoremap ]b :bnext - -" Always tell me the number of lines changed by a command -set report=0 +" Start with blank comment strings rather than the old default; let the +" filetype handle it +set comments= -" Show my current position in the status bar, default format is fine -if has('cmdline_info') - set ruler -endif +" When wrapping text, if a line is so long that not all of it can be shown on +" the screen, show as much as possible anyway; by default Vim fills the left +" column with @ symbols instead, which I don't find very helpful +set display=lastline -" Current date and time insertion commands, requiring POSIX date(1) -if has('unix') - " \d: Local - nnoremap d :read !date - " \D: UTC - nnoremap D :read !date -u +" Try to set the 'j' flag for 'formatoptions', to automatically delete comment +" leaders when joining lines, if supported +if v:version >= 704 || v:version == 703 && has('patch541') + set formatoptions+=j endif -" Start with blank comment strings rather than the old default; let the -" filetype handle it -set comments= +" Don't join lines with two spaces at the end of sentences; I don't two-space, +" despite the noble Steve Losh's exhortations +set nojoinspaces -" Configuration for the command completion feature; rather than merely cycling -" through possible completions with Tab, show them above the command line -if has('wildmenu') +" Define list characters +set listchars+=extends:> " Unwrapped text to screen right +set listchars+=precedes:< " Unwrapped text to screen left +set listchars+=tab:>- " Tab characters, preserve width +set listchars+=trail:_ " Trailing spaces - " Use the wild menu, both completing and showing all possible completions - " with a single Tab press, just as I've configured Bash to do - set wildmenu - set wildmode=list:longest +" Add angle brackets to pairs of characters to match +set matchpairs+=<:> - " Don't complete certain files that I'm not likely to want to manipulate - " from within Vim: - if has('wildignore') - set wildignore+=*.a,*.o - set wildignore+=*.bmp,*.gif,*.ico,*.jpg,*.png - set wildignore+=.DS_Store,.git,.hg,.svn - set wildignore+=*~,*.swp,*.tmp - endif +" Don't use modelines at all, they're apparently potential security problems +" and I've never used them anyway +set nomodeline - " Complete files without case sensitivity, if the option is available - if exists('+wildignorecase') - set wildignorecase - endif +" Don't assume a number with a leading zero is octal; it's far more likely a +" zero-padded decimal, so increment and decrement with ^A and ^X on that basis +set nrformats-=octal -endif +" Always tell me the number of lines changed by a command +set report=0 -" A few very important custom digraphs -if has('digraphs') - digraph ./ 8230 " Ellipsis (HORIZONTAL ELLIPSIS U+2026) - digraph %% 8984 " Mac command key (PLACE OF INTEREST SIGN U+2318) - digraph 8: 9731 " Snowman (SNOWMAN U+2603) -endif +" Don't bother drawing the screen while executing macros or other automated or +" scripted processes, just draw the screen as it is when the operation +" completes +set lazyredraw " Set up short message settings set shortmess= @@ -120,127 +107,84 @@ set shortmess+=T " Truncate other message in midle if too long set shortmess+=w " written -> [w], appended -> [a] set shortmess+=x " [dos format] -> [dos] -" \l toggles showing tab, end-of-line, and trailing whitespace -nnoremap l :set list! list? - -" \n toggles line numbers -nnoremap n :set number! number? - -" Use all ancestors of current directory for :find -if has('file_in_path') - set path+=** -endif - -" Don't use modelines at all, they're apparently potential security problems -" and I've never used them anyway -set nomodeline +" Default to no swap files at all, in a way that even ancient/tiny Vims will +" understand; the auto_cache_dirs.vim plugin will take care of re-enabling +" this with a 'directory' setting +set noswapfile -" I really like ZZ and ZQ, so I wrote a couple more mappings; ZW forces a -" write of the current buffer, but doesn't quit, and ZA forces a write of all -" buffers but doesn't quit -nnoremap ZW :write! -nnoremap ZA :wall! +" Never use any kind of bell, visual or not +set visualbell t_vb= -" Don't assume a number with a leading zero is octal; it's far more likely a -" zero-padded decimal, so increment and decrement with ^A and ^X on that basis -set nrformats-=octal +" Don't wrap by default, but use \w to toggle it on or off +set nowrap -" Try to set the 'j' flag for 'formatoptions', to automatically delete comment -" leaders when joining lines, if supported -if v:version >= 704 || v:version == 703 && has('patch541') - set formatoptions+=j +" Show my current position in the status bar, default format is fine +if has('cmdline_info') + set ruler endif -" \f shows the current formatoptions at a glance -nnoremap f :setlocal formatoptions? - -" Add angle brackets to pairs of characters to match -set matchpairs+=<:> - -" Change and delete with C and D both cut off the remainder of the line from -" the cursor, but Y yanks the whole line, which is inconsistent (and can be -" done with yy anyway); this fixes it so it only yanks the rest of the line -nnoremap Y y$ +" Highlight settings for search, if available +if has('extra_search') + set incsearch " Show matches as I type + set hlsearch " Highlight completed searches +endif -" Rebind in normal mode as a lazy scroll -nnoremap +" Use all ancestors of current directory for :find +if has('file_in_path') + set path+=** +endif -" Some special settings for searching, if available -if has('extra_search') +" Line break settings and mappings +if has('linebreak') - " Searching as I enter my pattern, \i toggles this - set incsearch - nnoremap i :set incsearch! incsearch? + " Break lines at word boundaries if possible + set linebreak - " Highlight search results, \h toggles this - set hlsearch - nnoremap h :set hlsearch! hlsearch? + " Precede continued lines with '...' + set showbreak=... - " Pressing ^L will clear highlighting until the next search-related - " operation; quite good because the highlighting gets distracting after - " you've found what you wanted - nnoremap :nohlsearch + " If we have the option, indent wrapped lines as much as the first line + if exists('+breakindent') + set breakindent + endif endif -" Configure spell checking features, if available +" Use NZ english by default if has('spell') - - " \s toggles spell checking - nnoremap s :setlocal spell! spell? - - " Use New Zealand English for spelling by default (it's almost identical - " to British English), but bind \u to switch to US English and \z to - " switch back set spelllang=en_nz - nnoremap u :setlocal spelllang=en_us spelllang? - nnoremap z :setlocal spelllang=en_nz spelllang? - endif -" Preserve the flags for a pattern when repeating a substitution with &; I -" don't really understand why this isn't a default, but there it is -nnoremap & :&& - -" Same again for visual mode; we use vnoremap rather than xnoremap to stay -" compatible with old Vims without doing :execute dances -vnoremap & :&& - -" Default to no swap files at all, in a way that even ancient/tiny Vims will -" understand; the auto_cache_dirs.vim plugin will take care of re-enabling -" this with a 'directory' setting -set noswapfile - -" Press F10 to stop console Vim from formatting pasted text -set pastetoggle= - -" Don't bother drawing the screen while executing macros or other automated or -" scripted processes, just draw the screen as it is when the operation -" completes -set lazyredraw - -" Never use any kind of bell, visual or not -set visualbell t_vb= - -" Rebind Ctrl-C in insert mode to undo the current insert operation -inoremap u - " When in visual block mode, let me move the cursor anywhere in the buffer; " don't restrict me only to regions with text if has('virtualedit') set virtualedit+=block endif -" The all-important default indent settings; filetypes to tweak -set autoindent " Use indent of previous line on new lines -set expandtab " Use spaces instead of tabs -set shiftround " Round indenting to multiples of 4 -set shiftwidth=4 " Indent with four spaces -set softtabstop=4 " Insert four spaces for a Tab press +" Configuration for the command completion feature; rather than merely cycling +" through possible completions with Tab, show them above the command line +if has('wildmenu') -" Don't join lines with two spaces at the end of sentences; I don't two-space, -" despite the noble Steve Losh's exhortations -set nojoinspaces + " Use the wild menu, both completing and showing all possible completions + " with a single Tab press, just as I've configured Bash to do + set wildmenu + set wildmode=list:longest + + " Don't complete certain files that I'm not likely to want to manipulate + " from within Vim: + if has('wildignore') + set wildignore+=*.a,*.o + set wildignore+=*.bmp,*.gif,*.ico,*.jpg,*.png + set wildignore+=.DS_Store,.git,.hg,.svn + set wildignore+=*~,*.swp,*.tmp + endif + + " Complete files without case sensitivity, if the option is available + if exists('+wildignorecase') + set wildignorecase + endif + +endif " Configuration for window features if has('windows') @@ -262,20 +206,33 @@ if has('windows') endif -" Don't wrap by default, but use \w to toggle it on or off -set nowrap -nnoremap w :set wrap! wrap? +" Rebind Ctrl-C in insert mode to undo the current insert operation +inoremap u -" When wrapping text, if a line is so long that not all of it can be shown on -" the screen, show as much as possible anyway; by default Vim fills the left -" column with @ symbols instead, which I don't find very helpful -set display=lastline +" Rebind in normal mode as a lazy scroll +nnoremap -" Define list characters -set listchars+=extends:> " Unwrapped text to screen right -set listchars+=precedes:< " Unwrapped text to screen left -set listchars+=tab:>- " Tab characters, preserve width -set listchars+=trail:_ " Trailing spaces +" Preserve the flags for a pattern when repeating a substitution with & +nnoremap & :&& +vnoremap & :&& + +" Pressing ^L will clear highlighting until the next search-related operation +nnoremap :nohlsearch + +" Cycle through things with unimpaired.vim-style bindings: +" Buffers +nnoremap [b :bprevious +nnoremap ]b :bnext +" Quicklist items (more often :helpgrep results) +nnoremap [c :cprevious +nnoremap ]c :cnext +" Location list items +nnoremap [l :lprevious +nnoremap ]l :lnext + +" Insert blank lines above and below via my custom unimpaired.vim rip +nmap [ PutBlankLinesAbove +nmap ] PutBlankLinesBelow " Swap the j/gj and k/gk command pairs so that we move by screen row, not " buffer line, with j/k @@ -284,20 +241,69 @@ nnoremap k gk nnoremap gj j nnoremap gk k -" Line break settings and mappings -if has('linebreak') +" Change and delete with C and D both cut off the remainder of the line from +" the cursor, but Y yanks the whole line, which is inconsistent (and can be +" done with yy anyway); this fixes it so it only yanks the rest of the line +nnoremap Y y$ - " Break lines at word boundaries if possible - set linebreak +" ZW does an unconditional write for this buffer +nnoremap ZW :write! +" ZA does an unconditional write for all buffers +nnoremap ZA :wall! - " Precede continued lines with '...' - set showbreak=... +" Use different keys for global and local leaders +if 1 + let g:mapleader = '\' + let g:maplocalleader = '_' +endif - " If we have the option, indent wrapped lines as much as the first line - if exists('+breakindent') - set breakindent - endif +" \a toggles 'formatoptions' 'a' flag using a plugin +nnoremap a :ToggleOptionFlagLocal formatoptions a +" \b toggles copy-pasteable linebreak settings +nmap b CopyLinebreakToggle +" Current date and time insertion commands, requiring POSIX date(1) +if has('unix') + " \d: Local date + nnoremap d :read !date + " \D: UTC + nnoremap D :read !date -u +endif +" \f shows the current 'formatoptions' at a glance +nnoremap f :set formatoptions? +" \h toggles highlighting search results +nnoremap h :set hlsearch! hlsearch? +" \i toggles showing matches as I enter my pattern +nnoremap i :set incsearch! incsearch? +" \l toggles showing tab, end-of-line, and trailing whitespace +nnoremap l :set list! list? +" \n toggles line numbers +nnoremap n :set number! number? +" \p toggles paste mode +set pastetoggle=p +" \s toggles spell checking +nnoremap s :setlocal spell! spell? +" \t shows current filetype +nnoremap t :set filetype? +" \u sets US English spelling +nnoremap u :setlocal spelllang=en_us spelllang? +" \w toggles wrapping +nnoremap w :set wrap! wrap? +" \x strips trailing whitespace via a custom plugin +nmap x StripTrailingWhitespace +" \z sets NZ English spelling +nnoremap z :setlocal spelllang=en_nz spelllang? +" Add the packaged version of matchit.vim included in the distribution, if +" possible; plugin/macros.vim loads this for older Vims +if has('packages') + packadd! matchit +endif + +" A few very important custom digraphs +if has('digraphs') + digraph ./ 8230 " Ellipsis (HORIZONTAL ELLIPSIS U+2026) + digraph %% 8984 " Mac command key (PLACE OF INTEREST SIGN U+2318) + digraph 8: 9731 " Snowman (SNOWMAN U+2603) endif " Disable most core plugin stuff that I don't use; after/plugin/dist.vim @@ -331,28 +337,6 @@ if 1 endif -" Insert blank lines above and below via my custom unimpaired.vim rip -nmap [ PutBlankLinesAbove -nmap ] PutBlankLinesBelow - -" \b toggles copy-pasteable linebreak settings -nmap b CopyLinebreakToggle - -" \x strips trailing whitespace via a custom plugin -nmap x StripTrailingWhitespace - -" \a toggles 'f' flag in 'formatoptions' to reformat paragraphs to 'textwidth' -" on all insert or delete operations -if has('user_commands') - nnoremap a :ToggleOptionFlagLocal formatoptions a -endif - -" Add the packaged version of matchit.vim included in the distribution, if -" possible; plugin/macros.vim loads this for older Vims -if has('packages') - packadd! matchit -endif - " Source all .vim files from ~/.vim/config, which may override any of the " above runtime! config/*.vim -- cgit v1.2.3 From a9c7118c20d184f331e6ab0011abc7a3dfe1ad94 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 21 Jun 2018 00:06:46 +1200 Subject: Use literal leaders in mappings --- vim/vimrc | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 721e6af6..d8a1d087 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -257,41 +257,45 @@ if 1 let g:maplocalleader = '_' endif +" Leader mappings below; we use a literal backslash rather than for +" the mappings here, because I want many of these even to work on tiny +" stripped-down Vims like Debian's. The settings above are for plugins. + " \a toggles 'formatoptions' 'a' flag using a plugin -nnoremap a :ToggleOptionFlagLocal formatoptions a +nnoremap \a :ToggleOptionFlagLocal formatoptions a " \b toggles copy-pasteable linebreak settings -nmap b CopyLinebreakToggle +nmap \b CopyLinebreakToggle " Current date and time insertion commands, requiring POSIX date(1) if has('unix') " \d: Local date - nnoremap d :read !date + nnoremap \d :read !date " \D: UTC - nnoremap D :read !date -u + nnoremap \D :read !date -u endif " \f shows the current 'formatoptions' at a glance -nnoremap f :set formatoptions? +nnoremap \f :set formatoptions? " \h toggles highlighting search results -nnoremap h :set hlsearch! hlsearch? +nnoremap \h :set hlsearch! hlsearch? " \i toggles showing matches as I enter my pattern -nnoremap i :set incsearch! incsearch? +nnoremap \i :set incsearch! incsearch? " \l toggles showing tab, end-of-line, and trailing whitespace -nnoremap l :set list! list? +nnoremap \l :set list! list? " \n toggles line numbers -nnoremap n :set number! number? +nnoremap \n :set number! number? " \p toggles paste mode -set pastetoggle=p +nnoremap \p :set paste! paste? " \s toggles spell checking -nnoremap s :setlocal spell! spell? +nnoremap \s :setlocal spell! spell? " \t shows current filetype -nnoremap t :set filetype? +nnoremap \t :set filetype? " \u sets US English spelling -nnoremap u :setlocal spelllang=en_us spelllang? +nnoremap \u :setlocal spelllang=en_us spelllang? " \w toggles wrapping -nnoremap w :set wrap! wrap? +nnoremap \w :set wrap! wrap? " \x strips trailing whitespace via a custom plugin -nmap x StripTrailingWhitespace +nmap \x StripTrailingWhitespace " \z sets NZ English spelling -nnoremap z :setlocal spelllang=en_nz spelllang? +nnoremap \z :setlocal spelllang=en_nz spelllang? " Add the packaged version of matchit.vim included in the distribution, if " possible; plugin/macros.vim loads this for older Vims -- cgit v1.2.3 From 02f55116721a31118f202c21af5913c6b50e39ab Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 21 Jun 2018 00:18:15 +1200 Subject: Greatly expand 'wildignore' This probably needs to be a little plugin. --- vim/vimrc | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index d8a1d087..99414e3c 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -171,12 +171,33 @@ if has('wildmenu') set wildmode=list:longest " Don't complete certain files that I'm not likely to want to manipulate - " from within Vim: + " from within Vim if has('wildignore') + + " Archives + set wildignore+=*.7z,*.bz2,*.gz,*.rar,*.tar,*.xz,*.zip + set wildignore+=*.7Z,*.BZ2,*.GZ,*.RAR,*.TAR,*.XZ,*.ZIP + " Binary + set wildignore+=*.bin,*.iso + set wildignore+=*.BIN,*.ISO + " Documents + set wildignore+=*.djvu,*.pdf,*.xls,*.xlsx + set wildignore+=*.DJVU,*.PDF,*.XLS,*.XLSX + " Images + set wildignore+=*.bmp,*.gif,*.ico,*.jpeg,*.jpg,*.png,*.xcf + set wildignore+=*.BMP,*.GIF,*.ICO,*.JPEG,*.JPG,*.PNG,*.XCF + " Mac OS X junk + set wildignore+=.DS_Store + " Media + set wildignore+=*.gifv,*.mid,*.m4a,*.mp3,*.mp4,*.ogg,*.opus,*.ogv,*.webm + set wildignore+=*.GIFV,*.MID,*.M4A,*.MP3,*.MP4,*.OGG,*.OPUS,*.OGV,*.WEBM + " Object formats set wildignore+=*.a,*.o - set wildignore+=*.bmp,*.gif,*.ico,*.jpg,*.png - set wildignore+=.DS_Store,.git,.hg,.svn - set wildignore+=*~,*.swp,*.tmp + " Version control + set wildignore+=.git,.hg,.svn, + " Vim metadata + set wildignore+=*~,*.swp + endif " Complete files without case sensitivity, if the option is available -- cgit v1.2.3 From 437532a0472fe8bc73b493ef766ce437eefa7698 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 21 Jun 2018 08:59:59 +1200 Subject: Remove 'wildignore' settings Changed my mind; they're too bulky for this file. They would probably be better in a plugin file if at all. --- vim/vimrc | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 99414e3c..687029b2 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -170,36 +170,6 @@ if has('wildmenu') set wildmenu set wildmode=list:longest - " Don't complete certain files that I'm not likely to want to manipulate - " from within Vim - if has('wildignore') - - " Archives - set wildignore+=*.7z,*.bz2,*.gz,*.rar,*.tar,*.xz,*.zip - set wildignore+=*.7Z,*.BZ2,*.GZ,*.RAR,*.TAR,*.XZ,*.ZIP - " Binary - set wildignore+=*.bin,*.iso - set wildignore+=*.BIN,*.ISO - " Documents - set wildignore+=*.djvu,*.pdf,*.xls,*.xlsx - set wildignore+=*.DJVU,*.PDF,*.XLS,*.XLSX - " Images - set wildignore+=*.bmp,*.gif,*.ico,*.jpeg,*.jpg,*.png,*.xcf - set wildignore+=*.BMP,*.GIF,*.ICO,*.JPEG,*.JPG,*.PNG,*.XCF - " Mac OS X junk - set wildignore+=.DS_Store - " Media - set wildignore+=*.gifv,*.mid,*.m4a,*.mp3,*.mp4,*.ogg,*.opus,*.ogv,*.webm - set wildignore+=*.GIFV,*.MID,*.M4A,*.MP3,*.MP4,*.OGG,*.OPUS,*.OGV,*.WEBM - " Object formats - set wildignore+=*.a,*.o - " Version control - set wildignore+=.git,.hg,.svn, - " Vim metadata - set wildignore+=*~,*.swp - - endif - " Complete files without case sensitivity, if the option is available if exists('+wildignorecase') set wildignorecase -- cgit v1.2.3 From 2295c22d8d7d663b13cba2fb4267518c75fcb895 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 21 Jun 2018 09:00:29 +1200 Subject: Add the "jetpack" buffer jump binding --- vim/vimrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vim/vimrc b/vim/vimrc index 687029b2..eb4a9091 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -269,6 +269,8 @@ nnoremap \f :set formatoptions? nnoremap \h :set hlsearch! hlsearch? " \i toggles showing matches as I enter my pattern nnoremap \i :set incsearch! incsearch? +" \j jumps to buffers (jetpack) +nnoremap \j :ls:buffer " \l toggles showing tab, end-of-line, and trailing whitespace nnoremap \l :set list! list? " \n toggles line numbers -- cgit v1.2.3 From 5584efb6f76ff908404bc36552ca2f6854679c1c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 21 Jun 2018 09:01:34 +1200 Subject: Add .vimrc reload binding --- vim/vimrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vim/vimrc b/vim/vimrc index eb4a9091..4199412e 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -277,6 +277,8 @@ nnoremap \l :set list! list? nnoremap \n :set number! number? " \p toggles paste mode nnoremap \p :set paste! paste? +" \r reloads .vimrc +nnoremap \r :source $MYVIMRC " \s toggles spell checking nnoremap \s :setlocal spell! spell? " \t shows current filetype -- cgit v1.2.3 From e9b47ddd71ab97c2ca608d26e10eb3d818e68cc6 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 21 Jun 2018 10:07:55 +1200 Subject: Restore 'esckeys' setting I remember now; otherwise things hang at the end of insert mode, which is a bit rubbish. --- vim/vimrc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vim/vimrc b/vim/vimrc index 4199412e..da1d1137 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -56,6 +56,9 @@ set comments= " column with @ symbols instead, which I don't find very helpful set display=lastline +" Don't wait to see if Escape in insert mode precedes a key for an Alt binding +set noesckeys + " Try to set the 'j' flag for 'formatoptions', to automatically delete comment " leaders when joining lines, if supported if v:version >= 704 || v:version == 703 && has('patch541') -- cgit v1.2.3 From ef6cdc39da392964df2a55ab183d20c0eeed1aef Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 21 Jun 2018 10:09:58 +1200 Subject: Add new vim_paste_open plugin and needed bindings --- .gitmodules | 3 +++ vim/bundle/paste_open | 1 + vim/vimrc | 3 +++ 3 files changed, 7 insertions(+) create mode 160000 vim/bundle/paste_open diff --git a/.gitmodules b/.gitmodules index e8e15892..30a58edc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -17,6 +17,9 @@ [submodule "vim/bundle/markdown_autoformat"] path = vim/bundle/markdown_autoformat url = https://sanctum.geek.nz/code/vim-markdown-autoformat.git +[submodule "vim/bundle/paste_open"] + path = vim/bundle/paste_open + url = https://sanctum.geek.nz/code/vim-paste-open.git [submodule "vim/bundle/put_blank_lines"] path = vim/bundle/put_blank_lines url = https://sanctum.geek.nz/code/vim-put-blank-lines.git diff --git a/vim/bundle/paste_open b/vim/bundle/paste_open new file mode 160000 index 00000000..6cfb284c --- /dev/null +++ b/vim/bundle/paste_open @@ -0,0 +1 @@ +Subproject commit 6cfb284c64a562e56f97282341614e67ca9565a1 diff --git a/vim/vimrc b/vim/vimrc index da1d1137..6431bd54 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -278,6 +278,9 @@ nnoremap \j :ls:buffer nnoremap \l :set list! list? " \n toggles line numbers nnoremap \n :set number! number? +" \o and \O open 'pasted insert' lines +nmap \o PasteOpenBelow +nmap \O PasteOpenAbove " \p toggles paste mode nnoremap \p :set paste! paste? " \r reloads .vimrc -- cgit v1.2.3 From 5bb43701428293eacae82604e9bbdfae671910dd Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 21 Jun 2018 10:18:37 +1200 Subject: Update auto_cache_dirs.vim plugin --- vim/bundle/auto_cache_dirs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/auto_cache_dirs b/vim/bundle/auto_cache_dirs index fc1853e7..c9560602 160000 --- a/vim/bundle/auto_cache_dirs +++ b/vim/bundle/auto_cache_dirs @@ -1 +1 @@ -Subproject commit fc1853e7cdda432e9e91b1352038e3cfe591e9d7 +Subproject commit c95606022488f019fa6c207012b38ef598b5f34a -- cgit v1.2.3 From 8f04e6d7862360e275c1efe4279f15d7f746cf64 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 21 Jun 2018 10:21:09 +1200 Subject: Update paste_open.vim plugin --- vim/bundle/paste_open | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/paste_open b/vim/bundle/paste_open index 6cfb284c..8537d312 160000 --- a/vim/bundle/paste_open +++ b/vim/bundle/paste_open @@ -1 +1 @@ -Subproject commit 6cfb284c64a562e56f97282341614e67ca9565a1 +Subproject commit 8537d312627d4acff204c543927549dcbfeae8fc -- cgit v1.2.3 From 600741d26b07fa5e15a8998fef285d51cc80db0a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 21 Jun 2018 10:19:19 +1200 Subject: Bump VERSION --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 2cb5653f..c73e8a6d 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -tejr dotfiles v0.56.1 -Sun Jun 17 11:47:39 UTC 2018 +tejr dotfiles v0.57.0 +Wed Jun 20 22:19:12 UTC 2018 -- cgit v1.2.3