]> oss.titaniummirror.com Git - smckown/dotfiles.git/blobdiff - vim/vimrc
Better text file handling
[smckown/dotfiles.git] / vim / vimrc
index 5bdef27f2bc3bf9dbc93d4c3c9e3b0d45b148e6d..15e4b3c7576d056a4c0295f669edae5f6f4bdca0 100644 (file)
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -76,11 +76,12 @@ if has("autocmd")
   autocmd filetype sh,ld setlocal sts=4 sw=4 tw=80 fo-=t fo+=j
   autocmd filetype python setlocal sts=4 sw=4 tw=79 fo-=t fo+=j
   autocmd filetype html,xml setlocal listchars-=tab:>. tw=80 fo-=t fo+=j
-  autocmd filetype text,markdown,mkd,md setlocal tw=80 fo-=t fo+=j
+  autocmd filetype markdown,mkd,md setlocal tw=80 fo-=t fo+=j
   autocmd filetype c,cpp,java setlocal tw=80 fo-=t fo+=j
   autocmd filetype nesc setlocal syntax=c.doxygen tw=80 fo-=t fo+=j
+  autocmd filetype text setlocal tw=80 fo+=jt
 
-  autocmd BufReadPre *.txt,README*,TODO*,INSTALL* setlocal tw=80 fo-=t fo+=j
+  autocmd BufReadPre README*,TODO*,INSTALL* setlocal tw=80 fo+=t
 
   " Whitelist for auto-stripping trailing whitespace on buffer write
   autocmd BufWritePre *.c,*.h,*.nesc,*.py,*.java,*.sh,make :call <SID>StripTrailingWhitespace()
@@ -348,10 +349,11 @@ let g:delimitMate_matchpairs = "{:},[:],(:)"
 let g:delimitMate_autoclose = 1
 let g:delimitMate_expand_cr = 1
 let g:delimitMate_expand_space = 1
-nnoremap coa :DelimitMateSwitch<CR>
+" cop means to toggle auto pairing
+nnoremap cop :DelimitMateSwitch<CR>
 
 " Rainbow Parenthesis -- off by default but set toggle
-nnoremap cop :RainbowParenthesesToggle<CR>
+nnoremap co( :RainbowParenthesesToggle<CR>
 
 " Turn on doxygen syntax highlighting for C, C++, C# and IDL files.
 let g:load_doxygen_syntax=1
@@ -385,6 +387,19 @@ function! ToggleFormatOptionT()
   endif
 endfunction
 
+" Implement 'coa' -- Toggle formatoption 'a' -- auto-wrap paragraphs
+nnoremap coa :call ToggleFormatOptionA()<CR>
+function! ToggleFormatOptionA()
+  let tmp = substitute(&formatoptions, 'a', '', '')
+  if &formatoptions == tmp
+    set fo+=a
+    :echo "Enable auto-wrap paragraphs"
+  else
+    set fo-=a
+    :echo "Disable auto-wrap paragraphs"
+  endif
+endfunction
+
 " Insert date and time in insert mode.  Have to use the native <Leader>, not
 " its re-mapped version <space>
 imap <leader>d <C-R>=strftime("%Y%m%d")<CR>