aboutsummaryrefslogtreecommitdiff
path: root/vim/config
diff options
context:
space:
mode:
Diffstat (limited to 'vim/config')
-rw-r--r--vim/config/file.vim8
-rw-r--r--vim/config/format.vim12
-rw-r--r--vim/config/list.vim4
-rw-r--r--vim/config/number.vim4
-rw-r--r--vim/config/search.vim22
-rw-r--r--vim/config/spell.vim12
-rw-r--r--vim/config/substitution.vim11
-rw-r--r--vim/config/swapfile.vim2
-rw-r--r--vim/config/undo.vim2
-rw-r--r--vim/config/viminfo.vim2
-rw-r--r--vim/config/whitespace.vim2
-rw-r--r--vim/config/wrap.vim6
12 files changed, 62 insertions, 25 deletions
diff --git a/vim/config/file.vim b/vim/config/file.vim
index 07c20cd5..4bf1f86b 100644
--- a/vim/config/file.vim
+++ b/vim/config/file.vim
@@ -27,5 +27,9 @@ 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 :w!<CR>
-nnoremap ZA :wa!<CR>
+nnoremap <silent>
+ \ ZW
+ \ :<C-U>write!<CR>
+nnoremap <silent>
+ \ ZA
+ \ :<C-U>wall!<CR>
diff --git a/vim/config/format.vim b/vim/config/format.vim
index 572e9877..688b60c9 100644
--- a/vim/config/format.vim
+++ b/vim/config/format.vim
@@ -1,6 +1,7 @@
" If we can, add j to the format options to get rid of comment leaders when
" joining lines
-if v:version > 703 || v:version ==# 703 && has('patch541')
+if v:version > 703
+ \ || v:version ==# 703 && has('patch541')
set formatoptions+=j
endif
@@ -17,10 +18,13 @@ endif
" t - Automatically wrap text at 'textwidth' (as above)
"
if has('eval') && has('user_commands')
- nnoremap <silent> <leader>a
+ nnoremap <silent>
+ \ <Leader>a
\ :<C-U>ToggleOptionFlagLocal formatoptions a<CR>
- nnoremap <silent> <leader>c
+ nnoremap <silent>
+ \ <Leader>c
\ :<C-U>ToggleOptionFlagLocal formatoptions c<CR>
- nnoremap <silent> <leader>t
+ nnoremap <silent>
+ \ <Leader>t
\ :<C-U>ToggleOptionFlagLocal formatoptions t<CR>
endif
diff --git a/vim/config/list.vim b/vim/config/list.vim
index 209bb4ec..1cb4345b 100644
--- a/vim/config/list.vim
+++ b/vim/config/list.vim
@@ -1,7 +1,9 @@
" 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! list?<CR>
+nnoremap <silent>
+ \ <Leader>l
+ \ :<C-U>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
diff --git a/vim/config/number.vim b/vim/config/number.vim
index d7d9919c..becc20f1 100644
--- a/vim/config/number.vim
+++ b/vim/config/number.vim
@@ -1,3 +1,5 @@
" Don't show line numbers by default, but \n toggles them
set nonumber
-nnoremap <Leader>n :setlocal number! number?<CR>
+nnoremap <silent>
+ \ <Leader>n
+ \ :<C-U>setlocal number! number?<CR>
diff --git a/vim/config/search.vim b/vim/config/search.vim
index 0f10eea5..ff243116 100644
--- a/vim/config/search.vim
+++ b/vim/config/search.vim
@@ -3,24 +3,34 @@ if has('extra_search')
" Searching as I enter my pattern, \i toggles this
set incsearch
- nnoremap <Leader>i :setlocal incsearch! incsearch?<CR>
+ nnoremap <silent>
+ \ <Leader>i
+ \ :<C-U>setlocal incsearch! incsearch?<CR>
" Highlight search results, \h toggles this
set hlsearch
- nnoremap <Leader>h :setlocal hlsearch! hlsearch?<CR>
+ nnoremap <silent>
+ \ <Leader>h
+ \ :<C-U>setlocal hlsearch! hlsearch?<CR>
" 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 <silent> <C-l> :nohlsearch<CR><C-l>
+ nnoremap <silent>
+ \ <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')
+ if has('autocmd') && v:version >= 701
augroup dotfiles_highlight
autocmd!
- silent! autocmd InsertEnter * setlocal nohlsearch
- silent! autocmd InsertLeave * setlocal hlsearch
+ autocmd InsertEnter
+ \ *
+ \ setlocal nohlsearch
+ autocmd InsertLeave
+ \ *
+ \ setlocal hlsearch
augroup END
endif
endif
diff --git a/vim/config/spell.vim b/vim/config/spell.vim
index 6a0167d0..7775ade9 100644
--- a/vim/config/spell.vim
+++ b/vim/config/spell.vim
@@ -3,12 +3,18 @@ if has('spell')
" Don't check spelling by default, but bind \s to toggle this
set nospell
- nnoremap <Leader>s :setlocal spell! spell?<CR>
+ nnoremap <silent>
+ \ <Leader>s
+ \ :<C-U>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 spelllang?<CR>
- nnoremap <Leader>z :setlocal spelllang=en_nz spelllang?<CR>
+ nnoremap <silent>
+ \ <Leader>u
+ \ :<C-U>setlocal spelllang=en_us spelllang?<CR>
+ nnoremap <silent>
+ \ <Leader>z
+ \ :<C-U>setlocal spelllang=en_nz spelllang?<CR>
endif
diff --git a/vim/config/substitution.vim b/vim/config/substitution.vim
index da9eb47e..415665ef 100644
--- a/vim/config/substitution.vim
+++ b/vim/config/substitution.vim
@@ -1,4 +1,11 @@
" 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 & :&&<CR>
-vnoremap & :&&<CR>
+nnoremap <silent>
+ \ &
+ \ :<C-U>&&<CR>
+
+" Same again for visual mode; we use vnoremap rather than xnoremap to stay
+" compatible with old Vims without doing eval() dances
+vnoremap <silent>
+ \ &
+ \ :<C-U>&&<CR>
diff --git a/vim/config/swapfile.vim b/vim/config/swapfile.vim
index f118eabd..778ae2f0 100644
--- a/vim/config/swapfile.vim
+++ b/vim/config/swapfile.vim
@@ -20,7 +20,7 @@ if !strlen($SUDO_USER) && has('unix')
if has('autocmd')
augroup dotfiles_swap_skip
autocmd!
- silent! autocmd BufNewFile,BufReadPre
+ autocmd BufNewFile,BufReadPre
\ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/*
\ setlocal noswapfile
augroup END
diff --git a/vim/config/undo.vim b/vim/config/undo.vim
index 872578f7..c9539665 100644
--- a/vim/config/undo.vim
+++ b/vim/config/undo.vim
@@ -24,7 +24,7 @@ if !strlen($SUDO_USER) && has('unix') && has('persistent_undo')
if has('autocmd')
augroup dotfiles_undo_skip
autocmd!
- silent! autocmd BufWritePre
+ autocmd BufWritePre
\ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/*
\ setlocal noundofile
augroup END
diff --git a/vim/config/viminfo.vim b/vim/config/viminfo.vim
index ce5d539d..9b01adc3 100644
--- a/vim/config/viminfo.vim
+++ b/vim/config/viminfo.vim
@@ -4,7 +4,7 @@
if has('viminfo') && has('autocmd')
augroup dotfiles_viminfo_skip
autocmd!
- silent! autocmd BufNewFile,BufReadPre
+ autocmd BufNewFile,BufReadPre
\ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/*
\ setlocal viminfo=
augroup END
diff --git a/vim/config/whitespace.vim b/vim/config/whitespace.vim
index 75ab7173..24cda107 100644
--- a/vim/config/whitespace.vim
+++ b/vim/config/whitespace.vim
@@ -1,2 +1,2 @@
" \x strips trailing whitespace via a custom plugin
-nmap <leader>x <Plug>StripTrailingWhitespace
+nmap <Leader>x <Plug>StripTrailingWhitespace
diff --git a/vim/config/wrap.vim b/vim/config/wrap.vim
index 5da843ce..a3fccbba 100644
--- a/vim/config/wrap.vim
+++ b/vim/config/wrap.vim
@@ -1,6 +1,8 @@
" Don't wrap by default, but use \w to toggle it on or off quickly
set nowrap
-nnoremap <Leader>w :setlocal wrap! wrap?<CR>
+nnoremap <silent>
+ \ <Leader>w
+ \ :<C-U>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
@@ -29,6 +31,6 @@ if has('linebreak')
endif
" \b toggles copy-pasteable linebreak settings
- nmap <leader>b <Plug>CopyLinebreak
+ nmap <Leader>b <Plug>CopyLinebreak
endif