1. Turn on formatoptions 't' for text files
2. The text filetype doesn't work in some cases. Add specific commands
for files like README.
3. Map 'coa' to toggling of the formatoptions 'a', auto-format
paragraphs.
4. Previous 'coa' -> 'cop', for toggling auto pairing (delimitMate).
5. Previous 'cop' -> 'co(', for toggling rainbow parenthesis. This is a
feature I've not used much, so maybe it needs to go away.
I'm debating the value of formatoptions 'n' for certain files. It could
be helpful for some things but seems to break others. For now it is not
being used.
With 'coa' present, there is some merit to considering adding 'a' by
default for text files, since it would then be trivial to turn off. But
since 'a' autoformats paragraphs all the time, any 'hand' formatting
will be lost with the next key press in that paragraph. So it's
probably better to leave it as a selectively enabled element as it is
now.
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 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 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()
" Whitelist for auto-stripping trailing whitespace on buffer write
autocmd BufWritePre *.c,*.h,*.nesc,*.py,*.java,*.sh,make :call <SID>StripTrailingWhitespace()
let g:delimitMate_autoclose = 1
let g:delimitMate_expand_cr = 1
let g:delimitMate_expand_space = 1
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
" 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
" Turn on doxygen syntax highlighting for C, C++, C# and IDL files.
let g:load_doxygen_syntax=1
+" 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>
" 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>