From 30e14ab95bdf039ac4abac20abd881d9909b1d5b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 8 Nov 2017 14:40:38 +1300 Subject: Beginnings of a buffer-to-Mutt mailer plugin --- vim/config/command.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'vim') diff --git a/vim/config/command.vim b/vim/config/command.vim index 09ee0f40..a8861583 100644 --- a/vim/config/command.vim +++ b/vim/config/command.vim @@ -34,3 +34,13 @@ nnoremap nnoremap \ D \ :read !date -u + +" \m fires up mutt with either the whole buffer or the text +function s:Mutt() + let l:tf = tempname() + execute 'write '.fnameescape(l:tf) + execute '!mutt -i '.shellescape(l:tf) +endfunction +nnoremap + \ m + \ :call Mutt() -- cgit v1.2.3 From fef27f00690ab0860e24eba0637e57d0cbd44812 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 9 Nov 2017 09:33:13 +1300 Subject: Fix 'while'/'until' highlighting in syntax/sh.vim These two changes coax syntax/sh.vim into realising that POSIX shell does not specify 'until' as a builtin (that's a Bash/Ksh thing), and that POSIX shell is able to nest 'while' loops within other blocks (that's not a Bash/Ksh thing). --- vim/after/syntax/sh.vim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'vim') diff --git a/vim/after/syntax/sh.vim b/vim/after/syntax/sh.vim index ba209e99..98b582bd 100644 --- a/vim/after/syntax/sh.vim +++ b/vim/after/syntax/sh.vim @@ -100,6 +100,20 @@ if exists('b:is_posix') \ PS4 \ PWD + " Core syntax/sh.vim thinks 'until' is a POSIX control structure keyword, + " but it isn't. Reset shRepeat and rebuild it with just 'while'. I only + " sort-of understand what this does, but it works. + syntax clear shRepeat + syntax region shRepeat + \ matchgroup=shLoop + \ start="\ Date: Thu, 9 Nov 2017 10:33:49 +1300 Subject: Remove false error flagging for sh char class glob The syntax highlighter flags this code with an error on the final square bracket: `case $foo in [![:ascii:]]) ;; esac`, but that's all legal. I'm not yet sure how to fix it, so will just turn the error group for now. --- vim/after/syntax/sh.vim | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'vim') diff --git a/vim/after/syntax/sh.vim b/vim/after/syntax/sh.vim index 98b582bd..8025c567 100644 --- a/vim/after/syntax/sh.vim +++ b/vim/after/syntax/sh.vim @@ -18,6 +18,11 @@ syntax clear shDerefWordError " probably not worth keeping the error. syntax clear shParenError +" The syntax highlighter flags this code with an error on the final square +" bracket: `case $foo in [![:ascii:]]) ;; esac`, but that's all legal. I'm not +" yet sure how to fix it, so will just turn the error group for now. +syntax clear shTestError + " Highlighting corrections specific to POSIX mode if exists('b:is_posix') -- cgit v1.2.3 From aab02ca1d3f40c91d39222f5ee84dab187d8da0e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 12:01:59 +1300 Subject: Remove setting for 'tabstop' :help 'tabstop' says that setting it may be a bad idea: > Note: Setting 'tabstop' to any other value than 8 can make your file > appear wrong in many places (e.g., when printing it). On thinking about it, it's actually probably better to show literal tabs as eight screen spaces, as it will make it very obvious when there are tabs in the file. --- vim/config/indent.vim | 3 --- 1 file changed, 3 deletions(-) (limited to 'vim') diff --git a/vim/config/indent.vim b/vim/config/indent.vim index f6dfd416..aba4bbf7 100644 --- a/vim/config/indent.vim +++ b/vim/config/indent.vim @@ -11,9 +11,6 @@ set shiftwidth=4 " Insert four spaces when Tab is pressed set softtabstop=4 -" How many spaces to show for a literal tab when 'list' is unset -set tabstop=4 - " Indent intelligently to 'shiftwidth' at the starts of lines with Tab, but " use 'tabstop' everywhere else set smarttab -- cgit v1.2.3 From 149d19c3ba54ece9314590d11136c2ec54e87c59 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 13:17:48 +1300 Subject: Append angle brackets rather than resetting opt --- vim/config/match.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'vim') diff --git a/vim/config/match.vim b/vim/config/match.vim index 5c53d63e..896e1d63 100644 --- a/vim/config/match.vim +++ b/vim/config/match.vim @@ -3,4 +3,4 @@ silent! runtime macros/matchit.vim " Match all forms of brackets in pairs (including angle brackets) -set matchpairs=(:),{:},[:],<:> +set matchpairs+=<:> -- cgit v1.2.3 From c3b2cf6b18d1ae408ff7f0eb685bf4a2281f39bf Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 13:19:54 +1300 Subject: Merge join,indent.vim into whitespace.vim --- vim/config/indent.vim | 21 --------------------- vim/config/join.vim | 10 ---------- vim/config/whitespace.vim | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 31 deletions(-) delete mode 100644 vim/config/indent.vim delete mode 100644 vim/config/join.vim (limited to 'vim') diff --git a/vim/config/indent.vim b/vim/config/indent.vim deleted file mode 100644 index aba4bbf7..00000000 --- a/vim/config/indent.vim +++ /dev/null @@ -1,21 +0,0 @@ -" Adopt the indent of the last line on new lines; interestingly, plugins that -" do clever things with indenting will often assume this is set -set autoindent - -" Use spaces instead of tabs -set expandtab - -" Indent with four spaces when an indent operation is used -set shiftwidth=4 - -" Insert four spaces when Tab is pressed -set softtabstop=4 - -" Indent intelligently to 'shiftwidth' at the starts of lines with Tab, but -" use 'tabstop' everywhere else -set smarttab - -" When indenting lines with < or >, round the indent to a multiple of -" 'shiftwidth', so even if the line is indented by one space it will indent -" up to 4 and down to 0, for example -set shiftround diff --git a/vim/config/join.vim b/vim/config/join.vim deleted file mode 100644 index ebf42a8b..00000000 --- a/vim/config/join.vim +++ /dev/null @@ -1,10 +0,0 @@ -" Don't join lines with two spaces at the end of sentences; I don't two-space, -" despite the noble Steve Losh's exhortations -set nojoinspaces - -" Rebind normal J to run plugin-defined join that doesn't jump around, but -" only if we have the eval feature, because otherwise this mapping won't exist -" and we should keep the default behaviour -if has('eval') - nmap J FixedJoin -endif diff --git a/vim/config/whitespace.vim b/vim/config/whitespace.vim index 24cda107..12d41a4e 100644 --- a/vim/config/whitespace.vim +++ b/vim/config/whitespace.vim @@ -1,2 +1,35 @@ +" Adopt the indent of the last line on new lines; interestingly, plugins that +" do clever things with indenting will often assume this is set +set autoindent + +" Use spaces instead of tabs +set expandtab + +" Indent with four spaces when an indent operation is used +set shiftwidth=4 + +" Insert four spaces when Tab is pressed +set softtabstop=4 + +" Indent intelligently to 'shiftwidth' at the starts of lines with Tab, but +" use 'tabstop' everywhere else +set smarttab + +" When indenting lines with < or >, round the indent to a multiple of +" 'shiftwidth', so even if the line is indented by one space it will indent +" up to 4 and down to 0, for example +set shiftround + +" Don't join lines with two spaces at the end of sentences; I don't two-space, +" despite the noble Steve Losh's exhortations +set nojoinspaces + +" Rebind normal J to run plugin-defined join that doesn't jump around, but +" only if we have the eval feature, because otherwise this mapping won't exist +" and we should keep the default behaviour +if has('eval') + nmap J FixedJoin +endif + " \x strips trailing whitespace via a custom plugin nmap x StripTrailingWhitespace -- cgit v1.2.3 From 69cac9e123d74fa9fecf96177cb79d8370a833f1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 21:13:21 +1300 Subject: Move backup, swap, and undo dir logic into plugins --- vim/config/backup.vim | 33 +++++++------------------ vim/config/swapfile.vim | 44 ++++++++++----------------------- vim/config/undo.vim | 22 +++++------------ vim/doc/auto_backupdir.txt | 12 +++++++++ vim/doc/auto_swapdir.txt | 12 +++++++++ vim/doc/auto_undodir.txt | 14 +++++++++++ vim/plugin/auto_backupdir.vim | 56 ++++++++++++++++++++++++++++++++++++++++++ vim/plugin/auto_swapdir.vim | 56 ++++++++++++++++++++++++++++++++++++++++++ vim/plugin/auto_undodir.vim | 57 +++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 235 insertions(+), 71 deletions(-) create mode 100644 vim/doc/auto_backupdir.txt create mode 100644 vim/doc/auto_swapdir.txt create mode 100644 vim/doc/auto_undodir.txt create mode 100644 vim/plugin/auto_backupdir.vim create mode 100644 vim/plugin/auto_swapdir.vim create mode 100644 vim/plugin/auto_undodir.vim (limited to 'vim') diff --git a/vim/config/backup.vim b/vim/config/backup.vim index 718647fc..8735a094 100644 --- a/vim/config/backup.vim +++ b/vim/config/backup.vim @@ -1,26 +1,11 @@ -" Use backup features if on a UNIX-like system and not using sudo(8) -if !strlen($SUDO_USER) && has('unix') +" Default to no backup files at all, in a way that even ancient/tiny Vims will +" understand; the auto_backupdir.vim plugin will take care of re-enabling this +set nobackup +set nowritebackup - " Keep backups with a .bak extension in ~/.vim/backup; the double-slash at - " the end of the directory is supposed to prod Vim into keeping the full - " path to the file in its backup filename to avoid collisions, but I don't - " think it actually works for backups, just undo and swap files - set backup - set backupext=.bak - set backupdir^=~/.vim/backup// +" If backps are enabled, use a more explicit and familiar backup suffix +set backupext=.bak - " This option already includes various temporary directories, but we - " append to it so that we don't back up anything in a shared memory - " filesystem either - set backupskip+=*/shm/* - - " Create the backup directory if necessary and possible - if !isdirectory($HOME . '/.vim/backup') && exists('*mkdir') - call mkdir($HOME . '/.vim/backup', 'p', 0700) - endif - -" Don't use backups at all otherwise -else - set nobackup - set nowritebackup -endif +" Don't back up files in anything named */shm/; they might be password +" files +set backupskip+=*/shm/* diff --git a/vim/config/swapfile.vim b/vim/config/swapfile.vim index 778ae2f0..bf91aa6b 100644 --- a/vim/config/swapfile.vim +++ b/vim/config/swapfile.vim @@ -1,32 +1,14 @@ -" Swap files are used if using Unix and not using sudo(8); I very seldom need -" them, but they are occasionally useful after a crash, and they don't really -" get in the way if kept in their own directory -if !strlen($SUDO_USER) && has('unix') - - " Use swap files but keep them in ~/.vim/swap; the double-slash at the end - " of the directory prods Vim into keeping the full path to the file in its - " undo filename to avoid collisions; the same thing works for undo files - set swapfile - set directory^=~/.vim/swap// - - " Create the ~/.vim/swap directory if necessary and possible - if !isdirectory($HOME . '/.vim/swap') && exists('*mkdir') - call mkdir($HOME . '/.vim/swap', 'p', 0700) - endif - - " Don't keep swap files for files in temporary directories or shared memory - " filesystems; this is because they're used as scratch spaces for tools - " like sudoedit(8) and pass(1) and hence could present a security problem - if has('autocmd') - augroup dotfiles_swap_skip - autocmd! - autocmd BufNewFile,BufReadPre - \ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/* - \ setlocal noswapfile - augroup END - endif - -" Otherwise, don't use swap files at all -else - set noswapfile +" Default to no swapfile files at all, in a way that even ancient/tiny Vims +" will understand; the auto_swapdir.vim plugin will take care of this +set noswapfile + +" Don't keep swap files from temporary directories or shared memory in case +" they're secrets +if has('autocmd') + augroup dotfiles_swap_skip + autocmd! + autocmd BufNewFile,BufReadPre + \ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/* + \ setlocal noswapfile + augroup END endif diff --git a/vim/config/undo.vim b/vim/config/undo.vim index c9539665..c31780e7 100644 --- a/vim/config/undo.vim +++ b/vim/config/undo.vim @@ -4,23 +4,13 @@ inoremap u " Keep screeds of undo history set undolevels=2000 -" Keep undo history in a separate file if the feature is available, we're on -" Unix, and not using sudo(8); this goes really well with undo visualization -" plugins like Gundo or Undotree. -if !strlen($SUDO_USER) && has('unix') && has('persistent_undo') +" 'undodir' and 'undofile' settings will be taken care of by the +" auto_undodir.vim plugin if applicable/possible +if has('persistent_undo') + set noundofile - " Keep per-file undo history in ~/.vim/undo; the double-slash at the end - " of the directory prods Vim into keeping the full path to the file in its - " undo filename to avoid collisions; the same thing works for swap files - set undofile - set undodir^=~/.vim/undo// - - " Create the ~/.vim/undo directory if necessary and possible - if !isdirectory($HOME . '/.vim/undo') && exists('*mkdir') - call mkdir($HOME . '/.vim/undo', 'p', 0700) - endif - - " Don't track changes to sensitive files + " Don't keep undo files from temporary directories or shared memory in case + " they're secrets if has('autocmd') augroup dotfiles_undo_skip autocmd! diff --git a/vim/doc/auto_backupdir.txt b/vim/doc/auto_backupdir.txt new file mode 100644 index 00000000..c5b6ebad --- /dev/null +++ b/vim/doc/auto_backupdir.txt @@ -0,0 +1,12 @@ +*auto_backupdir.txt* Automatically create 'backupdir' in 'realtimepath' + +Author: Tom Ryder +License: Same terms as Vim itself (see |license|) + +This plugin attempts to create a directory "backup" in the directory named by +the first element of 'realtimepath', and enables 'backup' with that as the +'backupdir' if it succeeds or if the directory already exists. + +This plugin lives in Tom Ryder's "dotfiles" suite, and will eventually be spun +off into a separate distribution as it solidifies and this documentation +improves. diff --git a/vim/doc/auto_swapdir.txt b/vim/doc/auto_swapdir.txt new file mode 100644 index 00000000..f88cfcf3 --- /dev/null +++ b/vim/doc/auto_swapdir.txt @@ -0,0 +1,12 @@ +*auto_swapdir.txt* Automatically create 'swapdir' in 'realtimepath' + +Author: Tom Ryder +License: Same terms as Vim itself (see |license|) + +This plugin attempts to create a directory "swap" in the directory named by the +first element of 'realtimepath', and enables 'swapfile' with that as the +'directory' if it succeeds or if the directory already exists. + +This plugin lives in Tom Ryder's "dotfiles" suite, and will eventually be spun +off into a separate distribution as it solidifies and this documentation +improves. diff --git a/vim/doc/auto_undodir.txt b/vim/doc/auto_undodir.txt new file mode 100644 index 00000000..c782a70e --- /dev/null +++ b/vim/doc/auto_undodir.txt @@ -0,0 +1,14 @@ +*auto_undodir.txt* Automatically create 'undodir' in 'realtimepath' + +Author: Tom Ryder +License: Same terms as Vim itself (see |license|) + +This plugin attempts to create a directory "undo" in the directory named by the +first element of 'realtimepath', and enables 'undofile' with that as the +'undodir' if it succeeds or if the directory already exists. + +It requires the +persistent_undo feature. + +This plugin lives in Tom Ryder's "dotfiles" suite, and will eventually be spun +off into a separate distribution as it solidifies and this documentation +improves. diff --git a/vim/plugin/auto_backupdir.vim b/vim/plugin/auto_backupdir.vim new file mode 100644 index 00000000..f15e7ce6 --- /dev/null +++ b/vim/plugin/auto_backupdir.vim @@ -0,0 +1,56 @@ +" +" auto_backupdir.vim: Configure 'backupdir' automatically, including trying +" hard to create it. +" +" Author: Tom Ryder +" License: Same as Vim itself +" +if exists('g:loaded_auto_backupdir') + \ || &compatible + finish +endif +let g:loaded_auto_backupdir = 1 + +" Define the backup path we want +if exists('$VIM_BACKUPDIR') + let s:backupdir = $VIM_BACKUPDIR +else + + " This is imperfect in that it will break if you have a backslashed comma in + " the first component of your &runtimepath, but if you're doing that, you + " probably already have way bigger problems + let s:backupdir + \ = strpart(&runtimepath, 0, stridx(&runtimepath, ',')) + \ . '/backup' +endif + +" If the prospective backup directory does not exist, try hard to create it +if !isdirectory(expand(s:backupdir)) + + " Try Vim's native mkdir() first + if exists('*mkdir') + silent! call mkdir(expand(s:backupdir), 'p', 0700) + + " Failing that, use an OS-dependent command + " (Fortunately, Unix and Windows are the only OS types in the world) + elseif has('unix') + silent! execute '!mkdir -m 0700 -p ' + \ . shellescape(expand(s:backupdir)) + elseif has('win32') || has('win64') + silent! execute '!mkdir ' + \ . shellescape(expand(s:backupdir)) + endif + +endif + +" If the directory exists after that... +if isdirectory(expand(s:backupdir)) + + " Set the backup directory and turn backups on + execute 'set backupdir^=' . s:backupdir . '//' + set backup + +" If not, give up and raise an error +else + echoerr 'Could not create backupdir ' . s:backupdir +endif diff --git a/vim/plugin/auto_swapdir.vim b/vim/plugin/auto_swapdir.vim new file mode 100644 index 00000000..ea41a0f0 --- /dev/null +++ b/vim/plugin/auto_swapdir.vim @@ -0,0 +1,56 @@ +" +" auto_swapdir.vim: Configure 'directory' automatically, including trying hard +" to create it. +" +" Author: Tom Ryder +" License: Same as Vim itself +" +if exists('g:loaded_auto_swapdir') + \ || &compatible + finish +endif +let g:loaded_auto_swapdir = 1 + +" Define the swap path we want +if exists('$VIM_SWAPDIR') + let s:swapdir = $VIM_SWAPDIR +else + + " This is imperfect in that it will break if you have a backslashed comma in + " the first component of your &runtimepath, but if you're doing that, you + " probably already have way bigger problems + let s:swapdir + \ = strpart(&runtimepath, 0, stridx(&runtimepath, ',')) + \ . '/swap' +endif + +" If the prospective swapfile directory does not exist, try hard to create it +if !isdirectory(expand(s:swapdir)) + + " Try Vim's native mkdir() first + if exists('*mkdir') + silent! call mkdir(expand(s:swapdir), 'p', 0700) + + " Failing that, use an OS-dependent command + " (Fortunately, Unix and Windows are the only OS types in the world) + elseif has('unix') + silent! execute '!mkdir -m 0700 -p ' + \ . shellescape(expand(s:swapdir)) + elseif has('win32') || has('win64') + silent! execute '!mkdir ' + \ . shellescape(expand(s:swapdir)) + endif + +endif + +" If the directory exists after that... +if isdirectory(expand(s:swapdir)) + + " Set the swapfile directory and turn swapfiles on + execute 'set directory^=' . s:swapdir . '//' + set swapfile + +" If not, give up and raise an error +else + echoerr 'Could not create swapdir ' . s:swapdir +endif diff --git a/vim/plugin/auto_undodir.vim b/vim/plugin/auto_undodir.vim new file mode 100644 index 00000000..1d20ba95 --- /dev/null +++ b/vim/plugin/auto_undodir.vim @@ -0,0 +1,57 @@ +" +" auto_undodir.vim: Configure 'undodir' automatically, including trying hard +" to create it. +" +" Author: Tom Ryder +" License: Same as Vim itself +" +if exists('g:loaded_auto_undodir') + \ || !has('persistent_undo') + \ || &compatible + finish +endif +let g:loaded_auto_undodir = 1 + +" Define the undo path we want +if exists('$VIM_UNDODIR') + let s:undodir = $VIM_UNDODIR +else + + " This is imperfect in that it will break if you have a backslashed comma in + " the first component of your &runtimepath, but if you're doing that, you + " probably already have way bigger problems + let s:undodir + \ = strpart(&runtimepath, 0, stridx(&runtimepath, ',')) + \ . '/undo' +endif + +" If the prospective undo directory does not exist, try hard to create it +if !isdirectory(expand(s:undodir)) + + " Try Vim's native mkdir() first + if exists('*mkdir') + silent! call mkdir(expand(s:undodir), 'p', 0700) + + " Failing that, use an OS-dependent command + " (Fortunately, Unix and Windows are the only OS types in the world) + elseif has('unix') + silent! execute '!mkdir -m 0700 -p ' + \ . shellescape(expand(s:undodir)) + elseif has('win32') || has('win64') + silent! execute '!mkdir ' + \ . shellescape(expand(s:undodir)) + endif + +endif + +" If the directory exists after that... +if isdirectory(expand(s:undodir)) + + " Set the undo directory and turn persistent undo files on + execute 'set undodir^=' . s:undodir . '//' + set undofile + +" If not, give up and raise an error +else + echoerr 'Could not create undodir ' . s:undodir +endif -- cgit v1.2.3 From 3d6a063b0702de236b3ffc6c5b40eef0cd76e56d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 21:15:10 +1300 Subject: Merge encoding.vim and file.vim into files.vim --- vim/config/encoding.vim | 4 ---- vim/config/file.vim | 40 ---------------------------------------- vim/config/files.vim | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 44 deletions(-) delete mode 100644 vim/config/encoding.vim delete mode 100644 vim/config/file.vim create mode 100644 vim/config/files.vim (limited to 'vim') diff --git a/vim/config/encoding.vim b/vim/config/encoding.vim deleted file mode 100644 index 72f2d40e..00000000 --- a/vim/config/encoding.vim +++ /dev/null @@ -1,4 +0,0 @@ -" Use UTF-8 by default wherever possible -if has('multi_byte') - set encoding=utf-8 -endif diff --git a/vim/config/file.vim b/vim/config/file.vim deleted file mode 100644 index a0c99f6c..00000000 --- a/vim/config/file.vim +++ /dev/null @@ -1,40 +0,0 @@ -" Load plugins for file types -if has('autocmd') - filetype plugin indent on -endif - -" Bind \p to show filetype -nnoremap - \ p - \ :set filetype? - -" Use all ancestors of current directory for :find -if has('file_in_path') - set path=** -endif - -" Try Mac line-endings if UNIX or DOS don't make sense; this has never -" happened to me but who knows, it might one day -set fileformats+=mac - -" If the Vim buffer for a file doesn't have any changes and Vim detects the -" file has been altered, quietly update it -set autoread - -" Save a file automatically if I change buffers or perform operations with the -" argument list; this is particularly helpful for me as I don't use 'hidden' -set autowrite - -" Don't use modelines at all, they're apparently potential security problems -" and I've never used them anyway -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 - \ :write! -nnoremap - \ ZA - \ :wall! diff --git a/vim/config/files.vim b/vim/config/files.vim new file mode 100644 index 00000000..7a23b4c5 --- /dev/null +++ b/vim/config/files.vim @@ -0,0 +1,45 @@ +" Load plugins for file types +if has('autocmd') + filetype plugin indent on +endif + +" Bind \p to show filetype +nnoremap + \ p + \ :set filetype? + +" Use UTF-8 by default wherever possible +if has('multi_byte') + set encoding=utf-8 +endif + +" Use all ancestors of current directory for :find +if has('file_in_path') + set path=** +endif + +" Try Mac line-endings if UNIX or DOS don't make sense; this has never +" happened to me but who knows, it might one day +set fileformats+=mac + +" If the Vim buffer for a file doesn't have any changes and Vim detects the +" file has been altered, quietly update it +set autoread + +" Save a file automatically if I change buffers or perform operations with the +" argument list; this is particularly helpful for me as I don't use 'hidden' +set autowrite + +" Don't use modelines at all, they're apparently potential security problems +" and I've never used them anyway +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 + \ :write! +nnoremap + \ ZA + \ :wall! -- cgit v1.2.3 From 53eb321f050903dc57f81c6bec941dd84b8a25d5 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 21:32:56 +1300 Subject: Rename startup.vim to messages.vim More accurate given the content, and more likely to have other options set in it. --- vim/config/messages.vim | 3 +++ vim/config/startup.vim | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 vim/config/messages.vim delete mode 100644 vim/config/startup.vim (limited to 'vim') diff --git a/vim/config/messages.vim b/vim/config/messages.vim new file mode 100644 index 00000000..b99bebe1 --- /dev/null +++ b/vim/config/messages.vim @@ -0,0 +1,3 @@ +" Don't show the Vim startup message, I have registered Vim and donated to +" Uganda +set shortmess+=I diff --git a/vim/config/startup.vim b/vim/config/startup.vim deleted file mode 100644 index b99bebe1..00000000 --- a/vim/config/startup.vim +++ /dev/null @@ -1,3 +0,0 @@ -" Don't show the Vim startup message, I have registered Vim and donated to -" Uganda -set shortmess+=I -- cgit v1.2.3 From fb4aec5034cf398285082c8173b45f9267337d6c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 21:34:02 +1300 Subject: Move nrformats.vim content to format.vim --- vim/config/format.vim | 4 ++++ vim/config/nrformats.vim | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) delete mode 100644 vim/config/nrformats.vim (limited to 'vim') diff --git a/vim/config/format.vim b/vim/config/format.vim index e1da2d0b..6c71b5ee 100644 --- a/vim/config/format.vim +++ b/vim/config/format.vim @@ -1,3 +1,7 @@ +" Don't assume a number with a leading zero is octal; it's far more likely a +" zero-padded decimal, so increment and decrement with ^A and ^X on that basis +set nrformats-=octal + " Try to set the 'j' flag for 'formatoptions', to automatically delete comment " leaders when joining lines silent! set formatoptions+=j diff --git a/vim/config/nrformats.vim b/vim/config/nrformats.vim deleted file mode 100644 index 09fe8c73..00000000 --- a/vim/config/nrformats.vim +++ /dev/null @@ -1,3 +0,0 @@ -" Don't assume a number with a leading zero is octal; it's far more likely a -" zero-padded decimal, so increment and decrement with ^A and ^X on that basis -set nrformats-=octal -- cgit v1.2.3 From 9be63f590dbe5a1de03220a3e2826778309038d2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 21:34:47 +1300 Subject: Rename yank.vim to registers.vim More likely to share options this way. --- vim/config/registers.vim | 4 ++++ vim/config/yank.vim | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 vim/config/registers.vim delete mode 100644 vim/config/yank.vim (limited to 'vim') diff --git a/vim/config/registers.vim b/vim/config/registers.vim new file mode 100644 index 00000000..01879aa8 --- /dev/null +++ b/vim/config/registers.vim @@ -0,0 +1,4 @@ +" Change and delete with C and D both cut off the remainder of the line from +" the cursor, but Y yanks the whole line, which is inconsistent (and can be +" done with yy anyway); this fixes it so it only yanks the rest of the line +nnoremap Y y$ diff --git a/vim/config/yank.vim b/vim/config/yank.vim deleted file mode 100644 index 01879aa8..00000000 --- a/vim/config/yank.vim +++ /dev/null @@ -1,4 +0,0 @@ -" Change and delete with C and D both cut off the remainder of the line from -" the cursor, but Y yanks the whole line, which is inconsistent (and can be -" done with yy anyway); this fixes it so it only yanks the rest of the line -nnoremap Y y$ -- cgit v1.2.3 From 559199f9d1b65c0f17d86540838892bf9c137cf1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 21:36:05 +1300 Subject: Rename term.vim to terminal.vim A little clearer and a needless abbreviation anyway. --- vim/config/term.vim | 24 ------------------------ vim/config/terminal.vim | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 24 deletions(-) delete mode 100644 vim/config/term.vim create mode 100644 vim/config/terminal.vim (limited to 'vim') diff --git a/vim/config/term.vim b/vim/config/term.vim deleted file mode 100644 index 8dbda431..00000000 --- a/vim/config/term.vim +++ /dev/null @@ -1,24 +0,0 @@ -" Don't bother about checking whether Escape is being used as a means to enter -" a Meta-key combination, just register Escape immediately -set noesckeys - -" Don't bother drawing the screen while executing macros or other automated or -" scripted processes, just draw the screen as it is when the operation -" completes -set lazyredraw - -" Improve redrawing smoothness by assuming that my terminal is reasonably -" fast -set ttyfast - -" Never use any kind of bell, visual or not -set visualbell t_vb= - -" Require less than one second between keys for mappings to work correctly -set timeout -set timeoutlen=1000 - -" Require less than a twentieth of a second between keys for key codes to work -" correctly; I don't use Escape as a meta key anyway -set ttimeout -set ttimeoutlen=50 diff --git a/vim/config/terminal.vim b/vim/config/terminal.vim new file mode 100644 index 00000000..8dbda431 --- /dev/null +++ b/vim/config/terminal.vim @@ -0,0 +1,24 @@ +" Don't bother about checking whether Escape is being used as a means to enter +" a Meta-key combination, just register Escape immediately +set noesckeys + +" Don't bother drawing the screen while executing macros or other automated or +" scripted processes, just draw the screen as it is when the operation +" completes +set lazyredraw + +" Improve redrawing smoothness by assuming that my terminal is reasonably +" fast +set ttyfast + +" Never use any kind of bell, visual or not +set visualbell t_vb= + +" Require less than one second between keys for mappings to work correctly +set timeout +set timeoutlen=1000 + +" Require less than a twentieth of a second between keys for key codes to work +" correctly; I don't use Escape as a meta key anyway +set ttimeout +set ttimeoutlen=50 -- cgit v1.2.3 From 5fe67e55ae268274df1b1010f6207130d8bbbc73 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 21:36:30 +1300 Subject: Rename complete.vim to completion.vim Clearer filename and more consistent to use the noun. --- vim/config/complete.vim | 3 --- vim/config/completion.vim | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 vim/config/complete.vim create mode 100644 vim/config/completion.vim (limited to 'vim') diff --git a/vim/config/complete.vim b/vim/config/complete.vim deleted file mode 100644 index 5fcc0e62..00000000 --- a/vim/config/complete.vim +++ /dev/null @@ -1,3 +0,0 @@ -" Don't try to complete strings from included files, just use the strings in -" the open buffers; I'll open the file if I want to complete from it -set complete-=i diff --git a/vim/config/completion.vim b/vim/config/completion.vim new file mode 100644 index 00000000..5fcc0e62 --- /dev/null +++ b/vim/config/completion.vim @@ -0,0 +1,3 @@ +" Don't try to complete strings from included files, just use the strings in +" the open buffers; I'll open the file if I want to complete from it +set complete-=i -- cgit v1.2.3 From 3592b950fc75003077cd4d208553f344bf6d892e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 21:37:27 +1300 Subject: Move wildmenu config into completion.vim --- vim/config/completion.vim | 24 ++++++++++++++++++++++++ vim/config/wildmenu.vim | 23 ----------------------- 2 files changed, 24 insertions(+), 23 deletions(-) delete mode 100644 vim/config/wildmenu.vim (limited to 'vim') diff --git a/vim/config/completion.vim b/vim/config/completion.vim index 5fcc0e62..d9db2113 100644 --- a/vim/config/completion.vim +++ b/vim/config/completion.vim @@ -1,3 +1,27 @@ " Don't try to complete strings from included files, just use the strings in " the open buffers; I'll open the file if I want to complete from it set complete-=i + +" Configuration for the command completion feature; rather than merely cycling +" through possible completions with Tab, show them above the command line +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 + + " Don't complete certain files that I'm not likely to want to manipulate + " from within Vim: + if has('wildignore') + set wildignore+=*.a,*.o + set wildignore+=*.bmp,*.gif,*.ico,*.jpg,*.png + set wildignore+=.DS_Store,.git,.hg,.svn + set wildignore+=*~,*.swp,*.tmp + endif + + " Complete files without case sensitivity, if the option is available + if exists('&wildignorecase') + set wildignorecase + endif +endif diff --git a/vim/config/wildmenu.vim b/vim/config/wildmenu.vim deleted file mode 100644 index 6036c90a..00000000 --- a/vim/config/wildmenu.vim +++ /dev/null @@ -1,23 +0,0 @@ -" Configuration for the command completion feature; rather than merely cycling -" through possible completions with Tab, show them above the command line -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 - - " Don't complete certain files that I'm not likely to want to manipulate - " from within Vim: - if has('wildignore') - set wildignore+=*.a,*.o - set wildignore+=*.bmp,*.gif,*.ico,*.jpg,*.png - set wildignore+=.DS_Store,.git,.hg,.svn - set wildignore+=*~,*.swp,*.tmp - endif - - " Complete files without case sensitivity, if the option is available - if exists('&wildignorecase') - set wildignorecase - endif -endif -- cgit v1.2.3 From 3719d9a42f339e40f3e74657cedc2aa9b25f6820 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 21:38:41 +1300 Subject: Move 'paste' options into terminal.vim 'paste' is specific to the terminal only anyway. --- vim/config/paste.vim | 6 ------ vim/config/terminal.vim | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) delete mode 100644 vim/config/paste.vim (limited to 'vim') diff --git a/vim/config/paste.vim b/vim/config/paste.vim deleted file mode 100644 index fa26d6f4..00000000 --- a/vim/config/paste.vim +++ /dev/null @@ -1,6 +0,0 @@ -" Start paste mode with F10 to prevent console Vim from confusing a swathe of -" pre-formatted pasted text with actual keyboard input, and thereby attempting -" to indent it inappropriately. If unimpaired.vim is available, it's generally -" nicer to use yo or yO. -set nopaste -set pastetoggle= diff --git a/vim/config/terminal.vim b/vim/config/terminal.vim index 8dbda431..202705a7 100644 --- a/vim/config/terminal.vim +++ b/vim/config/terminal.vim @@ -1,3 +1,10 @@ +" Start paste mode with F10 to prevent console Vim from confusing a swathe of +" pre-formatted pasted text with actual keyboard input, and thereby attempting +" to indent it inappropriately. If unimpaired.vim is available, it's generally +" nicer to use yo or yO. +set nopaste +set pastetoggle= + " Don't bother about checking whether Escape is being used as a means to enter " a Meta-key combination, just register Escape immediately set noesckeys -- cgit v1.2.3 From 44d807167f1cf122e83e4a9b7c5c15409ab3d96d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 21:41:52 +1300 Subject: Rearrange three smaller files into display.vim --- vim/config/display.vim | 16 ++++++++++++++++ vim/config/list.vim | 10 ---------- vim/config/messages.vim | 3 --- vim/config/number.vim | 5 ----- vim/config/wrap.vim | 4 ++++ 5 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 vim/config/display.vim delete mode 100644 vim/config/list.vim delete mode 100644 vim/config/messages.vim delete mode 100644 vim/config/number.vim (limited to 'vim') diff --git a/vim/config/display.vim b/vim/config/display.vim new file mode 100644 index 00000000..bb160915 --- /dev/null +++ b/vim/config/display.vim @@ -0,0 +1,16 @@ +" Don't show the Vim startup message, I have registered Vim and donated to +" Uganda +set shortmess+=I + +" 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! list? + +" Don't show line numbers by default, but \n toggles them +set nonumber +nnoremap + \ n + \ :setlocal number! number? diff --git a/vim/config/list.vim b/vim/config/list.vim deleted file mode 100644 index 1cb4345b..00000000 --- a/vim/config/list.vim +++ /dev/null @@ -1,10 +0,0 @@ -" 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! 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/messages.vim b/vim/config/messages.vim deleted file mode 100644 index b99bebe1..00000000 --- a/vim/config/messages.vim +++ /dev/null @@ -1,3 +0,0 @@ -" Don't show the Vim startup message, I have registered Vim and donated to -" Uganda -set shortmess+=I diff --git a/vim/config/number.vim b/vim/config/number.vim deleted file mode 100644 index becc20f1..00000000 --- a/vim/config/number.vim +++ /dev/null @@ -1,5 +0,0 @@ -" Don't show line numbers by default, but \n toggles them -set nonumber -nnoremap - \ n - \ :setlocal number! number? diff --git a/vim/config/wrap.vim b/vim/config/wrap.vim index 51e9ea89..8c7829ba 100644 --- a/vim/config/wrap.vim +++ b/vim/config/wrap.vim @@ -9,6 +9,10 @@ nnoremap " column with @ symbols instead, which I don't find very helpful set display=lastline +" 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:> + " When wrapping, j and k should move by screen row, and not to the same " column number in the previous logical line, which feels very clumsy and is " seldom particularly helpful; you can use n| to jump to the nth column in a -- cgit v1.2.3 From 46b5707961e63b7423d20fe8be42dcde0e8912e7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 21:42:32 +1300 Subject: Remove 'tildeop' setting I never use it. May as well defer to the vi default. --- vim/config/case.vim | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 vim/config/case.vim (limited to 'vim') diff --git a/vim/config/case.vim b/vim/config/case.vim deleted file mode 100644 index bb21aefd..00000000 --- a/vim/config/case.vim +++ /dev/null @@ -1,3 +0,0 @@ -" Use the tilde as an operator with motions, rather than just swapping the -" case of the character under the cursor -set tildeop -- cgit v1.2.3 From 6759051d4c92baf050393ae77e7506005d85f259 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 21:43:48 +1300 Subject: Move fedora.vim into os.vim For OS-dependent config. --- vim/config/fedora.vim | 8 -------- vim/config/os.vim | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) delete mode 100644 vim/config/fedora.vim create mode 100644 vim/config/os.vim (limited to 'vim') diff --git a/vim/config/fedora.vim b/vim/config/fedora.vim deleted file mode 100644 index ff6cadfc..00000000 --- a/vim/config/fedora.vim +++ /dev/null @@ -1,8 +0,0 @@ -" Fedora's default environment adds a few auto commands that I don't like, -" including the 'return to previous position in buffer' one; fortunately -" they're nice enough to group the commands, so I can just clear them -if has('autocmd') - augroup fedora - autocmd! - augroup END -endif diff --git a/vim/config/os.vim b/vim/config/os.vim new file mode 100644 index 00000000..ff6cadfc --- /dev/null +++ b/vim/config/os.vim @@ -0,0 +1,8 @@ +" Fedora's default environment adds a few auto commands that I don't like, +" including the 'return to previous position in buffer' one; fortunately +" they're nice enough to group the commands, so I can just clear them +if has('autocmd') + augroup fedora + autocmd! + augroup END +endif -- cgit v1.2.3 From 209bea8a39edd8313d1c168071c4ec2a926f0e53 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 21:44:28 +1300 Subject: Remove 'shellslash' setting This will allow the Windows-specific stuff in my new auto_* plugins to quote filenames correctly. --- vim/config/command.vim | 6 ------ 1 file changed, 6 deletions(-) (limited to 'vim') diff --git a/vim/config/command.vim b/vim/config/command.vim index 09ee0f40..a789fd6d 100644 --- a/vim/config/command.vim +++ b/vim/config/command.vim @@ -20,12 +20,6 @@ endif " Don't write the output of :make to the terminal set shellpipe=> -" Always use forward slashes, I very seldom need to use Vim on Windows for -" more than scratch space anyway -if exists('+shellslash') - set shellslash -endif - " \d inserts the current local date from date(1) nnoremap \ d -- cgit v1.2.3 From e24c0416f1d687f0ccb0f4f0ed526ab60b8449cf Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 21:45:03 +1300 Subject: Rename netrw.vim to plugin.vim For plugin-specific configuration. --- vim/config/netrw.vim | 16 ---------------- vim/config/plugin.vim | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 vim/config/netrw.vim create mode 100644 vim/config/plugin.vim (limited to 'vim') diff --git a/vim/config/netrw.vim b/vim/config/netrw.vim deleted file mode 100644 index b38649b9..00000000 --- a/vim/config/netrw.vim +++ /dev/null @@ -1,16 +0,0 @@ -" netrw plugin configuration -if has('eval') - - " Don't show the preamble banner - let g:netrw_banner = 0 - - " Perform file transfers silently - let g:netrw_silent = 1 - - " Use a tree-style file listing - let g:netrw_liststyle = 3 - - " Don't list the current directory shortcut, and don't show tags files - let g:netrw_list_hide = '^\.$,^tags$' - -endif diff --git a/vim/config/plugin.vim b/vim/config/plugin.vim new file mode 100644 index 00000000..b38649b9 --- /dev/null +++ b/vim/config/plugin.vim @@ -0,0 +1,16 @@ +" netrw plugin configuration +if has('eval') + + " Don't show the preamble banner + let g:netrw_banner = 0 + + " Perform file transfers silently + let g:netrw_silent = 1 + + " Use a tree-style file listing + let g:netrw_liststyle = 3 + + " Don't list the current directory shortcut, and don't show tags files + let g:netrw_list_hide = '^\.$,^tags$' + +endif -- cgit v1.2.3 From bb49f6a3164d0f3cf71ce3e60b46ca55ad9ae59a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 21:45:32 +1300 Subject: Move matchit.vim sourcing into plugin.vim --- vim/config/match.vim | 4 ---- vim/config/plugin.vim | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'vim') diff --git a/vim/config/match.vim b/vim/config/match.vim index 896e1d63..58bcce78 100644 --- a/vim/config/match.vim +++ b/vim/config/match.vim @@ -1,6 +1,2 @@ -" Try to run the version of matchit.vim included in the distribution, if there -" is one; extends % to match more than it does by default -silent! runtime macros/matchit.vim - " Match all forms of brackets in pairs (including angle brackets) set matchpairs+=<:> diff --git a/vim/config/plugin.vim b/vim/config/plugin.vim index b38649b9..407f0880 100644 --- a/vim/config/plugin.vim +++ b/vim/config/plugin.vim @@ -1,3 +1,7 @@ +" Try to run the version of matchit.vim included in the distribution, if there +" is one; extends % to match more than it does by default +silent! runtime macros/matchit.vim + " netrw plugin configuration if has('eval') -- cgit v1.2.3 From 3e29d5a95693a5ffd5e78622f560f415743b0736 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 21:48:23 +1300 Subject: Adjust some whitespace and comment layout --- vim/config/command.vim | 7 ++++--- vim/config/completion.vim | 1 + vim/config/format.vim | 1 + vim/config/search.vim | 1 + vim/config/spell.vim | 1 + vim/config/undo.vim | 3 +++ vim/config/windows.vim | 1 + 7 files changed, 12 insertions(+), 3 deletions(-) (limited to 'vim') diff --git a/vim/config/command.vim b/vim/config/command.vim index a789fd6d..031772e9 100644 --- a/vim/config/command.vim +++ b/vim/config/command.vim @@ -4,6 +4,9 @@ set history=2000 " Always tell me the number of lines changed by a command set report=0 +" Don't write the output of :make to the terminal +set shellpipe=> + " Command-line based features if has('cmdline_info') @@ -15,10 +18,8 @@ if has('cmdline_info') " Show the mode we're using if not normal mode (e.g. --INSERT--) set showmode -endif -" Don't write the output of :make to the terminal -set shellpipe=> +endif " \d inserts the current local date from date(1) nnoremap diff --git a/vim/config/completion.vim b/vim/config/completion.vim index d9db2113..854ffea7 100644 --- a/vim/config/completion.vim +++ b/vim/config/completion.vim @@ -24,4 +24,5 @@ if has('wildmenu') if exists('&wildignorecase') set wildignorecase endif + endif diff --git a/vim/config/format.vim b/vim/config/format.vim index 6c71b5ee..97ebcb11 100644 --- a/vim/config/format.vim +++ b/vim/config/format.vim @@ -34,4 +34,5 @@ if has('user_commands') nnoremap \ t \ :ToggleOptionFlagLocal formatoptions t + endif diff --git a/vim/config/search.vim b/vim/config/search.vim index ff243116..69f3f472 100644 --- a/vim/config/search.vim +++ b/vim/config/search.vim @@ -33,4 +33,5 @@ if has('extra_search') \ setlocal hlsearch augroup END endif + endif diff --git a/vim/config/spell.vim b/vim/config/spell.vim index 7775ade9..cbbe17f1 100644 --- a/vim/config/spell.vim +++ b/vim/config/spell.vim @@ -17,4 +17,5 @@ if has('spell') nnoremap \ z \ :setlocal spelllang=en_nz spelllang? + endif diff --git a/vim/config/undo.vim b/vim/config/undo.vim index c31780e7..f85d9d8c 100644 --- a/vim/config/undo.vim +++ b/vim/config/undo.vim @@ -7,6 +7,8 @@ set undolevels=2000 " 'undodir' and 'undofile' settings will be taken care of by the " auto_undodir.vim plugin if applicable/possible if has('persistent_undo') + + " Turn off the option by default set noundofile " Don't keep undo files from temporary directories or shared memory in case @@ -19,4 +21,5 @@ if has('persistent_undo') \ setlocal noundofile augroup END endif + endif diff --git a/vim/config/windows.vim b/vim/config/windows.vim index a54b8997..a0492c76 100644 --- a/vim/config/windows.vim +++ b/vim/config/windows.vim @@ -24,4 +24,5 @@ if has('windows') if has('folding') let &fillchars = 'diff: ,fold: ,vert: ' endif + endif -- cgit v1.2.3 From 8b79ec9365491f8fb2bd48452b6aca68d2b673d2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 21:54:42 +1300 Subject: Use exists+ test rather than exists& From :help hidden-options: >Not all options are supported in all versions. This depends on the >supported features and sometimes on the system. A remark about this is >in curly braces below. When an option is not supported it may still be >set without getting an error, this is called a hidden option. You can't >get the value of a hidden option though, it is not stored. > >To test if option "foo" can be used with ":set" use something like this: > if exists('&foo') >This also returns true for a hidden option. To test if option "foo" is >really supported use something like this: > if exists('+foo') --- vim/config/completion.vim | 2 +- vim/config/windows.vim | 2 +- vim/config/wrap.vim | 2 +- vim/plugin/big_file_options.vim | 2 +- vim/plugin/copy_linebreak.vim | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'vim') diff --git a/vim/config/completion.vim b/vim/config/completion.vim index 854ffea7..a8a5c201 100644 --- a/vim/config/completion.vim +++ b/vim/config/completion.vim @@ -21,7 +21,7 @@ if has('wildmenu') endif " Complete files without case sensitivity, if the option is available - if exists('&wildignorecase') + if exists('+wildignorecase') set wildignorecase endif diff --git a/vim/config/windows.vim b/vim/config/windows.vim index a0492c76..88b38f8c 100644 --- a/vim/config/windows.vim +++ b/vim/config/windows.vim @@ -16,7 +16,7 @@ if has('windows') endif " Only show the tab bar if there's more than one tab - if exists('&showtabline') + if exists('+showtabline') set showtabline=1 endif diff --git a/vim/config/wrap.vim b/vim/config/wrap.vim index 8c7829ba..a90c2765 100644 --- a/vim/config/wrap.vim +++ b/vim/config/wrap.vim @@ -30,7 +30,7 @@ if has('linebreak') set showbreak=... " If we have the option, indent wrapped lines as much as the first line - if has('&breakindent') + if exists('+breakindent') set breakindent endif diff --git a/vim/plugin/big_file_options.vim b/vim/plugin/big_file_options.vim index bbbedc96..cdced67d 100644 --- a/vim/plugin/big_file_options.vim +++ b/vim/plugin/big_file_options.vim @@ -44,7 +44,7 @@ function! s:BigFileOptions() endif " Limit the number of columns of syntax highlighting - if exists('&synmaxcol') + if exists('+synmaxcol') \ && &synmaxcol > g:big_file_synmaxcol execute 'setlocal synmaxcol=' . g:big_file_synmaxcol endif diff --git a/vim/plugin/copy_linebreak.vim b/vim/plugin/copy_linebreak.vim index 2b5f7243..732acfea 100644 --- a/vim/plugin/copy_linebreak.vim +++ b/vim/plugin/copy_linebreak.vim @@ -17,7 +17,7 @@ let g:loaded_copy_linebreak = 1 function! s:CopyLinebreakEnable() setlocal nolinebreak linebreak? setlocal showbreak= - if exists('&breakindent') + if exists('+breakindent') setlocal nobreakindent endif endfunction @@ -26,7 +26,7 @@ endfunction function! s:CopyLinebreakDisable() setlocal linebreak linebreak? setlocal showbreak< - if exists('&breakindent') + if exists('+breakindent') setlocal breakindent< endif endfunction -- cgit v1.2.3 From ab808d7dcfedda770e648ed6a731a1f17e900db8 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 22:29:14 +1300 Subject: Set up individual flags for 'shortmess' Most of these are actually the default; may as well explicitly set and document them, however. t and T in particular are new. --- vim/config/display.vim | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'vim') diff --git a/vim/config/display.vim b/vim/config/display.vim index bb160915..1f186572 100644 --- a/vim/config/display.vim +++ b/vim/config/display.vim @@ -1,5 +1,26 @@ -" Don't show the Vim startup message, I have registered Vim and donated to -" Uganda +" Set up short message settings +set shortmess= +" (file 3 of 5) -> (3 of 5) +set shortmess+=f +" [Incomplete last line] -> [eol] +set shortmess+=i +" 999 lines, 888 characters -> 999L, 888C +set shortmess+=l +" [Modified] -> [+] +set shortmess+=m +" [New File] -> [New] +set shortmess+=n +" [readonly] -> [RO] +set shortmess+=r +" written -> [w], appended -> [a] +set shortmess+=w +" [dos format] -> [dos] +set shortmess+=x +" Truncate file message at start if too long +set shortmess+=t +" Truncate other message in midle if too long +set shortmess+=T +" I donated to Uganda, thanks Bram set shortmess+=I " Don't show whitespace characters or end-of-line characters visually by -- cgit v1.2.3 From 36464257ccdf992bf5d808694c40ff62e1c85604 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 23:57:01 +1300 Subject: Add 'o' and 'O' back into 'shortmess' These flags prevent multiple messages from reading or writing multiple files from queuing up and forcing an enter prompt. They're part of the default, which is why I didn't notice their absence until I tried using the setting previous to this commit and opened two files at once. --- vim/config/display.vim | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'vim') diff --git a/vim/config/display.vim b/vim/config/display.vim index 1f186572..37ef18c7 100644 --- a/vim/config/display.vim +++ b/vim/config/display.vim @@ -10,6 +10,10 @@ set shortmess+=l set shortmess+=m " [New File] -> [New] set shortmess+=n +" Don't stack file writing messages +set shortmess+=o +" Don't stack file reading messages +set shortmess+=O " [readonly] -> [RO] set shortmess+=r " written -> [w], appended -> [a] -- cgit v1.2.3 From 41d238d0d9d835471e3b85c2f4d2dfb38cae2e3e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 10 Nov 2017 23:59:35 +1300 Subject: Sort 'shortmess' flag settings alphabetically --- vim/config/display.vim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'vim') diff --git a/vim/config/display.vim b/vim/config/display.vim index 37ef18c7..43889c1a 100644 --- a/vim/config/display.vim +++ b/vim/config/display.vim @@ -4,6 +4,8 @@ set shortmess= set shortmess+=f " [Incomplete last line] -> [eol] set shortmess+=i +" I donated to Uganda, thanks Bram +set shortmess+=I " 999 lines, 888 characters -> 999L, 888C set shortmess+=l " [Modified] -> [+] @@ -16,16 +18,14 @@ set shortmess+=o set shortmess+=O " [readonly] -> [RO] set shortmess+=r -" written -> [w], appended -> [a] -set shortmess+=w -" [dos format] -> [dos] -set shortmess+=x " Truncate file message at start if too long set shortmess+=t " Truncate other message in midle if too long set shortmess+=T -" I donated to Uganda, thanks Bram -set shortmess+=I +" written -> [w], appended -> [a] +set shortmess+=w +" [dos format] -> [dos] +set shortmess+=x " Don't show whitespace characters or end-of-line characters visually by " default, but make \l toggle between them -- cgit v1.2.3 From fe8e94bea39895f2544ae83916da83a4f2affa21 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 11 Nov 2017 00:59:12 +1300 Subject: Add new mail_mutt.vim plugin, apply mappings This plugin provides a shortcut for staring email messages in Mutt with a range of lines. --- vim/config/command.vim | 19 +++++++++++-------- vim/doc/mail_mutt.txt | 13 +++++++++++++ vim/plugin/mail_mutt.vim | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 vim/doc/mail_mutt.txt create mode 100644 vim/plugin/mail_mutt.vim (limited to 'vim') diff --git a/vim/config/command.vim b/vim/config/command.vim index a8861583..705f29b0 100644 --- a/vim/config/command.vim +++ b/vim/config/command.vim @@ -35,12 +35,15 @@ nnoremap \ D \ :read !date -u -" \m fires up mutt with either the whole buffer or the text -function s:Mutt() - let l:tf = tempname() - execute 'write '.fnameescape(l:tf) - execute '!mutt -i '.shellescape(l:tf) -endfunction -nnoremap +" \m in normal mode starts a mail message with the current line +nmap + \ m + \ :.MailMutt +" \M in normal mode starts a mail message with the whole buffer +nmap + \ M + \ :%MailMutt +" \m in visual mode starts a mail message with the selected lines +vmap \ m - \ :call Mutt() + \ :MailMutt diff --git a/vim/doc/mail_mutt.txt b/vim/doc/mail_mutt.txt new file mode 100644 index 00000000..dbaf72ac --- /dev/null +++ b/vim/doc/mail_mutt.txt @@ -0,0 +1,13 @@ +*mail_mutt.txt* Start a mutt(1) email message with a range of lines + +Author: Tom Ryder +License: Same terms as Vim itself (see |license|) + +This plugin provides a :MailMutt command which accepts a range of lines +defaulting to the entire buffer, writing these lines to a temporary file that +is then provided to the -i option of the mutt(1) MUA as the initial content of +a new message. + +This plugin lives in Tom Ryder's "dotfiles" suite, and will eventually be spun +off into a separate distribution as it solidifies and this documentation +improves. diff --git a/vim/plugin/mail_mutt.vim b/vim/plugin/mail_mutt.vim new file mode 100644 index 00000000..67444e4d --- /dev/null +++ b/vim/plugin/mail_mutt.vim @@ -0,0 +1,41 @@ +" +" mail_mutt.vim: Start a mutt(1) message with the lines in the given range, +" defaulting to the entire buffer. +" +" Author: Tom Ryder +" License: Same as Vim itself +" +if exists('g:loaded_mail_mutt') + \ || !has('user_commands') + \ || &compatible + finish +endif +let g:loaded_mail_mutt = 1 + +" Declare function +function! s:MailMutt(start, end) + + " Check we'll have mutt(1) to execute + if !executable('mutt') + echoerr 'mutt not found in $PATH' + finish + endif + + " Create a temporary file + let l:tf = tempname() + + " Write the contents of the buffer to it + let l:range = a:start . ',' . a:end + let l:command = 'write ' . fnameescape(l:tf) + execute l:range . l:command + + + " Run mutt(1) with that file as its input + execute '!mutt -i ' . shellescape(l:tf) + +endfunction + +" Create a command to wrap around that function +command -nargs=0 -range=% + \ MailMutt + \ call MailMutt(, ) -- cgit v1.2.3 From f9600abb2182b467dfd24ce16e3eebed26723338 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 11 Nov 2017 01:05:15 +1300 Subject: Move mutt_mail.vim line select logic into plugin This makes the configuration shorter and easier to read. --- vim/config/command.vim | 14 ++++---------- vim/plugin/mail_mutt.vim | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'vim') diff --git a/vim/config/command.vim b/vim/config/command.vim index 705f29b0..e3f7c473 100644 --- a/vim/config/command.vim +++ b/vim/config/command.vim @@ -35,15 +35,9 @@ nnoremap \ D \ :read !date -u +" \m in visual/select mode starts a mail message with the selected lines +vmap m MailMuttSelected " \m in normal mode starts a mail message with the current line -nmap - \ m - \ :.MailMutt +nmap m MailMuttLine " \M in normal mode starts a mail message with the whole buffer -nmap - \ M - \ :%MailMutt -" \m in visual mode starts a mail message with the selected lines -vmap - \ m - \ :MailMutt +nmap M MailMuttBuffer diff --git a/vim/plugin/mail_mutt.vim b/vim/plugin/mail_mutt.vim index 67444e4d..9bb4abd4 100644 --- a/vim/plugin/mail_mutt.vim +++ b/vim/plugin/mail_mutt.vim @@ -39,3 +39,18 @@ endfunction command -nargs=0 -range=% \ MailMutt \ call MailMutt(, ) + +" Mapping to mail current line in normal mode +nnoremap + \ MailMuttLine + \ :.MailMutt + +" Mapping to mail whole buffer in normal mode +nnoremap + \ MailMuttBuffer + \ :%MailMutt + +" Mapping to mail selected lines in visual/select mode +vnoremap + \ MailMuttSelected + \ :MailMutt -- cgit v1.2.3