aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-10-28 21:50:31 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-10-28 21:52:10 +1300
commit13d9b32de112f680357140fdb640f3fb3c512efe (patch)
treebe13cbea1800c444dd367a5c4bf612f3143ab462
parentMove linebreak .vimrc config into subfile (diff)
downloaddotfiles-13d9b32de112f680357140fdb640f3fb3c512efe.tar.gz
dotfiles-13d9b32de112f680357140fdb640f3fb3c512efe.zip
Move format .vimrc config into subfile
The ToggleFormatFlag function might actually be better implemented as some sort of plugin.
-rw-r--r--vim/config/format.vim31
-rw-r--r--vim/vimrc32
2 files changed, 31 insertions, 32 deletions
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 <silent> <leader>a :<C-U>call ToggleFormatFlag('a')<CR>
+ nnoremap <silent> <leader>c :<C-U>call ToggleFormatFlag('c')<CR>
+ nnoremap <silent> <leader>t :<C-U>call ToggleFormatFlag('t')<CR>
+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 <silent> <leader>a :<C-U>call ToggleFormatFlag('a')<CR>
- nnoremap <silent> <leader>c :<C-U>call ToggleFormatFlag('c')<CR>
- nnoremap <silent> <leader>t :<C-U>call ToggleFormatFlag('t')<CR>
-endif
-
" Strip trailing whitespace with \x
if has('eval')
function! StripTrailingWhitespace()