From c53b11072fc2de94b1bc6d13fb1c308b1002efc8 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 12 Nov 2017 23:30:58 +1300 Subject: Document each 'backspace' flag in Vim config --- vim/config/backspace.vim | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/vim/config/backspace.vim b/vim/config/backspace.vim index a4089a68..db842e12 100644 --- a/vim/config/backspace.vim +++ b/vim/config/backspace.vim @@ -1,3 +1,8 @@ -" Let me backspace over pretty much anything, even if it's not text I inserted -" in the current session -set backspace=indent,eol,start +" Let me backspace over pretty much anything +set backspace= +" Allow backspacing over autoindent +set backspace+=indent +" Allow backspacing over line breaks +set backspace+=eol +" Allow backspacing over the start of the insert operation +set backspace+=start -- cgit v1.2.3 From 4fc03c3970e9ccfcb6a792fed5b8c7d34e93da1e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 12 Nov 2017 23:31:27 +1300 Subject: Correct nonexistent 'wildmode' value in Vim config There is no such setting as "longest:list". What I meant was "list:longest". --- vim/config/completion.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/config/completion.vim b/vim/config/completion.vim index a8a5c201..566a3a7c 100644 --- a/vim/config/completion.vim +++ b/vim/config/completion.vim @@ -9,7 +9,7 @@ if has('wildmenu') " 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=longest:list + set wildmode=list:longest " Don't complete certain files that I'm not likely to want to manipulate " from within Vim: -- cgit v1.2.3 From c9cbeacdd2eb87200e7f43721adf3d61e804bde3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 12 Nov 2017 23:37:31 +1300 Subject: Use :set not :setlocal for 'hlsearch'/'incsearch' They don't have local analogues; they're global options. --- vim/config/search.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vim/config/search.vim b/vim/config/search.vim index 69f3f472..967146d4 100644 --- a/vim/config/search.vim +++ b/vim/config/search.vim @@ -5,13 +5,13 @@ if has('extra_search') set incsearch nnoremap \ i - \ :setlocal incsearch! incsearch? + \ :set incsearch! incsearch? " Highlight search results, \h toggles this set hlsearch nnoremap \ h - \ :setlocal hlsearch! hlsearch? + \ :set hlsearch! hlsearch? " Pressing ^L will clear highlighting until the next search-related " operation; quite good because the highlighting gets distracting after @@ -27,10 +27,10 @@ if has('extra_search') autocmd! autocmd InsertEnter \ * - \ setlocal nohlsearch + \ set nohlsearch autocmd InsertLeave \ * - \ setlocal hlsearch + \ set hlsearch augroup END endif -- cgit v1.2.3 From 03919f1c03f89e17c90e398a7eaceabb21f1268c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 12 Nov 2017 23:58:43 +1300 Subject: Separate g:loaded/&cp tests from feat tests Keeping the tests at the beginning of plugins on one line without continuations is needed to work around &cpo-=C. --- vim/plugin/auto_undodir.vim | 5 ++++- vim/plugin/big_file_options.vim | 5 ++++- vim/plugin/command_typos.vim | 5 ++++- vim/plugin/copy_linebreak.vim | 5 ++++- vim/plugin/mail_mutt.vim | 5 ++++- vim/plugin/toggle_option_flag.vim | 5 ++++- 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/vim/plugin/auto_undodir.vim b/vim/plugin/auto_undodir.vim index 9a686fb1..cf8d896a 100644 --- a/vim/plugin/auto_undodir.vim +++ b/vim/plugin/auto_undodir.vim @@ -5,7 +5,10 @@ " Author: Tom Ryder " License: Same as Vim itself " -if exists('g:loaded_auto_undodir') || &compatible || !has('persistent_undo') +if exists('g:loaded_auto_undodir') || &compatible + finish +endif +if !has('persistent_undo') finish endif let g:loaded_auto_undodir = 1 diff --git a/vim/plugin/big_file_options.vim b/vim/plugin/big_file_options.vim index cbbacc42..f7fa0281 100644 --- a/vim/plugin/big_file_options.vim +++ b/vim/plugin/big_file_options.vim @@ -5,7 +5,10 @@ " Author: Tom Ryder " License: Same as Vim itself " -if exists('g:loaded_big_file_options') || &compatible || !has('autocmd') +if exists('g:loaded_big_file_options') || &compatible + finish +endif +if !has('autocmd') finish endif let g:loaded_big_file_options = 1 diff --git a/vim/plugin/command_typos.vim b/vim/plugin/command_typos.vim index afc04ed3..6f34c680 100644 --- a/vim/plugin/command_typos.vim +++ b/vim/plugin/command_typos.vim @@ -7,7 +7,10 @@ " Author: Tom Ryder " License: Same as Vim itself " -if exists('g:loaded_command_typos') || &compatible || !has('user_commands') +if exists('g:loaded_command_typos') || &compatible + finish +endif +if !has('user_commands') finish endif let g:loaded_command_typos = 1 diff --git a/vim/plugin/copy_linebreak.vim b/vim/plugin/copy_linebreak.vim index 158282bf..9d241d5a 100644 --- a/vim/plugin/copy_linebreak.vim +++ b/vim/plugin/copy_linebreak.vim @@ -6,7 +6,10 @@ " Author: Tom Ryder " License: Same as Vim itself " -if exists('g:loaded_copy_linebreak') || &compatible || !has('linebreak') +if exists('g:loaded_copy_linebreak') || &compatible + finish +endif +if !has('linebreak') finish endif let g:loaded_copy_linebreak = 1 diff --git a/vim/plugin/mail_mutt.vim b/vim/plugin/mail_mutt.vim index 13389309..5170fb52 100644 --- a/vim/plugin/mail_mutt.vim +++ b/vim/plugin/mail_mutt.vim @@ -5,7 +5,10 @@ " Author: Tom Ryder " License: Same as Vim itself " -if exists('g:loaded_mail_mutt') || &compatible || !has('user_commands') +if exists('g:loaded_mail_mutt') || &compatible + finish +endif +if !has('user_commands') finish endif let g:loaded_mail_mutt = 1 diff --git a/vim/plugin/toggle_option_flag.vim b/vim/plugin/toggle_option_flag.vim index 5c848368..bc7ccd78 100644 --- a/vim/plugin/toggle_option_flag.vim +++ b/vim/plugin/toggle_option_flag.vim @@ -5,7 +5,10 @@ " Author: Tom Ryder " License: Same as Vim itself " -if exists('g:loaded_toggle_option_flag') || &compatible || !has('user_commands') +if exists('g:loaded_toggle_option_flag') || &compatible + finish +endif +if !has('user_commands') finish endif let g:loaded_toggle_option_flag = 1 -- cgit v1.2.3 From 54caf02bd794e45ed5b4b181f1e314e924809b1e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 13 Nov 2017 00:02:47 +1300 Subject: Move 'hlsearch' insert-mode suspension into plugin It's easily repackaged and it makes the configuration that much shorter, so I may as well. This version also correctly handles 'hlsearch' not being on in the first place. --- vim/config/search.vim | 14 ---------- vim/doc/insert_suspend_hlsearch.txt | 28 ++++++++++++++++++++ vim/plugin/insert_suspend_hlsearch.vim | 48 ++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 14 deletions(-) create mode 100644 vim/doc/insert_suspend_hlsearch.txt create mode 100644 vim/plugin/insert_suspend_hlsearch.vim diff --git a/vim/config/search.vim b/vim/config/search.vim index 967146d4..fc861801 100644 --- a/vim/config/search.vim +++ b/vim/config/search.vim @@ -20,18 +20,4 @@ if has('extra_search') \ \ :nohlsearch - " Clear search highlighting as soon as I enter insert mode, and restore it - " once I leave it - if has('autocmd') && v:version >= 701 - augroup dotfiles_highlight - autocmd! - autocmd InsertEnter - \ * - \ set nohlsearch - autocmd InsertLeave - \ * - \ set hlsearch - augroup END - endif - endif diff --git a/vim/doc/insert_suspend_hlsearch.txt b/vim/doc/insert_suspend_hlsearch.txt new file mode 100644 index 00000000..edb51e38 --- /dev/null +++ b/vim/doc/insert_suspend_hlsearch.txt @@ -0,0 +1,28 @@ +*insert_suspend_hlsearch.txt* For Vim version 7.0 Last change: 2017 November 12 + +DESCRIPTION *insert_suspend_hlsearch* + +This plugin quietly disables 'hlsearch' search highlighting if enabled when an +insert operation is started, and puts it back once done, to avoid the +distracting effect the highlighting can cause while writing. + +REQUIREMENTS *insert_suspend_hlsearch-requirements* + +This plugin is only available if 'compatible' is not set. + +AUTHOR *insert_suspend_hlsearch-author* + +Written and maintained by Tom Ryder . + +LICENSE *insert_suspend_hlsearch-license* + +Licensed for distribution under the same terms as Vim itself (see |license|). + +DISTRIBUTION *insert_suspend_hlsearch-distribution* + +This plugin lives in Tom Ryder's "dotfiles" suite, and may eventually be spun +off into a separate distribution as it solidifies and this documentation +improves. See for more +information. + + vim:tw=78:ts=8:ft=help:norl: diff --git a/vim/plugin/insert_suspend_hlsearch.vim b/vim/plugin/insert_suspend_hlsearch.vim new file mode 100644 index 00000000..378febc8 --- /dev/null +++ b/vim/plugin/insert_suspend_hlsearch.vim @@ -0,0 +1,48 @@ +" +" insert_suspend_hlsearch.vim: If 'hlsearch' is enabled, switch it off when +" the user starts an insert mode operation, and back on again when they're +" done. +" +" Author: Tom Ryder +" License: Same as Vim itself +" +if exists('g:loaded_insert_suspend_hlsearch') || &compatible + finish +endif +" InsertEnter isn't an autocmd event until 7.0 +if !has('autocmd') || v:version < 700 + finish +endif +let g:loaded_insert_suspend_hlsearch = 1 + +" When entering insert mode, copy the current value of the 'hlsearch' option +" into a script variable; if it's enabled, suspend it +function s:InsertEnter() + let s:hlsearch = &hlsearch + echo &hlsearch + if s:hlsearch + set nohlsearch + endif + return +endfunction + +" When leaving insert mode, if 'hlsearch' was enabled when this operation +" started, restore it +function s:InsertLeave() + if s:hlsearch + set hlsearch + endif + return +endfunction + +" Clear search highlighting as soon as I enter insert mode, and restore it +" once I leave it +augroup insert_suspend_hlsearch + autocmd! + autocmd InsertEnter + \ * + \ call InsertEnter() + autocmd InsertLeave + \ * + \ call InsertLeave() +augroup END -- cgit v1.2.3 From ed0f0acb3f2c78b1f600db370b634c0e6bf269d7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 13 Nov 2017 00:09:53 +1300 Subject: Limit \f mapping to normal mode --- vim/config/format.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/config/format.vim b/vim/config/format.vim index 97ebcb11..86557a8c 100644 --- a/vim/config/format.vim +++ b/vim/config/format.vim @@ -7,7 +7,7 @@ set nrformats-=octal silent! set formatoptions+=j " Show the current formatoptions at a glance -noremap +nnoremap \ f \ :setlocal formatoptions? -- cgit v1.2.3