From 52e201b43aca55be0a51e4342fcbc1de09b8f2d7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 12:39:23 +1200 Subject: Remove unnecessary :setlocal commands --- vim/vimrc | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 2f638b6b..3bc765b7 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -1326,45 +1326,45 @@ endif " 'cursorline' is always off when in any visual mode, including block mode, " where it actually might have been really handy. +"" Leader,TAB toggles automatic indentation based on the previous line +nnoremap + \ :set autoindent! autoindent? +"" Leader,c toggles highlighted cursor row; doesn't work in visual mode +nnoremap c + \ :set cursorline! cursorline? "" Leader,h toggles highlighting search results nnoremap h \ :set hlsearch! hlsearch? "" Leader,i toggles showing matches as I enter my pattern nnoremap i \ :set incsearch! incsearch? -"" Leader,TAB toggles automatic indentation based on the previous line -nnoremap - \ :setlocal autoindent! autoindent? -"" Leader,c toggles highlighted cursor row; doesn't work in visual mode -nnoremap c - \ :setlocal cursorline! cursorline? "" Leader,s toggles spell checking nnoremap s - \ :setlocal spell! spell? + \ :set spell! spell? " The next group of option-toggling maps are much the same as the previous " group, except they also include analogous maps for visual mode, defined as " recursive maps into normal mode that conclude with re-selecting the text. -"" Leader,N toggles position display in bottom right -nnoremap N - \ :set ruler! ruler? -xmap N Ngv "" Leader,C toggles highlighted cursor column; works in visual mode nnoremap C - \ :setlocal cursorcolumn! cursorcolumn? + \ :set cursorcolumn! cursorcolumn? xmap C Cgv "" Leader,l toggles showing tab, end-of-line, and trailing white space nnoremap l - \ :setlocal list! list? + \ :set list! list? xmap l lgv "" Leader,n toggles line number display nnoremap n - \ :setlocal number! number? + \ :set number! number? xmap n ngv +"" Leader,N toggles position display in bottom right +nnoremap N + \ :set ruler! ruler? +xmap N Ngv "" Leader,w toggles soft wrapping nnoremap w - \ :setlocal wrap! wrap? + \ :set wrap! wrap? xmap w wgv " This next one just shows option state of the 'formatoptions' affecting how @@ -1372,7 +1372,7 @@ xmap w wgv "" Leader,f shows the current 'formatoptions' at a glance nnoremap f - \ :setlocal formatoptions? + \ :set formatoptions? " I often have to switch between US English and NZ English. The latter is " almost exactly the same as UK English in most locales, although we use @@ -1382,10 +1382,10 @@ nnoremap f "" Leader,u sets US English spelling language nnoremap u - \ :setlocal spelllang=en_us + \ :set spelllang=en_us "" Leader,z sets NZ English spelling language nnoremap z - \ :setlocal spelllang=en_nz + \ :set spelllang=en_nz " The next mapping is also for toggling an option, but it's more complicated; " it uses a simple plugin of mine called copy_linebreak.vim to manage several @@ -1438,10 +1438,10 @@ nnoremap F \ :ReloadFileType "" Leader,t shows current filetype nnoremap t - \ :setlocal filetype? + \ :set filetype? "" Leader,T clears filetype nnoremap T - \ :setlocal filetype= + \ :set filetype= " These mappings use my put_date.vim plugin for date insertion into the " buffer. @@ -1515,10 +1515,10 @@ nnoremap \ :enew "" Leader,e forces a buffer to be editable, even a :help one nnoremap e - \ :setlocal modifiable noreadonly + \ :set modifiable noreadonly "" Leader,E locks a buffer, reversible with e nnoremap E - \ :setlocal nomodifiable readonly + \ :set nomodifiable readonly "" Leader,j jumps to buffers ("jetpack") nnoremap j \ :buffers:buffer -- cgit v1.2.3 From 6bd14e07a3ffd882c5eb236a79280b0d00ba3047 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 15:22:40 +1200 Subject: Add 'define' option reset to Vim C ftplugin --- vim/after/ftplugin/c.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vim/after/ftplugin/c.vim b/vim/after/ftplugin/c.vim index b5989410..d1f6ef0b 100644 --- a/vim/after/ftplugin/c.vim +++ b/vim/after/ftplugin/c.vim @@ -1,5 +1,6 @@ -" Set 'commentstring' and 'include' back to their default C-friendly values +" Set 'commentstring', 'define', and 'include' back to their default C-friendly values setlocal commentstring&vim +setlocal define&vim include&vim setlocal include&vim " Include macros in completion -- cgit v1.2.3 From b5862a03d07d378d62899acbe0ab31a785caac6e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 15:23:16 +1200 Subject: Inline option resets and undos in Vim C ftplugin --- vim/after/ftplugin/c.vim | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/vim/after/ftplugin/c.vim b/vim/after/ftplugin/c.vim index d1f6ef0b..dd99e81f 100644 --- a/vim/after/ftplugin/c.vim +++ b/vim/after/ftplugin/c.vim @@ -1,15 +1,13 @@ " Set 'commentstring', 'define', and 'include' back to their default C-friendly values -setlocal commentstring&vim -setlocal define&vim include&vim -setlocal include&vim +setlocal commentstring&vim define&vim include&vim +let b:undo_ftplugin .= '|setlocal commentstring< define< include<' " Include macros in completion setlocal complete+=d +let b:undo_ftplugin .= '|setlocal complete<' " Include system headers on UNIX if has('unix') setlocal path+=/usr/include + let b:undo_ftplugin .= '|setlocal path<' endif - -" Undo all of the above -let b:undo_ftplugin .= '|setlocal commentstring< complete< include< path<' -- cgit v1.2.3 From 352e2b820167ff2377350683a88a69af803be78c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 15:24:01 +1200 Subject: Move 'foldmethod' definitions out to filetypes --- vim/after/ftplugin/c.vim | 4 ++++ vim/after/ftplugin/perl.vim | 4 ++++ vim/after/ftplugin/php.vim | 4 ++++ vim/after/ftplugin/sh.vim | 4 ++++ vim/after/ftplugin/vim.vim | 4 ++++ vim/after/ftplugin/zsh.vim | 4 ++++ vim/ftplugin/awk.vim | 4 ++++ vim/ftplugin/sed.vim | 4 ++++ vim/vimrc | 18 ------------------ 9 files changed, 32 insertions(+), 18 deletions(-) diff --git a/vim/after/ftplugin/c.vim b/vim/after/ftplugin/c.vim index dd99e81f..ea220e65 100644 --- a/vim/after/ftplugin/c.vim +++ b/vim/after/ftplugin/c.vim @@ -6,6 +6,10 @@ let b:undo_ftplugin .= '|setlocal commentstring< define< include<' setlocal complete+=d let b:undo_ftplugin .= '|setlocal complete<' +" Fold based on indent level +setlocal foldmethod=indent +let b:undo_ftplugin .= '|setlocal foldmethod<' + " Include system headers on UNIX if has('unix') setlocal path+=/usr/include diff --git a/vim/after/ftplugin/perl.vim b/vim/after/ftplugin/perl.vim index a303fa75..e780bed5 100644 --- a/vim/after/ftplugin/perl.vim +++ b/vim/after/ftplugin/perl.vim @@ -4,6 +4,10 @@ setlocal equalprg=perltidy let b:undo_ftplugin .= '|unlet b:current_compiler' \ . '|setlocal equalprg< errorformat< makeprg<' +" Fold based on indent level +setlocal foldmethod=indent +let b:undo_ftplugin .= '|setlocal foldmethod<' + " Add angle brackets to pairs of matched characters for q<...> setlocal matchpairs+=<:> let b:undo_ftplugin .= '|setlocal matchpairs<' diff --git a/vim/after/ftplugin/php.vim b/vim/after/ftplugin/php.vim index 58d83c49..7bb20f99 100644 --- a/vim/after/ftplugin/php.vim +++ b/vim/after/ftplugin/php.vim @@ -8,6 +8,10 @@ setlocal comments=s1:/*,m:*,ex:*/,://,:# setlocal formatoptions+=or let b:undo_ftplugin .= '|setlocal comments< formatoptions<' +" Fold based on indent level +setlocal foldmethod=indent +let b:undo_ftplugin .= '|setlocal foldmethod<' + " Use pman as 'keywordprg' setlocal keywordprg=pman let b:undo_ftplugin .= '|setlocal keywordprg<' diff --git a/vim/after/ftplugin/sh.vim b/vim/after/ftplugin/sh.vim index 8468b133..2c68d83a 100644 --- a/vim/after/ftplugin/sh.vim +++ b/vim/after/ftplugin/sh.vim @@ -3,6 +3,10 @@ setlocal comments=:# setlocal formatoptions+=or let b:undo_ftplugin .= '|setlocal comments< formatoptions<' +" Fold based on indent level +setlocal foldmethod=indent +let b:undo_ftplugin .= '|setlocal foldmethod<' + " If subtype is Bash, set 'keywordprg' to han(1df) if exists('b:is_bash') setlocal keywordprg=han diff --git a/vim/after/ftplugin/vim.vim b/vim/after/ftplugin/vim.vim index 30182bba..01f971b9 100644 --- a/vim/after/ftplugin/vim.vim +++ b/vim/after/ftplugin/vim.vim @@ -9,6 +9,10 @@ endif let b:regex_escape_flavor = 'vim' let b:undo_ftplugin .= '|unlet b:regex_escape_flavor' +" Fold based on indent level +setlocal foldmethod=indent +let b:undo_ftplugin .= '|setlocal foldmethod<' + " Use :help as 'keywordprg' if not already set; this is the default since Vim " v8.1.1290 if &keywordprg !=# ':help' diff --git a/vim/after/ftplugin/zsh.vim b/vim/after/ftplugin/zsh.vim index 5aa2600a..6b5a389c 100644 --- a/vim/after/ftplugin/zsh.vim +++ b/vim/after/ftplugin/zsh.vim @@ -2,3 +2,7 @@ compiler zsh let b:undo_ftplugin .= '|unlet b:current_compiler' \ . '|setlocal errorformat< makeprg<' + +" Fold based on indent level +setlocal foldmethod=indent +let b:undo_ftplugin .= '|setlocal foldmethod<' diff --git a/vim/ftplugin/awk.vim b/vim/ftplugin/awk.vim index 663ba810..310534ac 100644 --- a/vim/ftplugin/awk.vim +++ b/vim/ftplugin/awk.vim @@ -9,6 +9,10 @@ setlocal comments=:# setlocal formatoptions+=or let b:undo_ftplugin = 'setlocal comments< formatoptions<' +" Fold based on indent level +setlocal foldmethod=indent +let b:undo_ftplugin .= '|setlocal foldmethod<' + " Specify ERE flavor for regex_escape.vim let b:regex_escape_flavor = 'ere' let b:undo_ftplugin .= '|unlet b:regex_escape_flavor' diff --git a/vim/ftplugin/sed.vim b/vim/ftplugin/sed.vim index 9627941d..b154eadf 100644 --- a/vim/ftplugin/sed.vim +++ b/vim/ftplugin/sed.vim @@ -8,3 +8,7 @@ let b:did_ftplugin = 1 setlocal comments=:# setlocal formatoptions+=or let b:undo_ftplugin = 'setlocal comments< formatoptions<' + +" Fold based on indent level +setlocal foldmethod=indent +let b:undo_ftplugin .= '|setlocal foldmethod<' diff --git a/vim/vimrc b/vim/vimrc index 3bc765b7..165322ac 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -584,24 +584,6 @@ set confirm " set noesckeys -" By default, I prefer that figuring out where a region of text to fold away -" should be done by the indent level of its lines, since I tend to be careful -" about my indentation even in languages where it has no semantic meaning. -" -set foldmethod=indent - -" That said, I don't want any of these indent-based folds to start off closed. -" Therefore, we set the depth level at which folds should automatically start -" as closed to a rather high number, per the documentation's recommendations. -" -" I think of a Vim window with a file buffer loaded into it as -" a two-dimensional, planar view of the file, so that moving down one screen -" line means moving down one buffer line, at least when 'wrap' is unset. -" Folds break that mental model, and so I usually enable them explicitly only -" when I'm struggling to grasp some code with very long functions or loops. -" -set foldlevelstart=99 - " Automatic text wrapping options using flags in the 'formatoptions' option " begin here. I rely on the filetype plugins to set the 't' and 'c' flags for " this option to configure whether text or comments should be wrapped, as -- cgit v1.2.3 From 6daae79aff34c7f90c21b0fab73dbe1b2601c631 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 15:24:28 +1200 Subject: Fix a comment in mail Vim ftplugin --- vim/ftplugin/textarea.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/ftplugin/textarea.vim b/vim/ftplugin/textarea.vim index 872ae4c6..c6c2f1fd 100644 --- a/vim/ftplugin/textarea.vim +++ b/vim/ftplugin/textarea.vim @@ -3,8 +3,8 @@ if exists('no_plugin_maps') || exists('no_textarea_maps') finish endif -" Switch to mail filetype, just because that's very often the contents of text -" areas I edit using TextEditorAnywhere +" Local mapping to switch to mail filetype, just because that's very often the +" contents of text areas I edit using TextEditorAnywhere nnoremap f \ :setlocal filetype=mail let b:undo_ftplugin = 'nunmap f' -- cgit v1.2.3 From 52e6a996b3b89da19e6fde0611dd1f15fe4fa9da Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 15:24:48 +1200 Subject: Add abbreviation to TextAnywhere Vim ftplugin --- vim/ftplugin/textarea.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vim/ftplugin/textarea.vim b/vim/ftplugin/textarea.vim index c6c2f1fd..5cdb2bba 100644 --- a/vim/ftplugin/textarea.vim +++ b/vim/ftplugin/textarea.vim @@ -8,3 +8,6 @@ endif nnoremap f \ :setlocal filetype=mail let b:undo_ftplugin = 'nunmap f' + +" #s expands to the #signature tag used in Cerb +inoreabbrev #s #signature -- cgit v1.2.3 From 628ad57d7f514896f1b1a9dd77085e0d713602d5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 15:25:36 +1200 Subject: Switch to tab indents for writing C --- vim/after/indent/c.vim | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 vim/after/indent/c.vim diff --git a/vim/after/indent/c.vim b/vim/after/indent/c.vim new file mode 100644 index 00000000..c3240acb --- /dev/null +++ b/vim/after/indent/c.vim @@ -0,0 +1,6 @@ +" Use tabs for C +setlocal noexpandtab shiftwidth=0 tabstop=8 +if &softtabstop != -1 + let &softtabstop = &shiftwidth +endif +let b:undo_ftplugin .= '|setlocal expandtab< shiftwidth< softtabstop< tabstop<' -- cgit v1.2.3 From a8dfc3b6c0d4e4ca7c09afd6cfa064c9ccf80f45 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 16:09:24 +1200 Subject: Correct variable name --- vim/after/indent/c.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/after/indent/c.vim b/vim/after/indent/c.vim index c3240acb..1893f564 100644 --- a/vim/after/indent/c.vim +++ b/vim/after/indent/c.vim @@ -3,4 +3,4 @@ setlocal noexpandtab shiftwidth=0 tabstop=8 if &softtabstop != -1 let &softtabstop = &shiftwidth endif -let b:undo_ftplugin .= '|setlocal expandtab< shiftwidth< softtabstop< tabstop<' +let b:undo_indent .= '|setlocal expandtab< shiftwidth< softtabstop< tabstop<' -- cgit v1.2.3 From 86f99ab368986a6e9040e6c457ad60d066bf27c8 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 16:09:35 +1200 Subject: Type proto/*.pro files as C --- vim/filetype.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/vim/filetype.vim b/vim/filetype.vim index e65848bb..219ec819 100644 --- a/vim/filetype.vim +++ b/vim/filetype.vim @@ -44,6 +44,7 @@ augroup filetypedetect autocmd BufNewFile,BufRead \ ?*.c \,?*.h + \,*/proto/?*.pro \ setfiletype c " C++ files autocmd BufNewFile,BufRead -- cgit v1.2.3 From fa6ed737961d053ee22d78d0e1c9a5575d1af171 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 16:09:51 +1200 Subject: Set 'shiftwidth' to 4 for C Vim sources --- vim/after/indent/c.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vim/after/indent/c.vim b/vim/after/indent/c.vim index 1893f564..87291541 100644 --- a/vim/after/indent/c.vim +++ b/vim/after/indent/c.vim @@ -4,3 +4,8 @@ if &softtabstop != -1 let &softtabstop = &shiftwidth endif let b:undo_indent .= '|setlocal expandtab< shiftwidth< softtabstop< tabstop<' + +" If the path to the file looks like the Vim sources, set 'shiftwidth' to 4 +if expand('%:p') =~# '/vim.*src/' + setlocal shiftwidth=4 +endif -- cgit v1.2.3 From cc2cd38d2405dc50bdc7184516fd0b8e0e71ade0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 17:02:21 +1200 Subject: Set filetype-appropriate 'foldlevel' --- vim/after/ftplugin/c.vim | 5 +++-- vim/after/ftplugin/perl.vim | 5 +++-- vim/after/ftplugin/php.vim | 5 +++-- vim/after/ftplugin/sh.vim | 5 +++-- vim/after/ftplugin/vim.vim | 5 +++-- vim/after/ftplugin/zsh.vim | 5 +++-- vim/ftplugin/awk.vim | 5 +++-- vim/ftplugin/markdown.vim | 4 +++- vim/ftplugin/sed.vim | 5 +++-- 9 files changed, 27 insertions(+), 17 deletions(-) diff --git a/vim/after/ftplugin/c.vim b/vim/after/ftplugin/c.vim index ea220e65..bc531a61 100644 --- a/vim/after/ftplugin/c.vim +++ b/vim/after/ftplugin/c.vim @@ -6,9 +6,10 @@ let b:undo_ftplugin .= '|setlocal commentstring< define< include<' setlocal complete+=d let b:undo_ftplugin .= '|setlocal complete<' -" Fold based on indent level +" Fold based on indent level, and start with all folds closed setlocal foldmethod=indent -let b:undo_ftplugin .= '|setlocal foldmethod<' +setlocal foldlevel=0 +let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<' " Include system headers on UNIX if has('unix') diff --git a/vim/after/ftplugin/perl.vim b/vim/after/ftplugin/perl.vim index e780bed5..5c9cf8a0 100644 --- a/vim/after/ftplugin/perl.vim +++ b/vim/after/ftplugin/perl.vim @@ -4,9 +4,10 @@ setlocal equalprg=perltidy let b:undo_ftplugin .= '|unlet b:current_compiler' \ . '|setlocal equalprg< errorformat< makeprg<' -" Fold based on indent level +" Fold based on indent level, but start with all folds open setlocal foldmethod=indent -let b:undo_ftplugin .= '|setlocal foldmethod<' +setlocal foldlevel=99 +let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<' " Add angle brackets to pairs of matched characters for q<...> setlocal matchpairs+=<:> diff --git a/vim/after/ftplugin/php.vim b/vim/after/ftplugin/php.vim index 7bb20f99..3b023f9e 100644 --- a/vim/after/ftplugin/php.vim +++ b/vim/after/ftplugin/php.vim @@ -8,9 +8,10 @@ setlocal comments=s1:/*,m:*,ex:*/,://,:# setlocal formatoptions+=or let b:undo_ftplugin .= '|setlocal comments< formatoptions<' -" Fold based on indent level +" Fold based on indent level, but start with all folds open setlocal foldmethod=indent -let b:undo_ftplugin .= '|setlocal foldmethod<' +setlocal foldlevel=99 +let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<' " Use pman as 'keywordprg' setlocal keywordprg=pman diff --git a/vim/after/ftplugin/sh.vim b/vim/after/ftplugin/sh.vim index 2c68d83a..39b8d0d6 100644 --- a/vim/after/ftplugin/sh.vim +++ b/vim/after/ftplugin/sh.vim @@ -3,9 +3,10 @@ setlocal comments=:# setlocal formatoptions+=or let b:undo_ftplugin .= '|setlocal comments< formatoptions<' -" Fold based on indent level +" Fold based on indent level, but start with all folds open setlocal foldmethod=indent -let b:undo_ftplugin .= '|setlocal foldmethod<' +setlocal foldlevel=99 +let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<' " If subtype is Bash, set 'keywordprg' to han(1df) if exists('b:is_bash') diff --git a/vim/after/ftplugin/vim.vim b/vim/after/ftplugin/vim.vim index 01f971b9..481af0ec 100644 --- a/vim/after/ftplugin/vim.vim +++ b/vim/after/ftplugin/vim.vim @@ -9,9 +9,10 @@ endif let b:regex_escape_flavor = 'vim' let b:undo_ftplugin .= '|unlet b:regex_escape_flavor' -" Fold based on indent level +" Fold based on indent level, but start with all folds open setlocal foldmethod=indent -let b:undo_ftplugin .= '|setlocal foldmethod<' +setlocal foldlevel=99 +let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<' " Use :help as 'keywordprg' if not already set; this is the default since Vim " v8.1.1290 diff --git a/vim/after/ftplugin/zsh.vim b/vim/after/ftplugin/zsh.vim index 6b5a389c..880c2c39 100644 --- a/vim/after/ftplugin/zsh.vim +++ b/vim/after/ftplugin/zsh.vim @@ -3,6 +3,7 @@ compiler zsh let b:undo_ftplugin .= '|unlet b:current_compiler' \ . '|setlocal errorformat< makeprg<' -" Fold based on indent level +" Fold based on indent level, but start with all folds open setlocal foldmethod=indent -let b:undo_ftplugin .= '|setlocal foldmethod<' +setlocal foldlevel=99 +let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<' diff --git a/vim/ftplugin/awk.vim b/vim/ftplugin/awk.vim index 310534ac..dbefa5cd 100644 --- a/vim/ftplugin/awk.vim +++ b/vim/ftplugin/awk.vim @@ -9,9 +9,10 @@ setlocal comments=:# setlocal formatoptions+=or let b:undo_ftplugin = 'setlocal comments< formatoptions<' -" Fold based on indent level +" Fold based on indent level, but start with all folds open setlocal foldmethod=indent -let b:undo_ftplugin .= '|setlocal foldmethod<' +setlocal foldlevel=99 +let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<' " Specify ERE flavor for regex_escape.vim let b:regex_escape_flavor = 'ere' diff --git a/vim/ftplugin/markdown.vim b/vim/ftplugin/markdown.vim index d119e599..da2228b3 100644 --- a/vim/ftplugin/markdown.vim +++ b/vim/ftplugin/markdown.vim @@ -39,9 +39,11 @@ function! MarkdownFold() return '=' endfunction +let b:undo_ftplugin .= '|delfunction MarkdownFold' setlocal foldexpr=MarkdownFold() setlocal foldmethod=expr -let b:undo_ftplugin .= '|delfunction MarkdownFold|setlocal foldexpr< foldmethod<' +setlocal foldlevel=99 +let b:undo_ftplugin .= '|setlocal foldexpr< foldmethod< foldlevel<' " Spellcheck documents we're actually editing (not just viewing) if &modifiable && !&readonly diff --git a/vim/ftplugin/sed.vim b/vim/ftplugin/sed.vim index b154eadf..35e705a4 100644 --- a/vim/ftplugin/sed.vim +++ b/vim/ftplugin/sed.vim @@ -9,6 +9,7 @@ setlocal comments=:# setlocal formatoptions+=or let b:undo_ftplugin = 'setlocal comments< formatoptions<' -" Fold based on indent level +" Fold based on indent level, but start with all folds open setlocal foldmethod=indent -let b:undo_ftplugin .= '|setlocal foldmethod<' +setlocal foldlevel=99 +let b:undo_ftplugin .= '|setlocal foldmethod< foldlevel<' -- cgit v1.2.3 From f9f1d3ba9426a6371b665541c84d84caffa33209 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 17:58:48 +1200 Subject: Enable 'smarttab' in Vim --- vim/vimrc | 1 + 1 file changed, 1 insertion(+) diff --git a/vim/vimrc b/vim/vimrc index 165322ac..9bebf686 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -499,6 +499,7 @@ set path-=/usr/include set autoindent " Use indent of previous line on new lines set expandtab " Insert spaces when tab key is pressed in insert mode set shiftwidth=4 " Indent command like < and > use four-space indents +set smarttab " Tab at start of line means indent, otherwise means tab " Apply 'softtabstop' option to make a tab key press in insert mode insert the " same number of spaces as defined by the indent depth in 'shiftwidth'. If -- cgit v1.2.3 From 328d8cfaa722af568f4d0283a36bde0912c56763 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 20:17:13 +1200 Subject: Adjust string comparisons --- vim/vimrc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 9bebf686..cabff060 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -118,7 +118,7 @@ endif " Firstly, MYVIM can't be an empty string. We need a real path. " -if !strlen($MYVIM) +if $MYVIM ==# '' echoerr 'Blank user runtime path' finish endif @@ -804,7 +804,7 @@ set shortmess+=I " plugin doesn't look like it's going to load, whether because plugins have " been disabled, or it's not in any of the plugin directories. " -if !&loadplugins || !strlen(globpath(&runtimepath, 'plugin/matchparen.vim')) +if !&loadplugins || globpath(&runtimepath, 'plugin/matchparen.vim') ==# '' set showmatch matchtime=3 endif @@ -1050,7 +1050,7 @@ autocmd vimrc ColorScheme * " environment variable COLORFGBG or a response in v:termrbgresp that would set " it specifically. " -if !exists('$COLORFGBG') && !strlen(get(v:, 'termrbgresp', '')) +if !exists('$COLORFGBG') && get(v:, 'termrbgresp', '') ==# '' set background=dark endif @@ -1060,7 +1060,7 @@ endif " if &background ==# 'dark' \ && (has('gui_running') || &t_Co >= 256) - \ && strlen(globpath(&runtimepath, 'colors/sahara.vim')) + \ && globpath(&runtimepath, 'colors/sahara.vim') !=# '' colorscheme sahara endif @@ -1153,7 +1153,7 @@ nnoremap " If the plugin isn't available, I just abandon CTRL-C to continue its " uselessness. " -if &loadplugins && strlen(globpath(&runtimepath, 'plugin/insert_cancel.vim')) +if &loadplugins && globpath(&runtimepath, 'plugin/insert_cancel.vim') ==# '' imap (InsertCancel) endif -- cgit v1.2.3 From 846422537be98f00c1d28867532cfdc8c2387e9e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 20:17:34 +1200 Subject: Adjust a few comments --- vim/vimrc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index cabff060..73650d2e 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -4,12 +4,12 @@ " " " This is an attempt at something like a 'literate vimrc', in the tradition of -" Donald Knuth's "literate programming". +" Donald Knuth's "literate programming": " " " -" It's a long file, and comments abound. If this bothers you, you can do -" something like this to strip out all the blank lines and lines with only +" It's a long file, and comments abound. If this bothers you, you can execute +" this command in Vim to strip out all the blank lines and lines with only " comments: " " :g/\m^$\|^\s*"/d @@ -1037,7 +1037,7 @@ endif " almost always stands out too much for my liking. " " You'd think the autocommand pattern here could be used to match the colour -" scheme name, and it can be...after patch v7.4.108, when Christian Brabandt +" scheme name, and it can be ... after patch v7.4.108, when Christian Brabandt " fixed it. Until that version, it matched against the current buffer name, " so we're forced to have an explicit test in the command instead. " -- cgit v1.2.3 From ffb8fc583b7730c1860d769a91c522772ee8c5c8 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 20:29:44 +1200 Subject: Back to simpler regex test of &term --- vim/vimrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/vimrc b/vim/vimrc index 73650d2e..38089a19 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -829,7 +829,7 @@ set synmaxcol=500 " windows terminal emulator PuTTY, and the terminal multiplexer tmux, both of " which I use heavily. " -if &term =~# '^\%(putty\|tmux\)' +if &term =~# '^putty\|^tmux' set ttyfast endif -- cgit v1.2.3 From 109d9cf59100e59746db60ce0399353f62486034 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 20:30:11 +1200 Subject: Remove leader maps for digits --- vim/vimrc | 9 --------- 1 file changed, 9 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 38089a19..591eca96 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -1608,15 +1608,6 @@ xmap r (ReplaceOperator) nmap * (RegexEscape) xmap * (RegexEscape) -" I don't have anything for which I'm using the numbers just yet, so let's set -" them to apply an explicit 'foldlevel' for now, which is occasionally useful, -" though I suspect I'm more likely to keep using zM, zm, and zr. -" -for s:key in range(0,9) - execute 'nnoremap '.s:key.' :set foldlevel='.s:key.'' - execute 'xmap '.s:key.' '.s:key.'gv' -endfor - " And last, but definitely not least, I'm required by Vim fanatic law to " include a mapping that reloads my whole configuration. This uses the " command wrapper defined much earlier in the file, so that filetypes also get -- cgit v1.2.3 From 9a6499eb127f9e380034c615414dd8e4dd9ee503 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 20:55:41 +1200 Subject: Swap two terms around --- vim/vimrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 591eca96..e5b38cb6 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -149,8 +149,8 @@ endif " " " -if stridx($MYVIM, '\') >= 0 - \ && (v:version < 701 || v:version == 701 && !has('patch55')) +if (v:version < 701 || v:version == 701 && !has('patch55')) + \ && stridx($MYVIM, '\') >= 0 echoerr 'Illegal backslash in user runtime path on Vim < v7.1.055' finish endif -- cgit v1.2.3 From 5b3d271efb68399357990e708f39e3142976494e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 21:16:37 +1200 Subject: Remove unneeded expand() --- vim/vimrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/vimrc b/vim/vimrc index e5b38cb6..5121cce6 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -252,7 +252,7 @@ endif " provide as a quoted parameter to the function. " function! s:Establish(name) abort - let name = expand(a:name) + let name = a:name let path = 'p' let prot = 0700 if !isdirectory(name) && exists('*mkdir') -- cgit v1.2.3 From 00aa282bd1cd7aa4068ebdfda29525c9b721b4f3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 22:17:06 +1200 Subject: Finishing touches to paste_insert.vim I think I'll spin this out into a distribution shortly. --- vim/autoload/paste_insert.vim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/vim/autoload/paste_insert.vim b/vim/autoload/paste_insert.vim index 675fa5ab..f055249f 100644 --- a/vim/autoload/paste_insert.vim +++ b/vim/autoload/paste_insert.vim @@ -1,12 +1,13 @@ function! paste_insert#() abort augroup paste_insert autocmd! - autocmd CursorHold,CursorMoved,User * - \ set nopaste paste? - \|autocmd! paste_insert + autocmd User Error,Finish + \ set nopaste paste? | autocmd! paste_insert + autocmd CursorHold,CursorMoved,BufLeave,WinLeave * + \ doautocmd paste_insert User Error autocmd InsertEnter * \ autocmd paste_insert InsertLeave * - \ doautocmd paste_insert User + \ doautocmd paste_insert User Finish augroup END set paste paste? endfunction -- cgit v1.2.3 From eb9e921d3d7a4f6b91651bbfc3fedb72a6d91f1d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 22:34:49 +1200 Subject: Add a word to a comment --- vim/after/indent/c.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/after/indent/c.vim b/vim/after/indent/c.vim index 87291541..dfc50242 100644 --- a/vim/after/indent/c.vim +++ b/vim/after/indent/c.vim @@ -1,4 +1,4 @@ -" Use tabs for C +" Use hard tabs for C setlocal noexpandtab shiftwidth=0 tabstop=8 if &softtabstop != -1 let &softtabstop = &shiftwidth -- cgit v1.2.3 From 8fc405cc45ff07d64a8cab145e53f6de12b5b7c2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 22:35:11 +1200 Subject: Use hard tabs for editing Vim :help files --- vim/after/indent/help.vim | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 vim/after/indent/help.vim diff --git a/vim/after/indent/help.vim b/vim/after/indent/help.vim new file mode 100644 index 00000000..449e3b4a --- /dev/null +++ b/vim/after/indent/help.vim @@ -0,0 +1,6 @@ +" Use hard tabs for Vim help +setlocal noexpandtab shiftwidth=0 tabstop=8 +if &softtabstop != -1 + let &softtabstop = &shiftwidth +endif +let b:undo_indent .= '|setlocal expandtab< shiftwidth< softtabstop< tabstop<' -- cgit v1.2.3 From 11e62995956dbb1f81f5dac30c64e9631eb9efac Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 22:42:22 +1200 Subject: Spin off paste_insert.vim into distribution --- .gitmodules | 3 +++ vim/autoload/paste_insert.vim | 13 ------------- vim/bundle/paste_insert | 1 + vim/plugin/paste_insert.vim | 8 -------- 4 files changed, 4 insertions(+), 21 deletions(-) delete mode 100644 vim/autoload/paste_insert.vim create mode 160000 vim/bundle/paste_insert delete mode 100644 vim/plugin/paste_insert.vim diff --git a/.gitmodules b/.gitmodules index 5f049838..1a1178e2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -32,6 +32,9 @@ [submodule "vim/bundle/keep_position"] path = vim/bundle/keep_position url = https://sanctum.geek.nz/code/vim-keep-position.git +[submodule "vim/bundle/paste_insert"] + path = vim/bundle/paste_insert + url = https://sanctum.geek.nz/code/vim-paste-insert.git [submodule "vim/bundle/put_blank_lines"] path = vim/bundle/put_blank_lines url = https://sanctum.geek.nz/code/vim-put-blank-lines.git diff --git a/vim/autoload/paste_insert.vim b/vim/autoload/paste_insert.vim deleted file mode 100644 index f055249f..00000000 --- a/vim/autoload/paste_insert.vim +++ /dev/null @@ -1,13 +0,0 @@ -function! paste_insert#() abort - augroup paste_insert - autocmd! - autocmd User Error,Finish - \ set nopaste paste? | autocmd! paste_insert - autocmd CursorHold,CursorMoved,BufLeave,WinLeave * - \ doautocmd paste_insert User Error - autocmd InsertEnter * - \ autocmd paste_insert InsertLeave * - \ doautocmd paste_insert User Finish - augroup END - set paste paste? -endfunction diff --git a/vim/bundle/paste_insert b/vim/bundle/paste_insert new file mode 160000 index 00000000..d754e506 --- /dev/null +++ b/vim/bundle/paste_insert @@ -0,0 +1 @@ +Subproject commit d754e506fdfb10688d721935c01d2615d11b2a12 diff --git a/vim/plugin/paste_insert.vim b/vim/plugin/paste_insert.vim deleted file mode 100644 index 2c17f802..00000000 --- a/vim/plugin/paste_insert.vim +++ /dev/null @@ -1,8 +0,0 @@ -if exists('loaded_paste_insert') || &compatible - finish -endif -let loaded_paste_insert = 1 -command! -bar PasteInsert - \ call paste_insert#() -nnoremap PasteInsert - \ :PasteInsert -- cgit v1.2.3 From 7735ac2ae5e9cd2cca915f687c9998f03cf396ee Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 19 Jun 2019 22:42:51 +1200 Subject: Bump VERSION --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 42521acc..6b758ce6 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -tejr dotfiles v6.32.0 -Tue, 18 Jun 2019 23:58:21 +0000 +tejr dotfiles v6.33.0 +Wed, 19 Jun 2019 10:42:51 +0000 -- cgit v1.2.3