aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--VERSION4
-rw-r--r--bin/oii.mi513
-rw-r--r--man/man1/oii.1df6
-rw-r--r--vim/after/syntax/sh.vim19
-rw-r--r--vim/config/backup.vim33
-rw-r--r--vim/config/case.vim3
-rw-r--r--vim/config/command.vim18
-rw-r--r--vim/config/complete.vim3
-rw-r--r--vim/config/completion.vim (renamed from vim/config/wildmenu.vim)7
-rw-r--r--vim/config/display.vim41
-rw-r--r--vim/config/encoding.vim4
-rw-r--r--vim/config/files.vim (renamed from vim/config/file.vim)5
-rw-r--r--vim/config/format.vim5
-rw-r--r--vim/config/indent.vim24
-rw-r--r--vim/config/join.vim10
-rw-r--r--vim/config/list.vim10
-rw-r--r--vim/config/match.vim6
-rw-r--r--vim/config/nrformats.vim3
-rw-r--r--vim/config/number.vim5
-rw-r--r--vim/config/os.vim (renamed from vim/config/fedora.vim)0
-rw-r--r--vim/config/paste.vim6
-rw-r--r--vim/config/plugin.vim (renamed from vim/config/netrw.vim)4
-rw-r--r--vim/config/registers.vim (renamed from vim/config/yank.vim)0
-rw-r--r--vim/config/search.vim1
-rw-r--r--vim/config/spell.vim1
-rw-r--r--vim/config/startup.vim3
-rw-r--r--vim/config/swapfile.vim44
-rw-r--r--vim/config/terminal.vim (renamed from vim/config/term.vim)7
-rw-r--r--vim/config/undo.vim23
-rw-r--r--vim/config/whitespace.vim33
-rw-r--r--vim/config/windows.vim3
-rw-r--r--vim/config/wrap.vim6
-rw-r--r--vim/doc/auto_backupdir.txt12
-rw-r--r--vim/doc/auto_swapdir.txt12
-rw-r--r--vim/doc/auto_undodir.txt14
-rw-r--r--vim/doc/mail_mutt.txt13
-rw-r--r--vim/plugin/auto_backupdir.vim56
-rw-r--r--vim/plugin/auto_swapdir.vim56
-rw-r--r--vim/plugin/auto_undodir.vim57
-rw-r--r--vim/plugin/big_file_options.vim2
-rw-r--r--vim/plugin/copy_linebreak.vim4
-rw-r--r--vim/plugin/mail_mutt.vim56
42 files changed, 459 insertions, 173 deletions
diff --git a/VERSION b/VERSION
index 1e286998..1d1240d5 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-tejr dotfiles v0.12.2
-Wed Nov 8 03:28:51 UTC 2017
+tejr dotfiles v0.13.0
+Fri Nov 10 12:06:47 UTC 2017
diff --git a/bin/oii.mi5 b/bin/oii.mi5
index 51f37fb4..914d45f9 100644
--- a/bin/oii.mi5
+++ b/bin/oii.mi5
@@ -11,9 +11,10 @@ fi
include(`include/mktd.m4')
%>
-# There is probably a way better way to do this than writing the whole file to
-# disk and then reading it off again, but until I think of something better,
-# this works and is byte-safe.
-cat - > "$td"/in
-[ -s "$td"/in ] || exit
-"$@" < "$td"/in
+# Read up to one byte and save it into temp file; discard stderr (stats)
+tf=$td/input
+dd bs=1 count=1 of="$tf" 2>/dev/null
+
+# If there's now a byte in the file, spit it and the rest of the input into the
+# requested command
+[ -s "$tf" ] && cat -- "$tf" - | "$@"
diff --git a/man/man1/oii.1df b/man/man1/oii.1df
index f5bb2678..6d1cf601 100644
--- a/man/man1/oii.1df
+++ b/man/man1/oii.1df
@@ -1,4 +1,4 @@
-.TH OII 1df "June 2017" "Manual page for oii"
+.TH OII 1df "November 2017" "Manual page for oii"
.SH NAME
.B oii
\- run a command on input only if there's at least one byte of input
@@ -13,9 +13,5 @@ CMD [ARGS ...]
Run the given program passing in stdin but only if at least one byte of input
is actually received, rather like the -E switch to mail(1) behaves on
bsd-mailx. If no input is received, exit silently with an error status.
-.SH CAVEATS
-It's slow, and doesn't work as a pipe. The entire input is written to disk and
-then tested for filesize before being re-emitted. There's almost certainly a
-more efficient way to do this while still remaining byte-safe.
.SH AUTHOR
Tom Ryder <tom@sanctum.geek.nz>
diff --git a/vim/after/syntax/sh.vim b/vim/after/syntax/sh.vim
index ba209e99..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')
@@ -100,6 +105,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="\<while\_s" end="\<do\>"me=e-2
+ \ contains=@shLoopList
+
+ " Run some clustering that core syntax/sh.vim thinks doesn't apply to POSIX;
+ " this fixes while loops so they can be within other blocks.
+ syntax cluster shCaseList add=shRepeat
+ syntax cluster shFunctionList add=shRepeat
+
endif
" Some corrections for highlighting specific to the Bash mode
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/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
diff --git a/vim/config/command.vim b/vim/config/command.vim
index 09ee0f40..e6679b84 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,15 +18,7 @@ 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=>
-
-" 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)
@@ -34,3 +29,10 @@ nnoremap <silent>
nnoremap <silent>
\ <Leader>D
\ :<C-U>read !date -u<CR>
+
+" \m in visual/select mode starts a mail message with the selected lines
+vmap <Leader>m <Plug>MailMuttSelected
+" \m in normal mode starts a mail message with the current line
+nmap <Leader>m <Plug>MailMuttLine
+" \M in normal mode starts a mail message with the whole buffer
+nmap <Leader>M <Plug>MailMuttBuffer
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/wildmenu.vim b/vim/config/completion.vim
index 6036c90a..a8a5c201 100644
--- a/vim/config/wildmenu.vim
+++ b/vim/config/completion.vim
@@ -1,3 +1,7 @@
+" 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')
@@ -17,7 +21,8 @@ if has('wildmenu')
endif
" Complete files without case sensitivity, if the option is available
- if exists('&wildignorecase')
+ if exists('+wildignorecase')
set wildignorecase
endif
+
endif
diff --git a/vim/config/display.vim b/vim/config/display.vim
new file mode 100644
index 00000000..43889c1a
--- /dev/null
+++ b/vim/config/display.vim
@@ -0,0 +1,41 @@
+" Set up short message settings
+set shortmess=
+" (file 3 of 5) -> (3 of 5)
+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] -> [+]
+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
+" Truncate file message at start if too long
+set shortmess+=t
+" Truncate other message in midle if too long
+set shortmess+=T
+" 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
+set nolist
+nnoremap <silent>
+ \ <Leader>l
+ \ :<C-U>setlocal list! list?<CR>
+
+" Don't show line numbers by default, but \n toggles them
+set nonumber
+nnoremap <silent>
+ \ <Leader>n
+ \ :<C-U>setlocal number! number?<CR>
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/files.vim
index a0c99f6c..7a23b4c5 100644
--- a/vim/config/file.vim
+++ b/vim/config/files.vim
@@ -8,6 +8,11 @@ nnoremap <silent>
\ <Leader>p
\ :<C-U>set filetype?<CR>
+" 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=**
diff --git a/vim/config/format.vim b/vim/config/format.vim
index e1da2d0b..97ebcb11 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
@@ -30,4 +34,5 @@ if has('user_commands')
nnoremap <silent>
\ <Leader>t
\ :<C-U>ToggleOptionFlagLocal formatoptions t<CR>
+
endif
diff --git a/vim/config/indent.vim b/vim/config/indent.vim
deleted file mode 100644
index f6dfd416..00000000
--- a/vim/config/indent.vim
+++ /dev/null
@@ -1,24 +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
-
-" 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
-
-" 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 <Plug>FixedJoin
-endif
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 <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
-set listchars+=precedes:<,extends:>
diff --git a/vim/config/match.vim b/vim/config/match.vim
index 5c53d63e..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=(:),{:},[:],<:>
+set matchpairs+=<:>
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
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 <silent>
- \ <Leader>n
- \ :<C-U>setlocal number! number?<CR>
diff --git a/vim/config/fedora.vim b/vim/config/os.vim
index ff6cadfc..ff6cadfc 100644
--- a/vim/config/fedora.vim
+++ b/vim/config/os.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=<F10>
diff --git a/vim/config/netrw.vim b/vim/config/plugin.vim
index b38649b9..407f0880 100644
--- a/vim/config/netrw.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')
diff --git a/vim/config/yank.vim b/vim/config/registers.vim
index 01879aa8..01879aa8 100644
--- a/vim/config/yank.vim
+++ b/vim/config/registers.vim
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 <silent>
\ <Leader>z
\ :<C-U>setlocal spelllang=en_nz spelllang?<CR>
+
endif
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
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/term.vim b/vim/config/terminal.vim
index 8dbda431..202705a7 100644
--- a/vim/config/term.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=<F10>
+
" 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
diff --git a/vim/config/undo.vim b/vim/config/undo.vim
index c9539665..f85d9d8c 100644
--- a/vim/config/undo.vim
+++ b/vim/config/undo.vim
@@ -4,23 +4,15 @@ inoremap <C-c> <C-c>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')
- " 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//
+ " Turn off the option by default
+ set noundofile
- " 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!
@@ -29,4 +21,5 @@ if !strlen($SUDO_USER) && has('unix') && has('persistent_undo')
\ setlocal noundofile
augroup END
endif
+
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 <Plug>FixedJoin
+endif
+
" \x strips trailing whitespace via a custom plugin
nmap <Leader>x <Plug>StripTrailingWhitespace
diff --git a/vim/config/windows.vim b/vim/config/windows.vim
index a54b8997..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
@@ -24,4 +24,5 @@ if has('windows')
if has('folding')
let &fillchars = 'diff: ,fold: ,vert: '
endif
+
endif
diff --git a/vim/config/wrap.vim b/vim/config/wrap.vim
index 51e9ea89..a90c2765 100644
--- a/vim/config/wrap.vim
+++ b/vim/config/wrap.vim
@@ -9,6 +9,10 @@ nnoremap <silent>
" 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
@@ -26,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/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 <tom@sanctum.geek.nz>
+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 <tom@sanctum.geek.nz>
+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 <tom@sanctum.geek.nz>
+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/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 <tom@sanctum.geek.nz>
+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/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 <tom@sanctum.geek.nz>
+" 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 <tom@sanctum.geek.nz>
+" 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 <tom@sanctum.geek.nz>
+" 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
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
diff --git a/vim/plugin/mail_mutt.vim b/vim/plugin/mail_mutt.vim
new file mode 100644
index 00000000..9bb4abd4
--- /dev/null
+++ b/vim/plugin/mail_mutt.vim
@@ -0,0 +1,56 @@
+"
+" mail_mutt.vim: Start a mutt(1) message with the lines in the given range,
+" defaulting to the entire buffer.
+"
+" Author: Tom Ryder <tom@sanctum.geek.nz>
+" 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 <SID>MailMutt(<line1>, <line2>)
+
+" Mapping to mail current line in normal mode
+nnoremap <silent> <unique>
+ \ <Plug>MailMuttLine
+ \ :<C-U>.MailMutt<CR>
+
+" Mapping to mail whole buffer in normal mode
+nnoremap <silent> <unique>
+ \ <Plug>MailMuttBuffer
+ \ :<C-U>%MailMutt<CR>
+
+" Mapping to mail selected lines in visual/select mode
+vnoremap <silent> <unique>
+ \ <Plug>MailMuttSelected
+ \ :MailMutt<CR>