aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-11-13 00:14:22 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-11-13 00:14:22 +1300
commitd3b197b7107a692744e82ef90ca539639ebb4a8b (patch)
tree94ce74a0462fa53017a19163ba3df6ea97f07f20
parent6a0e0c0e5f58ee2ce7ca59acad63c3fdfd0080f6 (diff)
parented0f0acb3f2c78b1f600db370b634c0e6bf269d7 (diff)
downloaddotfiles-d3b197b7107a692744e82ef90ca539639ebb4a8b.tar.gz
Merge branch 'feature/vimrc-rev' into develop
* feature/vimrc-rev: Limit \f mapping to normal mode Move 'hlsearch' insert-mode suspension into plugin Separate g:loaded/&cp tests from feat tests Use :set not :setlocal for 'hlsearch'/'incsearch' Correct nonexistent 'wildmode' value in Vim config Document each 'backspace' flag in Vim config
-rw-r--r--vim/config/backspace.vim11
-rw-r--r--vim/config/completion.vim2
-rw-r--r--vim/config/format.vim2
-rw-r--r--vim/config/search.vim18
-rw-r--r--vim/doc/insert_suspend_hlsearch.txt28
-rw-r--r--vim/plugin/auto_undodir.vim5
-rw-r--r--vim/plugin/big_file_options.vim5
-rw-r--r--vim/plugin/command_typos.vim5
-rw-r--r--vim/plugin/copy_linebreak.vim5
-rw-r--r--vim/plugin/insert_suspend_hlsearch.vim48
-rw-r--r--vim/plugin/mail_mutt.vim5
-rw-r--r--vim/plugin/toggle_option_flag.vim5
12 files changed, 112 insertions, 27 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
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:
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 <silent>
+nnoremap <silent>
\ <Leader>f
\ :<C-U>setlocal formatoptions?<CR>
diff --git a/vim/config/search.vim b/vim/config/search.vim
index 69f3f472..fc861801 100644
--- a/vim/config/search.vim
+++ b/vim/config/search.vim
@@ -5,13 +5,13 @@ if has('extra_search')
set incsearch
nnoremap <silent>
\ <Leader>i
- \ :<C-U>setlocal incsearch! incsearch?<CR>
+ \ :<C-U>set incsearch! incsearch?<CR>
" Highlight search results, \h toggles this
set hlsearch
nnoremap <silent>
\ <Leader>h
- \ :<C-U>setlocal hlsearch! hlsearch?<CR>
+ \ :<C-U>set hlsearch! hlsearch?<CR>
" Pressing ^L will clear highlighting until the next search-related
" operation; quite good because the highlighting gets distracting after
@@ -20,18 +20,4 @@ if has('extra_search')
\ <C-L>
\ :<C-U>nohlsearch<CR><C-L>
- " 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
- \ *
- \ setlocal nohlsearch
- autocmd InsertLeave
- \ *
- \ setlocal 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 <tom@sanctum.geek.nz>.
+
+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 <https://sanctum.geek.nz/cgit/dotfiles.git/about/> for more
+information.
+
+ vim:tw=78:ts=8:ft=help:norl:
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 <tom@sanctum.geek.nz>
" 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 <tom@sanctum.geek.nz>
" 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 <tom@sanctum.geek.nz>
" 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 <tom@sanctum.geek.nz>
" 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/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 <tom@sanctum.geek.nz>
+" 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 <SID>InsertEnter()
+ autocmd InsertLeave
+ \ *
+ \ call <SID>InsertLeave()
+augroup END
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 <tom@sanctum.geek.nz>
" 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 <tom@sanctum.geek.nz>
" 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