From 19f6f3b665834a684ffd0f1b25809222fa607888 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:19:35 +1300 Subject: Set up .d-style vimrc subdir for config breakup Before loading up all the plugins proper from ~/.vim/bundle with Pathogen, apply :runtime to load all .vim files in a new config directory, installed by the Makefile. I hope that this will enable me to break most of my .vimrc up into logically-arranged subfiles. This is just a guess at a good way of doing this that will almost certainly need refinement and restructuring later. --- Makefile | 2 ++ vim/config/test.vim | 2 ++ vim/vimrc | 4 ++++ 3 files changed, 8 insertions(+) create mode 100644 vim/config/test.vim diff --git a/Makefile b/Makefile index 6cfee7a1..630eaf79 100644 --- a/Makefile +++ b/Makefile @@ -462,7 +462,9 @@ install-vim: install-vim-config \ install-vim-pathogen install-vim-config: + mkdir -p -- $(HOME)/.vim/config cp -p -- vim/vimrc $(HOME)/.vimrc + cp -p -- vim/config/*.vim $(HOME)/.vim/config install-vim-gui: install-vim \ install-vim-gui-config diff --git a/vim/config/test.vim b/vim/config/test.vim new file mode 100644 index 00000000..b92ea09e --- /dev/null +++ b/vim/config/test.vim @@ -0,0 +1,2 @@ +" Confirm that config subfiles are loading correctly +echo "Config subfiles loading!" diff --git a/vim/vimrc b/vim/vimrc index b64e4290..a6a67dc7 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -7,6 +7,10 @@ if has('multi_byte') scriptencoding utf-8 endif +" Load configuration files from ~/.vim/config or its analogue, before Pathogen +" loads all its directories into 'runtimepath' +runtime config/*.vim + " If our version isn't ancient and Pathogen is available, call it to load all " the plugins in .vim/bundle; these are saved as submodules if v:version >= 701 -- cgit v1.2.3 From 974df16c51b86252fa0b53f4052d7c7369f48fed Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:24:00 +1300 Subject: Move backup .vimrc config into subfile Replace the test.vim file placed by 19f6f3 to do this. --- vim/config/backup.vim | 26 ++++++++++++++++++++++++++ vim/config/test.vim | 2 -- vim/vimrc | 27 --------------------------- 3 files changed, 26 insertions(+), 29 deletions(-) create mode 100644 vim/config/backup.vim delete mode 100644 vim/config/test.vim diff --git a/vim/config/backup.vim b/vim/config/backup.vim new file mode 100644 index 00000000..718647fc --- /dev/null +++ b/vim/config/backup.vim @@ -0,0 +1,26 @@ +" Use backup features if on a UNIX-like system and not using sudo(8) +if !strlen($SUDO_USER) && has('unix') + + " 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// + + " 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 diff --git a/vim/config/test.vim b/vim/config/test.vim deleted file mode 100644 index b92ea09e..00000000 --- a/vim/config/test.vim +++ /dev/null @@ -1,2 +0,0 @@ -" Confirm that config subfiles are loading correctly -echo "Config subfiles loading!" diff --git a/vim/vimrc b/vim/vimrc index a6a67dc7..9cbf309d 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -23,33 +23,6 @@ if has('autocmd') filetype indent plugin on endif -" Use backup features if on a UNIX-like system and not using sudo(8) -if !strlen($SUDO_USER) && has('unix') - - " 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// - - " 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 - " Options dependent on the syntax feature if has('syntax') -- cgit v1.2.3 From 8bbfbf3365159c670b3a634f2fbb11af0ca181d0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:27:51 +1300 Subject: Move undo .vimrc config into subfile Interestingly, this does not seem to work, and this configuration doesn't get loaded; I suspect the :runtime line is not quite right. --- vim/config/undo.vim | 32 ++++++++++++++++++++++++++++++++ vim/vimrc | 33 --------------------------------- 2 files changed, 32 insertions(+), 33 deletions(-) create mode 100644 vim/config/undo.vim diff --git a/vim/config/undo.vim b/vim/config/undo.vim new file mode 100644 index 00000000..3df06d80 --- /dev/null +++ b/vim/config/undo.vim @@ -0,0 +1,32 @@ +" Rebind Ctrl-C in insert mode to undo the current insert operation +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') + + " 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 + if has('autocmd') + augroup undoskip + autocmd! + silent! autocmd BufWritePre + \ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/* + \ setlocal noundofile + augroup END + endif +endif diff --git a/vim/vimrc b/vim/vimrc index 9cbf309d..c3118f71 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -58,9 +58,6 @@ endif " the open buffers; I'll open the file if I want to complete from it set complete-=i -" Rebind Ctrl-C in insert mode to undo the current insert operation -inoremap u - " A few very important custom digraphs if has('digraphs') digraph ./ 8230 " Ellipsis (HORIZONTAL ELLIPSIS U+2026) @@ -344,36 +341,6 @@ if has('user_commands') command! -bang WA wa endif -" 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') - - " 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 - if has('autocmd') - augroup undoskip - autocmd! - silent! autocmd BufWritePre - \ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/* - \ setlocal noundofile - augroup END - endif -endif - " When in visual block mode, let me move the cursor anywhere in the buffer; " don't restrict me only to regions with text if has('virtualedit') -- cgit v1.2.3 From 04316986732bdd348b190c38a98cb4f14ea190a3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:30:54 +1300 Subject: Add ! to runtime for sourcing vimrc subfiles From :help :runtime: > When [!] is included, all found files are sourced. When it is not > included only the first found file is sourced. --- vim/vimrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/vimrc b/vim/vimrc index c3118f71..abe783cc 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -9,7 +9,7 @@ endif " Load configuration files from ~/.vim/config or its analogue, before Pathogen " loads all its directories into 'runtimepath' -runtime config/*.vim +runtime! config/*.vim " If our version isn't ancient and Pathogen is available, call it to load all " the plugins in .vim/bundle; these are saved as submodules -- cgit v1.2.3 From cf8d82653ae77b9927f18b24ac35f6b099da7c49 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:32:29 +1300 Subject: Move swapfile .vimrc config into subfile --- vim/config/swapfile.vim | 32 ++++++++++++++++++++++++++++++++ vim/vimrc | 33 --------------------------------- 2 files changed, 32 insertions(+), 33 deletions(-) create mode 100644 vim/config/swapfile.vim diff --git a/vim/config/swapfile.vim b/vim/config/swapfile.vim new file mode 100644 index 00000000..39e1ab95 --- /dev/null +++ b/vim/config/swapfile.vim @@ -0,0 +1,32 @@ +" 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 swapskip + autocmd! + silent! autocmd BufNewFile,BufReadPre + \ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/* + \ setlocal noswapfile + augroup END + endif + +" Otherwise, don't use swap files at all +else + set noswapfile +endif diff --git a/vim/vimrc b/vim/vimrc index abe783cc..8e83e144 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -268,39 +268,6 @@ endif nnoremap & :&& vnoremap & :&& -" 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 swapskip - autocmd! - silent! autocmd BufNewFile,BufReadPre - \ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/* - \ setlocal noswapfile - augroup END - endif - -" Otherwise, don't use swap files at all -else - set noswapfile -endif - " 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 d83db65420a1963fb83c13cbde50f0d0d1cdee92 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:33:46 +1300 Subject: Move search .vimrc config into subfile --- vim/config/search.vim | 26 ++++++++++++++++++++++++++ vim/vimrc | 27 --------------------------- 2 files changed, 26 insertions(+), 27 deletions(-) create mode 100644 vim/config/search.vim diff --git a/vim/config/search.vim b/vim/config/search.vim new file mode 100644 index 00000000..ed71bff8 --- /dev/null +++ b/vim/config/search.vim @@ -0,0 +1,26 @@ +" Some special settings for searching, if available +if has('extra_search') + + " Searching as I enter my pattern, \i toggles this + set incsearch + nnoremap i :set incsearch! + + " Highlight search results, \h toggles this + set hlsearch + nnoremap h :set hlsearch! + + " Pressing ^L will clear highlighting until the next search-related + " operation; quite good because the highlighting gets distracting after + " you've found what you wanted + nnoremap :nohlsearch + + " Clear search highlighting as soon as I enter insert mode, and restore it + " once I leave it + if has('autocmd') + augroup highlight + autocmd! + silent! autocmd InsertEnter * set nohlsearch + silent! autocmd InsertLeave * set hlsearch + augroup END + endif +endif diff --git a/vim/vimrc b/vim/vimrc index 8e83e144..3a579836 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -209,33 +209,6 @@ set autowrite set scrolloff=0 set sidescrolloff=16 -" Some special settings for searching, if available -if has('extra_search') - - " Searching as I enter my pattern, \i toggles this - set incsearch - nnoremap i :set incsearch! - - " Highlight search results, \h toggles this - set hlsearch - nnoremap h :set hlsearch! - - " Pressing ^L will clear highlighting until the next search-related - " operation; quite good because the highlighting gets distracting after - " you've found what you wanted - nnoremap :nohlsearch - - " Clear search highlighting as soon as I enter insert mode, and restore it - " once I leave it - if has('autocmd') - augroup highlight - autocmd! - silent! autocmd InsertEnter * set nohlsearch - silent! autocmd InsertLeave * set hlsearch - augroup END - endif -endif - " Configure spell checking features, if available if has('spell') -- cgit v1.2.3 From 5dba4c921de02ec6c4475b5cc1df8d35de3cc30e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:34:34 +1300 Subject: Move syntax highlight .vimrc config into subfile This appears to break my choice of syntax colorscheme; the order of loading some of the previous directives in the configuration may have been relevant. --- vim/config/syntax.vim | 12 ++++++++++++ vim/vimrc | 13 ------------- 2 files changed, 12 insertions(+), 13 deletions(-) create mode 100644 vim/config/syntax.vim diff --git a/vim/config/syntax.vim b/vim/config/syntax.vim new file mode 100644 index 00000000..68a344e2 --- /dev/null +++ b/vim/config/syntax.vim @@ -0,0 +1,12 @@ +" Options dependent on the syntax feature +if has('syntax') + + " Use syntax highlighting with 100 lines of context + silent! syntax enable + silent! syntax sync minlines=100 + + " Use my custom color scheme if possible, otherwise I'm happy with whatever + " the default is, and it usually cares about my background + set background=dark + silent! colorscheme sahara +endif diff --git a/vim/vimrc b/vim/vimrc index 3a579836..401a287e 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -23,19 +23,6 @@ if has('autocmd') filetype indent plugin on endif -" Options dependent on the syntax feature -if has('syntax') - - " Use syntax highlighting with 100 lines of context - silent! syntax enable - silent! syntax sync minlines=100 - - " Use my custom color scheme if possible, otherwise I'm happy with whatever - " the default is, and it usually cares about my background - set background=dark - silent! colorscheme sahara -endif - " Use all ancestors of current directory for :find if has('file_in_path') set path=** -- cgit v1.2.3 From 5caa13c27c7f14173ec12bd45c7542228d537f4f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:39:02 +1300 Subject: Move syntax config back into .vimrc This reverts commit 5dba4c. The order of the configuration matters more for these settings, because the "sahara" colorscheme is only available after loading it as a plugin. I'll divest some other stuff that should be less sensitive to the order in which it's loaded first, and then tackle this one afterwards. --- vim/config/syntax.vim | 12 ------------ vim/vimrc | 13 +++++++++++++ 2 files changed, 13 insertions(+), 12 deletions(-) delete mode 100644 vim/config/syntax.vim diff --git a/vim/config/syntax.vim b/vim/config/syntax.vim deleted file mode 100644 index 68a344e2..00000000 --- a/vim/config/syntax.vim +++ /dev/null @@ -1,12 +0,0 @@ -" Options dependent on the syntax feature -if has('syntax') - - " Use syntax highlighting with 100 lines of context - silent! syntax enable - silent! syntax sync minlines=100 - - " Use my custom color scheme if possible, otherwise I'm happy with whatever - " the default is, and it usually cares about my background - set background=dark - silent! colorscheme sahara -endif diff --git a/vim/vimrc b/vim/vimrc index 401a287e..3a579836 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -23,6 +23,19 @@ if has('autocmd') filetype indent plugin on endif +" Options dependent on the syntax feature +if has('syntax') + + " Use syntax highlighting with 100 lines of context + silent! syntax enable + silent! syntax sync minlines=100 + + " Use my custom color scheme if possible, otherwise I'm happy with whatever + " the default is, and it usually cares about my background + set background=dark + silent! colorscheme sahara +endif + " Use all ancestors of current directory for :find if has('file_in_path') set path=** -- cgit v1.2.3 From ebf0f4bea112cb242de2502daa5074a6c63c806a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:42:15 +1300 Subject: Move digraphs .vimrc config into subfile --- vim/config/digraphs.vim | 6 ++++++ vim/vimrc | 7 ------- 2 files changed, 6 insertions(+), 7 deletions(-) create mode 100644 vim/config/digraphs.vim diff --git a/vim/config/digraphs.vim b/vim/config/digraphs.vim new file mode 100644 index 00000000..0982d94f --- /dev/null +++ b/vim/config/digraphs.vim @@ -0,0 +1,6 @@ +" A few very important custom digraphs +if has('digraphs') + digraph ./ 8230 " Ellipsis (HORIZONTAL ELLIPSIS U+2026) + digraph %% 8984 " Mac command key (PLACE OF INTEREST SIGN U+2318) + digraph 8: 9731 " Snowman (SNOWMAN U+2603) +endif diff --git a/vim/vimrc b/vim/vimrc index 3a579836..f0b2faf7 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -58,13 +58,6 @@ endif " the open buffers; I'll open the file if I want to complete from it set complete-=i -" A few very important custom digraphs -if has('digraphs') - digraph ./ 8230 " Ellipsis (HORIZONTAL ELLIPSIS U+2026) - digraph %% 8984 " Mac command key (PLACE OF INTEREST SIGN U+2318) - digraph 8: 9731 " Snowman (SNOWMAN U+2603) -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 -- cgit v1.2.3 From 7a80deca0cf0e8c53b4fdde6f5bd921b1eed7877 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:44:29 +1300 Subject: Move indent .vimrc config into subfile --- vim/config/indent.vim | 29 +++++++++++++++++++++++++++++ vim/vimrc | 30 ++---------------------------- 2 files changed, 31 insertions(+), 28 deletions(-) create mode 100644 vim/config/indent.vim diff --git a/vim/config/indent.vim b/vim/config/indent.vim new file mode 100644 index 00000000..de6b154d --- /dev/null +++ b/vim/config/indent.vim @@ -0,0 +1,29 @@ +" Load indentation for file types +if has('autocmd') + filetype indent on +endif + +" 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/vimrc b/vim/vimrc index f0b2faf7..1a4c916d 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -18,9 +18,9 @@ if v:version >= 701 silent! call pathogen#helptags() endif -" Load plugins and indentation for file types +" Load plugins for file types if has('autocmd') - filetype indent plugin on + filetype plugin on endif " Options dependent on the syntax feature @@ -46,7 +46,6 @@ if has('cmdline_info') " Show my current position in the status bar set ruler - " Show the keystrokes being entered in the screen set showcmd @@ -62,31 +61,6 @@ set complete-=i " happened to me but who knows, it might one day set fileformats+=mac -" 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 - " 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 -- cgit v1.2.3 From 07fc8ce2fdd565fdbb082ee120b4d0d574c72df3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:45:25 +1300 Subject: Move spelling .vimrc config into subfile --- vim/config/spell.vim | 26 ++++++++++++++++++++++++++ vim/vimrc | 27 --------------------------- 2 files changed, 26 insertions(+), 27 deletions(-) create mode 100644 vim/config/spell.vim diff --git a/vim/config/spell.vim b/vim/config/spell.vim new file mode 100644 index 00000000..50b3f657 --- /dev/null +++ b/vim/config/spell.vim @@ -0,0 +1,26 @@ +" Configure spell checking features, if available +if has('spell') + + " Don't check spelling by default, but bind \s to toggle this + set nospell + nnoremap s :setlocal spell! + + " Use New Zealand English for spelling by default (it's almost identical + " to British English), but bind \u to switch to US English and \z to + " switch back + set spelllang=en_nz + nnoremap u :setlocal spelllang=en_us + nnoremap z :setlocal spelllang=en_nz +endif + +" Don't keep .viminfo information 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('viminfo') && has('autocmd') + augroup viminfoskip + autocmd! + silent! autocmd BufNewFile,BufReadPre + \ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/* + \ setlocal viminfo= + augroup END +endif diff --git a/vim/vimrc b/vim/vimrc index 1a4c916d..55a7a9bd 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -176,33 +176,6 @@ set autowrite set scrolloff=0 set sidescrolloff=16 -" Configure spell checking features, if available -if has('spell') - - " Don't check spelling by default, but bind \s to toggle this - set nospell - nnoremap s :setlocal spell! - - " Use New Zealand English for spelling by default (it's almost identical - " to British English), but bind \u to switch to US English and \z to - " switch back - set spelllang=en_nz - nnoremap u :setlocal spelllang=en_us - nnoremap z :setlocal spelllang=en_nz -endif - -" Don't keep .viminfo information 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('viminfo') && has('autocmd') - augroup viminfoskip - autocmd! - silent! autocmd BufNewFile,BufReadPre - \ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/* - \ setlocal viminfo= - augroup END -endif - " Preserve the flags for a pattern when repeating a substitution with &; I don't " really understand why this isn't a default, but there it is nnoremap & :&& -- cgit v1.2.3 From d27dbdad24ea0772711fa883969de97d0807827d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:46:07 +1300 Subject: Move wildmenu .vimrc config into subfile --- vim/config/wildmenu.vim | 23 +++++++++++++++++++++++ vim/vimrc | 24 ------------------------ 2 files changed, 23 insertions(+), 24 deletions(-) create mode 100644 vim/config/wildmenu.vim diff --git a/vim/config/wildmenu.vim b/vim/config/wildmenu.vim new file mode 100644 index 00000000..6036c90a --- /dev/null +++ b/vim/config/wildmenu.vim @@ -0,0 +1,23 @@ +" 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/vimrc b/vim/vimrc index 55a7a9bd..1442fe80 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -227,30 +227,6 @@ if has('virtualedit') set virtualedit+=block endif -" 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 - " Configuration for window features if has('windows') -- cgit v1.2.3 From 8b156457b45ae6fa971362d68141fb177974b218 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:47:05 +1300 Subject: Move windows .vimrc config into subfile Not the operating system; Vim editor windows. --- vim/config/windows.vim | 27 +++++++++++++++++++++++++++ vim/vimrc | 28 ---------------------------- 2 files changed, 27 insertions(+), 28 deletions(-) create mode 100644 vim/config/windows.vim diff --git a/vim/config/windows.vim b/vim/config/windows.vim new file mode 100644 index 00000000..a54b8997 --- /dev/null +++ b/vim/config/windows.vim @@ -0,0 +1,27 @@ +" Configuration for window features +if has('windows') + + " Show the status in a distinct bar above the command line only if there's + " more than one window on the screen or in the current tab + set laststatus=1 + + " Don't resize windows we're not splitting (Tmux-like; think Mondrian) + set noequalalways + + " New split windows appear below or to the right of the existing window, + " not above or to the left per the default + set splitbelow + if has('vertsplit') + set splitright + endif + + " Only show the tab bar if there's more than one tab + if exists('&showtabline') + set showtabline=1 + endif + + " Get rid of visually noisy folding characters + if has('folding') + let &fillchars = 'diff: ,fold: ,vert: ' + endif +endif diff --git a/vim/vimrc b/vim/vimrc index 1442fe80..19dbd482 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -227,34 +227,6 @@ if has('virtualedit') set virtualedit+=block endif -" Configuration for window features -if has('windows') - - " Show the status in a distinct bar above the command line only if there's - " more than one window on the screen or in the current tab - set laststatus=1 - - " Don't resize windows we're not splitting (Tmux-like; think Mondrian) - set noequalalways - - " New split windows appear below or to the right of the existing window, - " not above or to the left per the default - set splitbelow - if has('vertsplit') - set splitright - endif - - " Only show the tab bar if there's more than one tab - if exists('&showtabline') - set showtabline=1 - endif - - " Get rid of visually noisy folding characters - if has('folding') - let &fillchars = 'diff: ,fold: ,vert: ' - endif -endif - " 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 ce7003bd7fa173ccfb1552b42ca4250176d3ebb2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:49:01 +1300 Subject: Move linebreak .vimrc config into subfile I'm not quite so sure about this one. The ToggleBreak() function might actually be better in a plugin on its own. The rest of it makes sense though. --- vim/config/linebreak.vim | 31 +++++++++++++++++++++++++++++++ vim/vimrc | 32 -------------------------------- 2 files changed, 31 insertions(+), 32 deletions(-) create mode 100644 vim/config/linebreak.vim diff --git a/vim/config/linebreak.vim b/vim/config/linebreak.vim new file mode 100644 index 00000000..887d5f39 --- /dev/null +++ b/vim/config/linebreak.vim @@ -0,0 +1,31 @@ +" Break lines at word boundaries if possible and not simply at the last +" character that will fit on the screen, preceding the next line with three +" periods to make it obvious that it's a continuation of the previous line +if has('linebreak') + set linebreak + set showbreak=... + if v:version > 704 || v:version == 704 && has('patch338') + set breakindent + endif + + " Bind \b to turn off linebreak and toggle the showbreak characters on and + " off for convenience of copypasting multiple lines from terminal emulators. + if has('eval') + function! ToggleBreak() + if &linebreak + set nolinebreak + set showbreak= + if v:version > 704 || v:version == 704 && has('patch338') + set nobreakindent + endif + else + set linebreak + set showbreak=... + if v:version > 704 || v:version == 704 && has('patch338') + set breakindent + endif + endif + endfunction + nnoremap b :call ToggleBreak() + endif +endif diff --git a/vim/vimrc b/vim/vimrc index 19dbd482..f4678bb9 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -254,38 +254,6 @@ set shellpipe=> nnoremap j gj nnoremap k gk -" Break lines at word boundaries if possible and not simply at the last -" character that will fit on the screen, preceding the next line with three -" periods to make it obvious that it's a continuation of the previous line -if has('linebreak') - set linebreak - set showbreak=... - if v:version > 704 || v:version == 704 && has('patch338') - set breakindent - endif - - " Bind \b to turn off linebreak and toggle the showbreak characters on and - " off for convenience of copypasting multiple lines from terminal emulators. - if has('eval') - function! ToggleBreak() - if &linebreak - set nolinebreak - set showbreak= - if v:version > 704 || v:version == 704 && has('patch338') - set nobreakindent - endif - else - set linebreak - set showbreak=... - if v:version > 704 || v:version == 704 && has('patch338') - set breakindent - endif - endif - endfunction - nnoremap b :call ToggleBreak() - endif -endif - " 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 -- cgit v1.2.3 From 13d9b32de112f680357140fdb640f3fb3c512efe Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:50:31 +1300 Subject: Move format .vimrc config into subfile The ToggleFormatFlag function might actually be better implemented as some sort of plugin. --- vim/config/format.vim | 31 +++++++++++++++++++++++++++++++ vim/vimrc | 32 -------------------------------- 2 files changed, 31 insertions(+), 32 deletions(-) create mode 100644 vim/config/format.vim diff --git a/vim/config/format.vim b/vim/config/format.vim new file mode 100644 index 00000000..cbc995af --- /dev/null +++ b/vim/config/format.vim @@ -0,0 +1,31 @@ +" If we can, add j to the format options to get rid of comment leaders when +" joining lines +if v:version > 703 || v:version == 703 && has('patch541') + set formatoptions+=j +endif + +" +" Quick way to toggle flags in 'formatoptions' that I often want to change; +" specifically: +" +" a - Automatically format paragraphs, reapplying the wrap on every text +" insertion or deletion; sometimes I want this and sometimes I +" don't, it particularly varies when typing prose in Markdown that +" includes headings and code +" c - Automatically wrap comments at 'textwidth' (which I allow the filetypes +" to set for me) +" t - Automatically wrap text at 'textwidth' (as above) +" +" So I just have to type e.g. \a to toggle the auto-format flag on and off; +" very handy +" +if has('eval') + function! ToggleFormatFlag(flag) + let l:operation = (&formatoptions =~ a:flag) ? '-=' : '+=' + silent! exec 'setlocal formatoptions' . l:operation . a:flag + setlocal formatoptions? + endfunction + nnoremap a :call ToggleFormatFlag('a') + nnoremap c :call ToggleFormatFlag('c') + nnoremap t :call ToggleFormatFlag('t') +endif diff --git a/vim/vimrc b/vim/vimrc index f4678bb9..d00376f0 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -70,38 +70,6 @@ set nojoinspaces " to it; note that it wipes out your z mark, if you happen to use it nnoremap J mzJ`z -" If we can, add j to the format options to get rid of comment leaders when -" joining lines -if v:version > 703 || v:version == 703 && has('patch541') - set formatoptions+=j -endif - -" -" Quick way to toggle flags in 'formatoptions' that I often want to change; -" specifically: -" -" a - Automatically format paragraphs, reapplying the wrap on every text -" insertion or deletion; sometimes I want this and sometimes I -" don't, it particularly varies when typing prose in Markdown that -" includes headings and code -" c - Automatically wrap comments at 'textwidth' (which I allow the filetypes -" to set for me) -" t - Automatically wrap text at 'textwidth' (as above) -" -" So I just have to type e.g. \a to toggle the auto-format flag on and off; -" very handy -" -if has('eval') - function! ToggleFormatFlag(flag) - let l:operation = (&formatoptions =~ a:flag) ? '-=' : '+=' - silent! exec 'setlocal formatoptions' . l:operation . a:flag - setlocal formatoptions? - endfunction - nnoremap a :call ToggleFormatFlag('a') - nnoremap c :call ToggleFormatFlag('c') - nnoremap t :call ToggleFormatFlag('t') -endif - " Strip trailing whitespace with \x if has('eval') function! StripTrailingWhitespace() -- cgit v1.2.3 From 0dbc9b35f9ae0c21390f2133406da3279af190c7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:53:46 +1300 Subject: Move BigFileMeasures() .vimrc func into subfile Also add a note to IDEAS.md for later to consider packaging this as a proepr plugin, even if it doesn't actually leave the dotfiles repository just yet. --- IDEAS.md | 2 ++ vim/config/bigfile.vim | 28 ++++++++++++++++++++++++++++ vim/vimrc | 29 ----------------------------- 3 files changed, 30 insertions(+), 29 deletions(-) create mode 100644 vim/config/bigfile.vim diff --git a/IDEAS.md b/IDEAS.md index bba9e314..0a812167 100644 --- a/IDEAS.md +++ b/IDEAS.md @@ -19,3 +19,5 @@ Ideas * I can probably get rid of all that nasty templated shell by writing something that wraps around td(1df) and generates shell script to run, and calls that via `eval`. +* The BigFileMeasures() function in .vim/config/bigfile.vim should maybe be a + self-contained plugin rather than a config subfile. diff --git a/vim/config/bigfile.vim b/vim/config/bigfile.vim new file mode 100644 index 00000000..f15c7e85 --- /dev/null +++ b/vim/config/bigfile.vim @@ -0,0 +1,28 @@ +" When opening a large file, take some measures to keep things loading quickly +if has('eval') && has('autocmd') + + " Threshold is 10 MiB + let g:bigfilesize = 10 * 1024 * 1024 + + " Declare function for turning off slow options + function! BigFileMeasures() + let l:file = expand('') + if getfsize(l:file) > g:bigfilesize + setlocal nobackup + setlocal nowritebackup + setlocal noswapfile + if has('persistent_undo') + setlocal noundofile + endif + if exists('&synmaxcol') + setlocal synmaxcol=256 + endif + endif + endfunction + + " Define autocmd for calling to check filesize + augroup bigfilesize + autocmd! + autocmd BufReadPre * call BigFileMeasures() + augroup end +endif diff --git a/vim/vimrc b/vim/vimrc index d00376f0..9dcbb38f 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -249,32 +249,3 @@ if has('autocmd') autocmd! augroup END endif - -" When opening a large file, take some measures to keep things loading quickly -if has('eval') && has('autocmd') - - " Threshold is 10 MiB - let g:bigfilesize = 10 * 1024 * 1024 - - " Declare function for turning off slow options - function! BigFileMeasures() - let l:file = expand('') - if getfsize(l:file) > g:bigfilesize - setlocal nobackup - setlocal nowritebackup - setlocal noswapfile - if has('persistent_undo') - setlocal noundofile - endif - if exists('&synmaxcol') - setlocal synmaxcol=256 - endif - endif - endfunction - - " Define autocmd for calling to check filesize - augroup bigfilesize - autocmd! - autocmd BufReadPre * call BigFileMeasures() - augroup end -endif -- cgit v1.2.3 From 97f8038230006c6eb9abc4dfb49bfc978fc100dc Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:55:14 +1300 Subject: Move list .vimrc config into subfile By "list" here I am referring to options for Vim's 'list' display setting, showing control characters visually. --- vim/config/list.vim | 9 +++++++++ vim/vimrc | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 vim/config/list.vim diff --git a/vim/config/list.vim b/vim/config/list.vim new file mode 100644 index 00000000..87e80005 --- /dev/null +++ b/vim/config/list.vim @@ -0,0 +1,9 @@ +" 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! + +" 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/vimrc b/vim/vimrc index 9dcbb38f..58eb3a5f 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -84,11 +84,6 @@ endif " Keep plenty of command and search history, because disk space is cheap set history=2000 -" 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! - " 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 @@ -208,10 +203,6 @@ set display=lastline set nowrap nnoremap w :set wrap! -" 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:> - " Don't write the output of :make to the terminal set shellpipe=> -- cgit v1.2.3 From 46be8760df20d934b15616c0f97a7c5bb55c6227 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:56:40 +1300 Subject: Move whitespace .vimrc config into subfile The StripTrailingWhitespace() function should perhaps be its own plugin. --- vim/config/whitespace.vim | 14 ++++++++++++++ vim/vimrc | 15 --------------- 2 files changed, 14 insertions(+), 15 deletions(-) create mode 100644 vim/config/whitespace.vim diff --git a/vim/config/whitespace.vim b/vim/config/whitespace.vim new file mode 100644 index 00000000..2202f47b --- /dev/null +++ b/vim/config/whitespace.vim @@ -0,0 +1,14 @@ +" 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 + +" Strip trailing whitespace with \x +if has('eval') + function! StripTrailingWhitespace() + let l:search = @/ + %substitute/\s\+$//e + let @/ = l:search + nohlsearch + endfunction + nnoremap x :call StripTrailingWhitespace() +endif diff --git a/vim/vimrc b/vim/vimrc index 58eb3a5f..948de359 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -61,26 +61,11 @@ set complete-=i " happened to me but who knows, it might one day set fileformats+=mac -" 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 - " Don't jump my screen around when I join lines, keep my cursor in the same " place; this is done by dropping a mark first and then immediately returning " to it; note that it wipes out your z mark, if you happen to use it nnoremap J mzJ`z -" Strip trailing whitespace with \x -if has('eval') - function! StripTrailingWhitespace() - let l:search = @/ - %substitute/\s\+$//e - let @/ = l:search - nohlsearch - endfunction - nnoremap x :call StripTrailingWhitespace() -endif - " Keep plenty of command and search history, because disk space is cheap set history=2000 -- cgit v1.2.3 From 0d3fb9c9f94fa71d8bab82dd9561abeae00c7a10 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:58:09 +1300 Subject: Move terminal .vimrc config into subfile --- vim/config/term.vim | 27 +++++++++++++++++++++++++++ vim/vimrc | 28 ---------------------------- 2 files changed, 27 insertions(+), 28 deletions(-) create mode 100644 vim/config/term.vim diff --git a/vim/config/term.vim b/vim/config/term.vim new file mode 100644 index 00000000..f368e481 --- /dev/null +++ b/vim/config/term.vim @@ -0,0 +1,27 @@ +" 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 + +" Don't write the output of :make to the terminal +set shellpipe=> diff --git a/vim/vimrc b/vim/vimrc index 948de359..6f0c9b1a 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -129,31 +129,6 @@ set sidescrolloff=16 nnoremap & :&& vnoremap & :&& -" 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 - " Tolerate typos like :Wq, :Q, or :Qa and do what I mean, including any " arguments or modifiers; I fat-finger these commands a lot because I type " them so rapidly, and they don't correspond to any other commands I use @@ -188,9 +163,6 @@ set display=lastline set nowrap nnoremap w :set wrap! -" Don't write the output of :make to the terminal -set shellpipe=> - " 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 6876b5850cee41aca2ba79960751d97c77a17e0a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 21:58:52 +1300 Subject: Move line number .vimrc config into subfile This file is rather short; it may turn out to make more sense to put these settings elsewhere a bit later. --- vim/config/number.vim | 3 +++ vim/vimrc | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) create mode 100644 vim/config/number.vim diff --git a/vim/config/number.vim b/vim/config/number.vim new file mode 100644 index 00000000..464a77a2 --- /dev/null +++ b/vim/config/number.vim @@ -0,0 +1,3 @@ +" Don't show line numbers by default, but \n toggles them +set nonumber +nnoremap n :setlocal number! diff --git a/vim/vimrc b/vim/vimrc index 6f0c9b1a..55631d37 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -99,10 +99,6 @@ set report=0 " more than scratch space anyway set shellslash -" Don't show line numbers by default, but \n toggles them -set nonumber -nnoremap n :setlocal number! - " 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 -- cgit v1.2.3 From f1b0f0f30996e1114252bacaf8b170349d61c854 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:00:45 +1300 Subject: Move command .vimrc config into subfile A little bit iffy on the grouping here, but it's still better than having it all lumped in the one file. --- vim/config/command.vim | 33 +++++++++++++++++++++++++++++++++ vim/vimrc | 33 --------------------------------- 2 files changed, 33 insertions(+), 33 deletions(-) create mode 100644 vim/config/command.vim diff --git a/vim/config/command.vim b/vim/config/command.vim new file mode 100644 index 00000000..1ffe9058 --- /dev/null +++ b/vim/config/command.vim @@ -0,0 +1,33 @@ +" Keep plenty of command and search history, because disk space is cheap +set history=2000 + +" Always tell me the number of lines changed by a command +set report=0 + +" Command-line based features +if has('cmdline_info') + + " Show my current position in the status bar + set ruler + + " Show the keystrokes being entered in the screen + set showcmd + + " Show the mode we're using if not normal mode (e.g. --INSERT--) + set showmode +endif + +" Tolerate typos like :Wq, :Q, or :Qa and do what I mean, including any +" arguments or modifiers; I fat-finger these commands a lot because I type +" them so rapidly, and they don't correspond to any other commands I use +if has('user_commands') + command! -bang -complete=file -nargs=? E e + command! -bang -complete=file -nargs=? W w + command! -bang -complete=file -nargs=? WQ wq + command! -bang -complete=file -nargs=? Wq wq + command! -bang Q q + command! -bang Qa qa + command! -bang QA qa + command! -bang Wa wa + command! -bang WA wa +endif diff --git a/vim/vimrc b/vim/vimrc index 55631d37..38ecabf1 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -41,18 +41,6 @@ if has('file_in_path') set path=** endif -" Command-line based features -if has('cmdline_info') - - " Show my current position in the status bar - set ruler - " Show the keystrokes being entered in the screen - set showcmd - - " Show the mode we're using if not normal mode (e.g. --INSERT--) - set showmode -endif - " 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 @@ -66,9 +54,6 @@ set fileformats+=mac " to it; note that it wipes out your z mark, if you happen to use it nnoremap J mzJ`z -" Keep plenty of command and search history, because disk space is cheap -set history=2000 - " 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 @@ -92,9 +77,6 @@ set nomodeline " zero-padded decimal, so increment and decrement with ^A and ^X on that basis set nrformats-=octal -" Always tell me the number of lines changed by a command -set report=0 - " Always use forward slashes, I very seldom need to use Vim on Windows for " more than scratch space anyway set shellslash @@ -125,21 +107,6 @@ set sidescrolloff=16 nnoremap & :&& vnoremap & :&& -" Tolerate typos like :Wq, :Q, or :Qa and do what I mean, including any -" arguments or modifiers; I fat-finger these commands a lot because I type -" them so rapidly, and they don't correspond to any other commands I use -if has('user_commands') - command! -bang -complete=file -nargs=? E e - command! -bang -complete=file -nargs=? W w - command! -bang -complete=file -nargs=? WQ wq - command! -bang -complete=file -nargs=? Wq wq - command! -bang Q q - command! -bang Qa qa - command! -bang QA qa - command! -bang Wa wa - command! -bang WA wa -endif - " When in visual block mode, let me move the cursor anywhere in the buffer; " don't restrict me only to regions with text if has('virtualedit') -- cgit v1.2.3 From fd7d1e2364484abb328af830d6877e0cc8bae963 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:01:55 +1300 Subject: Move wrapping .vimrc config into subfile --- vim/config/wrap.vim | 15 +++++++++++++++ vim/vimrc | 16 ---------------- 2 files changed, 15 insertions(+), 16 deletions(-) create mode 100644 vim/config/wrap.vim diff --git a/vim/config/wrap.vim b/vim/config/wrap.vim new file mode 100644 index 00000000..1316e12e --- /dev/null +++ b/vim/config/wrap.vim @@ -0,0 +1,15 @@ +" When wrapping text, if a line is so long that not all of it can be shown on +" the screen, show as much as possible anyway; by default Vim fills the left +" column with @ symbols instead, which I don't find very helpful +set display=lastline + +" Don't wrap by default, but use \w to toggle it on or off quickly +set nowrap +nnoremap w :set wrap! + +" 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 +" line anyway if you need to +nnoremap j gj +nnoremap k gk diff --git a/vim/vimrc b/vim/vimrc index 38ecabf1..adc4518b 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -117,22 +117,6 @@ endif " case of the character under the cursor set tildeop -" When wrapping text, if a line is so long that not all of it can be shown on -" the screen, show as much as possible anyway; by default Vim fills the left -" column with @ symbols instead, which I don't find very helpful -set display=lastline - -" Don't wrap by default, but use \w to toggle it on or off quickly -set nowrap -nnoremap w :set wrap! - -" 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 -" line anyway if you need to -nnoremap j gj -nnoremap k gk - " 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 -- cgit v1.2.3 From 9079fbb685294913b06b346ab1e8af6be2cb5d2a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:02:32 +1300 Subject: Move paste .vimrc config into subfile --- vim/config/paste.vim | 6 ++++++ vim/vimrc | 7 ------- 2 files changed, 6 insertions(+), 7 deletions(-) create mode 100644 vim/config/paste.vim diff --git a/vim/config/paste.vim b/vim/config/paste.vim new file mode 100644 index 00000000..fa26d6f4 --- /dev/null +++ b/vim/config/paste.vim @@ -0,0 +1,6 @@ +" 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/vimrc b/vim/vimrc index adc4518b..3e7aa847 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -81,13 +81,6 @@ set nrformats-=octal " more than scratch space anyway set shellslash -" 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= - " 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 -- cgit v1.2.3 From cb7bb3d38847c937815297cda39732bff7a2fefb Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:03:28 +1300 Subject: Add matching .vimrc config into subfiles "Matching" here refers to using % as a motion to the matching character or closing statement for a block, as enabled by Vim and enhanced by the optional matchit.vim included with the distribution. --- vim/config/match.vim | 6 ++++++ vim/vimrc | 7 ------- 2 files changed, 6 insertions(+), 7 deletions(-) create mode 100644 vim/config/match.vim diff --git a/vim/config/match.vim b/vim/config/match.vim new file mode 100644 index 00000000..5c53d63e --- /dev/null +++ b/vim/config/match.vim @@ -0,0 +1,6 @@ +" 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/vimrc b/vim/vimrc index 3e7aa847..2d60a34e 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -54,13 +54,6 @@ set fileformats+=mac " to it; note that it wipes out your z mark, if you happen to use it nnoremap J mzJ`z -" 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=(:),{:},[:],<:> - " Don't show the Vim startup message, I have registered Vim and donated to " Uganda set shortmess+=I -- cgit v1.2.3 From 408e6c07d77c2be237c900fd338ea8851dc49cb7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:07:47 +1300 Subject: Move file .vimrc config into subfile Not completely sure this grouping is meaningful; I may refactor it a bit more later on. --- vim/config/file.vim | 27 +++++++++++++++++++++++++++ vim/vimrc | 28 ---------------------------- 2 files changed, 27 insertions(+), 28 deletions(-) create mode 100644 vim/config/file.vim diff --git a/vim/config/file.vim b/vim/config/file.vim new file mode 100644 index 00000000..417f7ca8 --- /dev/null +++ b/vim/config/file.vim @@ -0,0 +1,27 @@ +" Load plugins for file types +if has('autocmd') + filetype plugin on +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 + +" I really like ZZ and ZQ, so I wrote a couple more mappings; ZW forces a +" write of the current buffer, but doesn't quit, and ZA forces a write of all +" buffers but doesn't quit +nnoremap ZW :w! +nnoremap ZA :wa! diff --git a/vim/vimrc b/vim/vimrc index 2d60a34e..e8e35c44 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -18,11 +18,6 @@ if v:version >= 701 silent! call pathogen#helptags() endif -" Load plugins for file types -if has('autocmd') - filetype plugin on -endif - " Options dependent on the syntax feature if has('syntax') @@ -36,19 +31,10 @@ if has('syntax') silent! colorscheme sahara endif -" Use all ancestors of current directory for :find -if has('file_in_path') - set path=** -endif - " 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 -" 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 - " Don't jump my screen around when I join lines, keep my cursor in the same " place; this is done by dropping a mark first and then immediately returning " to it; note that it wipes out your z mark, if you happen to use it @@ -74,14 +60,6 @@ set nrformats-=octal " more than scratch space anyway set shellslash -" 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 - " Allow the cursor to get to the top or bottom of the screen before scrolling " vertically, but set a reasonably wide gutter for scrolling horizontally; no " particular reason, just suits me better @@ -103,12 +81,6 @@ endif " case of the character under the cursor set tildeop -" I really like ZZ and ZQ, so I wrote a couple more mappings; ZW forces a -" write of the current buffer, but doesn't quit, and ZA forces a write of all -" buffers but doesn't quit -nnoremap ZW :w! -nnoremap ZA :wa! - " 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 -- cgit v1.2.3 From c68874ee98b80f17bf79ce6875f4dcd7932dc662 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:09:46 +1300 Subject: Move 'shellslash' .vimrc conf into cmds subfile --- vim/config/command.vim | 4 ++++ vim/vimrc | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vim/config/command.vim b/vim/config/command.vim index 1ffe9058..a7389cfb 100644 --- a/vim/config/command.vim +++ b/vim/config/command.vim @@ -17,6 +17,10 @@ if has('cmdline_info') set showmode endif +" Always use forward slashes, I very seldom need to use Vim on Windows for +" more than scratch space anyway +set shellslash + " Tolerate typos like :Wq, :Q, or :Qa and do what I mean, including any " arguments or modifiers; I fat-finger these commands a lot because I type " them so rapidly, and they don't correspond to any other commands I use diff --git a/vim/vimrc b/vim/vimrc index e8e35c44..4571d903 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -56,10 +56,6 @@ set nomodeline " zero-padded decimal, so increment and decrement with ^A and ^X on that basis set nrformats-=octal -" Always use forward slashes, I very seldom need to use Vim on Windows for -" more than scratch space anyway -set shellslash - " Allow the cursor to get to the top or bottom of the screen before scrolling " vertically, but set a reasonably wide gutter for scrolling horizontally; no " particular reason, just suits me better -- cgit v1.2.3 From 8d59180a2d2a6c404e77011c2e8ba4cdac09c36a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:12:36 +1300 Subject: Move visual-mode .vimrc config into subfile --- vim/config/visual.vim | 5 +++++ vim/vimrc | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) create mode 100644 vim/config/visual.vim diff --git a/vim/config/visual.vim b/vim/config/visual.vim new file mode 100644 index 00000000..8bac2cf1 --- /dev/null +++ b/vim/config/visual.vim @@ -0,0 +1,5 @@ +" When in visual block mode, let me move the cursor anywhere in the buffer; +" don't restrict me only to regions with text +if has('virtualedit') + set virtualedit+=block +endif diff --git a/vim/vimrc b/vim/vimrc index 4571d903..35ab717f 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -67,12 +67,6 @@ set sidescrolloff=16 nnoremap & :&& vnoremap & :&& -" When in visual block mode, let me move the cursor anywhere in the buffer; -" don't restrict me only to regions with text -if has('virtualedit') - set virtualedit+=block -endif - " 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 1576bf3cc8058f983615585a3dbe5e8576467c7a Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:13:10 +1300 Subject: Move scrolling .vimrc config into subfile --- vim/config/scroll.vim | 5 +++++ vim/vimrc | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) create mode 100644 vim/config/scroll.vim diff --git a/vim/config/scroll.vim b/vim/config/scroll.vim new file mode 100644 index 00000000..62bc4ee8 --- /dev/null +++ b/vim/config/scroll.vim @@ -0,0 +1,5 @@ +" Allow the cursor to get to the top or bottom of the screen before scrolling +" vertically, but set a reasonably wide gutter for scrolling horizontally; no +" particular reason, just suits me better +set scrolloff=0 +set sidescrolloff=16 diff --git a/vim/vimrc b/vim/vimrc index 35ab717f..d94b5929 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -56,12 +56,6 @@ set nomodeline " zero-padded decimal, so increment and decrement with ^A and ^X on that basis set nrformats-=octal -" Allow the cursor to get to the top or bottom of the screen before scrolling -" vertically, but set a reasonably wide gutter for scrolling horizontally; no -" particular reason, just suits me better -set scrolloff=0 -set sidescrolloff=16 - " Preserve the flags for a pattern when repeating a substitution with &; I don't " really understand why this isn't a default, but there it is nnoremap & :&& -- cgit v1.2.3 From 63d4f331a305c1e9e7c791814b2a8d77600ea6e7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:13:42 +1300 Subject: Move completion .vimrc config into subfile Only one setting at the moment, but there's enough completion stuff even just in core Vim that I'm barely using, so this could be expanded upon later on. --- vim/config/complete.vim | 3 +++ vim/vimrc | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) create mode 100644 vim/config/complete.vim diff --git a/vim/config/complete.vim b/vim/config/complete.vim new file mode 100644 index 00000000..5fcc0e62 --- /dev/null +++ b/vim/config/complete.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 diff --git a/vim/vimrc b/vim/vimrc index d94b5929..a2698925 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -31,10 +31,6 @@ if has('syntax') silent! colorscheme sahara endif -" 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 - " Don't jump my screen around when I join lines, keep my cursor in the same " place; this is done by dropping a mark first and then immediately returning " to it; note that it wipes out your z mark, if you happen to use it -- cgit v1.2.3 From 6ca11a52b5754ae9011fe3cb29648723854837eb Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:16:06 +1300 Subject: Move syntax .vimrc config into subfile Some refactoring is done here, because as noted in 5caa13c, my custom colorscheme is implemented as a plugin to be loaded by Pathogen, and hence isn't available into after it's done its work. I've removed the :set background line for now until I'm sure it's needed, because at the moment I'm not sure. --- vim/config/syntax.vim | 8 ++++++++ vim/vimrc | 16 ++++------------ 2 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 vim/config/syntax.vim diff --git a/vim/config/syntax.vim b/vim/config/syntax.vim new file mode 100644 index 00000000..118486b1 --- /dev/null +++ b/vim/config/syntax.vim @@ -0,0 +1,8 @@ +" Options dependent on the syntax feature +if has('syntax') + + " Use syntax highlighting with 100 lines of context + silent! syntax enable + silent! syntax sync minlines=100 + +endif diff --git a/vim/vimrc b/vim/vimrc index a2698925..6700b5fa 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -16,19 +16,11 @@ runtime! config/*.vim if v:version >= 701 silent! call pathogen#infect() silent! call pathogen#helptags() -endif - -" Options dependent on the syntax feature -if has('syntax') - - " Use syntax highlighting with 100 lines of context - silent! syntax enable - silent! syntax sync minlines=100 - " Use my custom color scheme if possible, otherwise I'm happy with whatever - " the default is, and it usually cares about my background - set background=dark - silent! colorscheme sahara + " With the plugins loaded, we might now be able to use my custom colorscheme + if has('syntax') + silent! colorscheme sahara + endif endif " Don't jump my screen around when I join lines, keep my cursor in the same -- cgit v1.2.3 From 69a0c2e789df507eb83ab08f19ea476a5aa56866 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:18:34 +1300 Subject: Restore 'background' .vimrc setting Per 6ca11a5, I've confirmed I do still need this, otherwise the default colorschemes (not sahara.vim) assume a bright background and show very dark colours. --- vim/config/syntax.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vim/config/syntax.vim b/vim/config/syntax.vim index 118486b1..af332ba3 100644 --- a/vim/config/syntax.vim +++ b/vim/config/syntax.vim @@ -5,4 +5,8 @@ if has('syntax') silent! syntax enable silent! syntax sync minlines=100 + " I almost always use a dark background, so use that version of the selected + " colorscheme + set background=dark + endif -- cgit v1.2.3 From 5042692f61db05758abcd0d040d2e726a93ddf45 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:19:51 +1300 Subject: Move startup .vimrc config into subfile Just the 'shortmess' setting for now. --- vim/config/startup.vim | 3 +++ vim/vimrc | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) create mode 100644 vim/config/startup.vim diff --git a/vim/config/startup.vim b/vim/config/startup.vim new file mode 100644 index 00000000..b99bebe1 --- /dev/null +++ b/vim/config/startup.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/vimrc b/vim/vimrc index 6700b5fa..30eb9502 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -28,10 +28,6 @@ endif " to it; note that it wipes out your z mark, if you happen to use it nnoremap J mzJ`z -" Don't show the Vim startup message, I have registered Vim and donated to -" Uganda -set shortmess+=I - " Let me backspace over pretty much anything, even if it's not text I inserted " in the current session set backspace=indent,eol,start -- cgit v1.2.3 From 68de17180ef3fd9233ab45792a963aab42ed8103 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:20:58 +1300 Subject: Move 'modeline' .vimrc setting to file.vim subfile --- vim/config/file.vim | 4 ++++ vim/vimrc | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vim/config/file.vim b/vim/config/file.vim index 417f7ca8..0e2f2e96 100644 --- a/vim/config/file.vim +++ b/vim/config/file.vim @@ -20,6 +20,10 @@ set autoread " 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 diff --git a/vim/vimrc b/vim/vimrc index 30eb9502..19877316 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -32,10 +32,6 @@ nnoremap J mzJ`z " in the current session set backspace=indent,eol,start -" Don't use modelines at all, they're apparently potential security problems -" and I've never used them anyway -set nomodeline - " 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 c71e4f16a4e8a7c91ce354f636048c39bdd98275 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:22:10 +1300 Subject: Move Fedora workaround .vimrc config into subfile --- vim/config/fedora.vim | 8 ++++++++ vim/vimrc | 9 --------- 2 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 vim/config/fedora.vim diff --git a/vim/config/fedora.vim b/vim/config/fedora.vim new file mode 100644 index 00000000..ff6cadfc --- /dev/null +++ b/vim/config/fedora.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 diff --git a/vim/vimrc b/vim/vimrc index 19877316..040d1165 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -57,12 +57,3 @@ if v:version >= 701 else set switchbuf=useopen endif - -" 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 b4b53a9a9bee55e8bdcbe91201305a87fcafca60 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:23:25 +1300 Subject: Move substitution .vimrc config into subfile --- vim/config/substitution.vim | 4 ++++ vim/vimrc | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 vim/config/substitution.vim diff --git a/vim/config/substitution.vim b/vim/config/substitution.vim new file mode 100644 index 00000000..da9eb47e --- /dev/null +++ b/vim/config/substitution.vim @@ -0,0 +1,4 @@ +" Preserve the flags for a pattern when repeating a substitution with &; I +" don't really understand why this isn't a default, but there it is +nnoremap & :&& +vnoremap & :&& diff --git a/vim/vimrc b/vim/vimrc index 040d1165..6e536c33 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -36,11 +36,6 @@ set backspace=indent,eol,start " zero-padded decimal, so increment and decrement with ^A and ^X on that basis set nrformats-=octal -" Preserve the flags for a pattern when repeating a substitution with &; I don't -" really understand why this isn't a default, but there it is -nnoremap & :&& -vnoremap & :&& - " 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 b841310211f3e54c82ecb4efaa3ccc3544947ec3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:24:32 +1300 Subject: Move buffers .vimrc config into subfile --- vim/config/buffers.vim | 8 ++++++++ vim/vimrc | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 vim/config/buffers.vim diff --git a/vim/config/buffers.vim b/vim/config/buffers.vim new file mode 100644 index 00000000..6102fc76 --- /dev/null +++ b/vim/config/buffers.vim @@ -0,0 +1,8 @@ +" Allow jumping between windows and tabs to find an open instance of a given +" buffer with :sbuffer. +if v:version >= 701 + set switchbuf=useopen,usetab +else + set switchbuf=useopen +endif + diff --git a/vim/vimrc b/vim/vimrc index 6e536c33..d56c9ee6 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -44,11 +44,3 @@ set tildeop " 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$ - -" Allow jumping between windows and tabs to find an open instance of a given -" buffer with :sbuffer. -if v:version >= 701 - set switchbuf=useopen,usetab -else - set switchbuf=useopen -endif -- cgit v1.2.3 From 61bc98d0c54640d3cfc6ef80f9d1f161a8a43920 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:25:23 +1300 Subject: Move yanking .vimrc config into subfile --- vim/config/yank.vim | 4 ++++ vim/vimrc | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 vim/config/yank.vim diff --git a/vim/config/yank.vim b/vim/config/yank.vim new file mode 100644 index 00000000..01879aa8 --- /dev/null +++ b/vim/config/yank.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/vimrc b/vim/vimrc index d56c9ee6..889cff01 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -39,8 +39,3 @@ set nrformats-=octal " Use the tilde as an operator with motions, rather than just swapping the " case of the character under the cursor set tildeop - -" 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 f5ecb57445f1cbff0dc16428d9c04ec1d0fe46de Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:25:53 +1300 Subject: Move backspace .vimrc config into subfile --- vim/config/backspace.vim | 3 +++ vim/vimrc | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) create mode 100644 vim/config/backspace.vim diff --git a/vim/config/backspace.vim b/vim/config/backspace.vim new file mode 100644 index 00000000..a4089a68 --- /dev/null +++ b/vim/config/backspace.vim @@ -0,0 +1,3 @@ +" Let me backspace over pretty much anything, even if it's not text I inserted +" in the current session +set backspace=indent,eol,start diff --git a/vim/vimrc b/vim/vimrc index 889cff01..5b5851d8 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -28,10 +28,6 @@ endif " to it; note that it wipes out your z mark, if you happen to use it nnoremap J mzJ`z -" Let me backspace over pretty much anything, even if it's not text I inserted -" in the current session -set backspace=indent,eol,start - " 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 67f2fdc6d8679d5932b0bc9c757db79735d81b09 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:26:28 +1300 Subject: Move 'tildeop' .vimrc config into subfile This is an awkward filename and very unlikely to ever have anything but this one setting in it, but I can't think of any logical other place to put it. --- vim/config/tildeop.vim | 3 +++ vim/vimrc | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) create mode 100644 vim/config/tildeop.vim diff --git a/vim/config/tildeop.vim b/vim/config/tildeop.vim new file mode 100644 index 00000000..bb21aefd --- /dev/null +++ b/vim/config/tildeop.vim @@ -0,0 +1,3 @@ +" 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/vimrc b/vim/vimrc index 5b5851d8..ce487bc4 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -31,7 +31,3 @@ nnoremap J mzJ`z " 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 - -" 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 473211e0a404e7e22539cfdb0ba34436b5afb430 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:27:06 +1300 Subject: Move line-joining .vimrc config into subfile --- vim/config/join.vim | 4 ++++ vim/vimrc | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 vim/config/join.vim diff --git a/vim/config/join.vim b/vim/config/join.vim new file mode 100644 index 00000000..5f75d89b --- /dev/null +++ b/vim/config/join.vim @@ -0,0 +1,4 @@ +" Don't jump my screen around when I join lines, keep my cursor in the same +" place; this is done by dropping a mark first and then immediately returning +" to it; note that it wipes out your z mark, if you happen to use it +nnoremap J mzJ`z diff --git a/vim/vimrc b/vim/vimrc index ce487bc4..11746738 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -23,11 +23,6 @@ if v:version >= 701 endif endif -" Don't jump my screen around when I join lines, keep my cursor in the same -" place; this is done by dropping a mark first and then immediately returning -" to it; note that it wipes out your z mark, if you happen to use it -nnoremap J mzJ`z - " 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 2bbea0927b8ec1be00e6aa78ff92882bd271d4f1 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 28 Oct 2017 22:27:37 +1300 Subject: Move 'nrformats' .vimrc config into subfile This is an awkward filename and very unlikely to ever have anything but this one setting in it, but I can't think of any logical other place to put it. number.vim applies to line numbering, which is a distinct concept. --- vim/config/nrformats.vim | 3 +++ vim/vimrc | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) create mode 100644 vim/config/nrformats.vim diff --git a/vim/config/nrformats.vim b/vim/config/nrformats.vim new file mode 100644 index 00000000..09fe8c73 --- /dev/null +++ b/vim/config/nrformats.vim @@ -0,0 +1,3 @@ +" 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/vimrc b/vim/vimrc index 11746738..a5849694 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -22,7 +22,3 @@ if v:version >= 701 silent! colorscheme sahara endif endif - -" 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