From 92f2c78524d1e446aa2ab08b12b54a56dfbbbd26 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 30 Oct 2017 23:47:33 +1300 Subject: 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 press, even if we put all three `option?` calls on one :setlocal line. --- vim/config/list.vim | 3 +-- vim/config/number.vim | 2 +- vim/config/search.vim | 8 ++++---- vim/config/spell.vim | 6 +++--- vim/config/wrap.vim | 6 +++--- 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 l :setlocal list! +nnoremap l :setlocal list! list? " 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 n :setlocal number! +nnoremap n :setlocal number! number? 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 i :setlocal incsearch! + nnoremap i :setlocal incsearch! incsearch? " Highlight search results, \h toggles this set hlsearch - nnoremap h :setlocal hlsearch! + nnoremap h :setlocal hlsearch! hlsearch? " 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 autocmd! - silent! autocmd InsertEnter * setlocal nohlsearch - silent! autocmd InsertLeave * setlocal hlsearch + silent! autocmd InsertEnter * setlocal nohlsearch nohlsearch? + silent! autocmd InsertLeave * setlocal hlsearch hlsearch? augroup END endif endif 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 s :setlocal 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 - nnoremap z :setlocal spelllang=en_nz + nnoremap u :setlocal spelllang=en_us spelllang? + nnoremap z :setlocal spelllang=en_nz spelllang? endif 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 w :setlocal wrap! +nnoremap w :setlocal 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 @@ -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 else - setlocal linebreak + setlocal linebreak linebreak? setlocal showbreak=... if s:breakindent setlocal breakindent -- cgit v1.2.3