vimrc tweaks

Nov 7, 2009 Author Kyle Christensen

I found myself getting frustrated with having one conf file for my whole vim usage. So, I discovered recently that you can use different configurations for different filetypes. While this may be common knowledge among some, maybe someone will benefit from my recent knowledge acquisition.

Here is my $HOME/.vimrc file:

autocmd BufRead *.tex :source ~/.vim/tex.vimrc
autocmd BufRead ~/.mutt/temp/mutt*   :source ~/.vim/mail.vimrc
autocmd BufRead *.cpp set cin
set tabstop=4

~/.vim/tex.vimrc

set linebreak "If word wrap is toggled, only wrap on whitespace
set textwidth=80 "Carriage return at 80 characters
set spell "Default is to have spellcheck on

"" My mappings
" <F7> toggle spellcheck
" <F11> view pdf of latex file
" <F12> compile latex file

        "These are in command mode
        nmap <F7> :set spell!<CR>
        nmap <F11> :!/bin/tex2pdf.sh %<CR><Esc>
        nmap <F12> :!/bin/xpdf_current.sh %&<CR><Esc>

        "These are in insert mode
        map! <F7> <Esc>:set spell!<CR>i
        map! <F11> <Esc>:!/bin/tex2pdf.sh %<CR><Esc>i
        map! <F12> <Esc>:!/bin/xpdf_current.sh %&<CR><Esc>i

~/.vim/mail.vim

" To use with Mutt, just put this line your ~/.vimrc :
"   autocmd BufRead ~/.mutt/temp/mutt*      :source ~/.vim/mail

" * <F1> to re-format the current paragraph correctly
" * <F2> to format a line which is too long, and go to the next line
" * <F3> to merge the previous line with the current one, with a correct
"        formatting (sometimes useful associated with <F2>)

" turn on spell checking
set spell

" reformat paragraphs
nmap    <F1>    gqap
nmap    <F2>    gqqj
nmap    <F3>    kgqj
map!    <F1>    <ESC>gqapi
map!    <F2>    <ESC>gqqji
map!    <F3>    <ESC>kgqji

This final source I am borrowing from pbrisbin.com. There is a lot on his page that is worth looking at, if you are interested in a great tiling WM.

2 Responses į “vimrc tweaks”

  1. njazz @ December 25th, 2009 05:12

    I want to quote your post in my blog. It can?
    And you et an account on Twitter?

  2. Kyle Christensen @ January 19th, 2010 20:32

    Absolutely, you can. :)

Leave a Reply: