diff options
authorTom Ryder <tom@sanctum.geek.nz>2017-10-30 23:47:33 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-10-30 23:49:45 +1300
commit92f2c78524d1e446aa2ab08b12b54a56dfbbbd26 (patch)
parentdefc57b54c38e2411e1e89f3211230ac912fb7ba (diff)
Show Vim option values after leader-key toggle
Using the very weird syntax: :setlocal option! option? We can toggle the option and print its new value in the same line. For the line breaking options, we only show the value of the 'linebreak' option, because otherwise we print three lines of messages, which requires an <Enter> press, even if we put all three `option?` calls on one :setlocal line.
5 files changed, 12 insertions, 13 deletions
diff --git a/vim/config/list.vim b/vim/config/list.vim
index 87e80005..faf5e29a 100644
--- a/vim/config/list.vim
+++ b/vim/config/list.vim
@@ -1,9 +1,8 @@
" Don't show whitespace characters or end-of-line characters visually by
" default, but make \l toggle between them
set nolist
-nnoremap <leader>l :setlocal list!<CR>
+nnoremap <leader>l :setlocal list! list?<CR>
" Clearly show when the start or end of the row does not correspond to the
" start and end of the line
set listchars+=precedes:<,extends:>
diff --git a/vim/config/number.vim b/vim/config/number.vim
index 464a77a2..35ec7efe 100644
--- a/vim/config/number.vim
+++ b/vim/config/number.vim
@@ -1,3 +1,3 @@
" Don't show line numbers by default, but \n toggles them
set nonumber
-nnoremap <leader>n :setlocal number!<CR>
+nnoremap <leader>n :setlocal number! number?<CR>
diff --git a/vim/config/search.vim b/vim/config/search.vim
index 78b17327..1d1039e2 100644
--- a/vim/config/search.vim
+++ b/vim/config/search.vim
@@ -3,11 +3,11 @@ if has('extra_search')
" Searching as I enter my pattern, \i toggles this
set incsearch
- nnoremap <leader>i :setlocal incsearch!<CR>
+ nnoremap <leader>i :setlocal incsearch! incsearch?<CR>
" Highlight search results, \h toggles this
set hlsearch
- nnoremap <leader>h :setlocal hlsearch!<CR>
+ nnoremap <leader>h :setlocal hlsearch! hlsearch?<CR>
" Pressing ^L will clear highlighting until the next search-related
" operation; quite good because the highlighting gets distracting after
@@ -19,8 +19,8 @@ if has('extra_search')
if has('autocmd')
augroup dotfiles_highlight
- silent! autocmd InsertEnter * setlocal nohlsearch
- silent! autocmd InsertLeave * setlocal hlsearch
+ silent! autocmd InsertEnter * setlocal nohlsearch nohlsearch?
+ silent! autocmd InsertLeave * setlocal hlsearch hlsearch?
augroup END
diff --git a/vim/config/spell.vim b/vim/config/spell.vim
index c34a6cc3..046b50ff 100644
--- a/vim/config/spell.vim
+++ b/vim/config/spell.vim
@@ -3,12 +3,12 @@ if has('spell')
" Don't check spelling by default, but bind \s to toggle this
set nospell
- nnoremap <leader>s :setlocal spell!<CR>
+ nnoremap <leader>s :setlocal spell! spell?<CR>
" 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 <leader>u :setlocal spelllang=en_us<CR>
- nnoremap <leader>z :setlocal spelllang=en_nz<CR>
+ nnoremap <leader>u :setlocal spelllang=en_us spelllang?<CR>
+ nnoremap <leader>z :setlocal spelllang=en_nz spelllang?<CR>
diff --git a/vim/config/wrap.vim b/vim/config/wrap.vim
index cad3ec1a..831cd907 100644
--- a/vim/config/wrap.vim
+++ b/vim/config/wrap.vim
@@ -1,6 +1,6 @@
" Don't wrap by default, but use \w to toggle it on or off quickly
set nowrap
-nnoremap <leader>w :setlocal wrap!<CR>
+nnoremap <leader>w :setlocal wrap! wrap?<CR>
" 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
@@ -40,7 +40,7 @@ if has('linebreak')
" If linebreak is on, turn it off
if &l:linebreak
- setlocal nolinebreak
+ setlocal nolinebreak linebreak?
setlocal showbreak=
if s:breakindent
setlocal nobreakindent
@@ -48,7 +48,7 @@ if has('linebreak')
" If it's off, turn it on
- setlocal linebreak
+ setlocal linebreak linebreak?
setlocal showbreak=...
if s:breakindent
setlocal breakindent