" ================================================ " MMMM MMMM VVV VVV SSSSSS " MMMM MMM MMMM VVVV VVVV SSSSSSSS " MMMM M MMMM VVVV VVVV SSSS " MMMM MMMM VVVV VVVV SSSSSSS " MMMM MMMM VVVV VVVV SSSS " MMMM MMMM VVVV VVVV SSSSSSSS " MMMM MMMM y VVVVV im SSSSSS etup " ================================================ " " File: vimrc " Maintainer: Claas-Thido Pfaff " Description: This is my personal Vim setup. " Include bundles and autosource {{{ " Load vim bundles source ~/.vim/bundles.vim " auto source changed vimrc file "if has("autocmd") "autocmd bufwritepost .vimrc source $MYVIMRC "endif "}}} " General Vim behaviour {{{ " Disable vim error behavior set noerrorbells set novisualbell set t_vb= set tm=500 " Sets how much history and undo vim remembers set history=1000 " Save files in one place set backupdir=~/.vim/tmp set directory=~/.vim/tmp set tags=~/.vim/tmp/ " Persistent undo if has('persistent_undo') set undodir=~/.vim/tmp set undofile set undolevels=1000 set undoreload=10000 endif " Enable filetype plugins filetype plugin on filetype indent on " A buffer becomes hidden when it is abandoned set hidden " Configure backspace and wrap behavior set backspace=indent,eol,start set whichwrap=b,s,h,l,<,>,[,] "swith on numbering on left side set number " Ignore compiled files set wildmenu set wildignore=*tikzDiktionary* " Ignore case when searching set ignorecase " When searching try to be smart about cases set smartcase " Highlight search results set hlsearch " Makes search act like search in modern browsers set incsearch " Don't redraw while executing macros (good performance config) set lazyredraw " For regular expressions turn magic on set magic " blink on mathing bracets set matchtime=2 " Enable better colours in console set t_Co=256 " Set colour scheme syntax enable set background=dark colorscheme solarized " colorscheme peaksea " use spaces instead of tabs set expandtab " Be smart when using tabs set smarttab " 1 tab == 3 spaces set shiftwidth=3 set tabstop=3 " let cursor beyond last character "set virtualedit=onemore " wrap and linebreak set wrap set linebreak set nolist "Auto indent set autoindent "Smart indent set smartindent " set format program to par with 80 col width set formatprg=par\ -w80 " Specify the behavior when switching buffers try set switchbuf=useopen,usetab,newtab set showtabline=2 catch endtry " Remember info about open buffers on close " set viminfo^=% " Scroll options set scrolloff=8 set sidescrolloff=15 set sidescroll=1 " Autocompletion set completeopt=menu,menuone,longest " Limit popup menu height set pumheight=15 " Set information of status line if has('statusline') set laststatus=2 " in segments set statusline=%<%f\ " Filename set statusline+=%w%h%m%r " Options set statusline+=%{fugitive#statusline()} " Git set statusline+=\ [%{&ff}/%Y] " filetype set statusline+=\ [%{getcwd()}] " current directory set statusline+=%#warningmsg# set statusline+=%{SyntasticStatuslineFlag()} set statusline+=%* set statusline+=%=%-14.(%l,%c%V%)\ %p%% " Right aligned file nav info endif " Folding options "set nofoldenable set foldmethod=marker set foldnestmax=10 " Standard spelling en set spelllang=en " Toggle paste mode on and off set pastetoggle= " Autosize windows set winheight=30 "}}} " Mappings {{{ " Preparations {{{ " set leader and local leader let mapleader = "," let maplocalleader = '.' " setup for alt and meta key mappings for i in range(97,122) let c = nr2char(i) exec "set =\".c endfor "}}} " Basic mappings {{{ " Remove key functionality {{{ " Remove help from f1 noremap "}}} " Movement related {{{ " move always one line up/down noremap j gj noremap k gk " move between windows noremap j noremap k noremap h noremap l " 0 to first non-blank character noremap 0 ^ " space: search forward. ctrl-: search backward, leader space clear search noremap / noremap ? noremap :noh " Visual mode pressing * or # searches for the current selection vnoremap * :call VisualSelection('b') vnoremap # :call VisualSelection('f') " " }}} " Edit related mappings {{{ " Exit visual/insert/command/select mode with kj vnoremap kj inoremap kj cnoremap kj snoremap kj " format the current paragraph with par noremap Q gqap " Easy undo nnoremap U " Move lines up and down (bubbling) left and right (indent) nmap [e nmap ]e vmap [egv vmap ]egv nnoremap >> nnoremap << vnoremap >gv vnoremap (neosnippet_expand) smap (neosnippet_expand) xmap (neosnippet_start_unite_snippet_target) imap (neosnippet_jump) smap (neosnippet_jump) inoremap pumvisible() ? neocomplcache#close_popup() : "\" inoremap neocomplcache#complete_common_string() inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" "}}} "}}} " Sorted key mappings {{{ " (a)lign with tabularize {{{ " Description: " This mappings help to align text with the tabularize plugin. " You can call them in vizual and in normal mode. For example " to allign text by the & character you can issue aa. " " Mappings: " " - a= align by = " - aa align by & " - a: align by : " - a:: align by :: " - a, align by , nnoremap [n_align_key] nmap a [n_align_key] vnoremap [v_align_key] vmap a [v_align_key] nnoremap [n_align_key]= :Tabularize /= vnoremap [v_align_key]= :Tabularize /= nnoremap [n_align_key]a :Tabularize /& vnoremap [v_align_key]a :Tabularize /& nnoremap [n_align_key]: :Tabularize /: vnoremap [v_align_key]: :Tabularize /: nnoremap [n_align_key]:: :Tabularize /:\zs vnoremap [v_align_key]:: :Tabularize /:\zs nnoremap [n_align_key], :Tabularize /, vnoremap [v_align_key], :Tabularize /, "}}} " (b)uffer handling {{{ " Description: " " This mappings do the buffer handling. Fast buffer switching is " realized with the LustyJuggler plugin. You can switch betwenn buffers " with the combination b which opens up LustyJuggler. Then " you can switch to the buffer you like with a key of the homerow of " your keyboard starting with a for the first buffer, s for the second " and so on. On tap on the key highlights the corresponding buffer, a " second key stroke switches to that buffer. " " Mappings: " " - [buffer_key]d closes the active buffer " - [buffer_key]n opens a new tab " - [buffer_key]o closes all but the active buffer nnoremap [buffer_key] nmap b [buffer_key] noremap [buffer_key] :LustyJuggler noremap [buffer_key]n :tabnew noremap [buffer_key]d :bd! noremap [buffer_key]o :tabonly " }}} " (c)omment handling {{{ " Description: " " This mappings handle commenting lines in and out with the " NERDCommenter plugin. They combination c calls the comment " toggle of nerd commter which comments the line in or out. This " mapping works in vizal and normal mode. " " Mappings: " " - [comment_key] toggles the nerd commenter " - [comment_key]y yank text then comment out " - [comment_key]a change to alternative delimiter set nnoremap [comment_key] map c [comment_key] map [comment_key] NERDCommenterToggle map [comment_key]y NERDCommenterYank map [comment_key]a NERDCommenterAltDelims " }}} " (d)ump and load sessions {{{ " Description: " " This mappings use the vim sessionman plugin to handle sessions. If " you store a session all things defined under sessionoptions will be " stored. " " Mappings: " " - [dump_key]l lists all stored sessions " - [dump_key]s to save a session nnoremap [dump_key] nmap d [dump_key] nnoremap [dump_key]s :SessionSave nnoremap [dump_key]l :SessionList " }}} " (e)dit config files {{{ " Description: " " This mappings use enable fast access to important configuration " and snippet files. " " Mappings: " " - [edit_key]v edit the vimrc file in vertical split " - [edit_key]r edit the neosnippet runtime snippets for [filetype] " - [edit_key]s edit your personal snippet for [filetype] nnoremap [edit_key] nmap e [edit_key] nnoremap [edit_key]v :vsplit $MYVIMRC nnoremap [edit_key]r :NeoSnippetEdit -runtime nnoremap [edit_key]s :NeoSnippetEdit " }}} " (f)ind files, buffers etc. and do (unite) {{{ " Description: " " This are the mappings use the unite plug-in to search in files, " buffers etc. " " Mappings: " " - [unite_key]c open files recursively starting from current directory " - [unite_key]r open recently used files " - [unite_key]f open unite with sources overview to chose from actions nnoremap [unite_key] nmap f [unite_key] nnoremap [unite_key]c :Unite -buffer-name=files file_rec:! nnoremap [unite_key]r :Unite -buffer-name=files file_mru nnoremap [unite_key]f :Unite -buffer-name=sources source "}}} " (g)it version control (Fugitive) {{{ " Description: " " This mappings cover common git tasks with the help of the Vim " plug-in fugitive. " " Mappings: " " - [git_key]s open the interactive git status window " - [git_key]d opens a git diff in split view of the file " - [git_key]c commit your changes " - [git_key]b open a git blame in split view " - [git_key]l show a git log " - [git_key]p push to your remote repository nnoremap [git_key] nmap g [git_key] nnoremap [git_key]s :Gstatus nnoremap [git_key]d :Gdiff nnoremap [git_key]c :Gcommit nnoremap [git_key]b :Gblame nnoremap [git_key]l :Glog nnoremap [git_key]p :Git push " }}} " (m)ake call a task {{{ " Description: " " This mappings help to call make tasks. " " Mappings: " " - [make_key] opens a unite window and starte a plain make call. " the filter in the file is set to error so it will " display all errors in the make run output. You can " specify it to your needs or to multiple statements " if you like. Another solution is to delete the " filter and type in the interactive unite window to " narrow down the output. " " - [make_key]s This is an exaple makefile call which calls make directly to " execute a task defined in the makefile. I would also do this with " unite in future versions of this configuration but I have a unicode " problem with it at them moment. The example calls " the make task showpdf. You can extend this to you " needs. nnoremap [make_key] nmap m [make_key] nnoremap [make_key] :Unite -input=error build nnoremap [make_key]s :Unite -no-empty build:make:showpdf " }}} " (q)quit fast {{{ " Description: " " Fast quit your document " " Mappings: " " [quit_key] close your document. " nnoremap [quit_key] nmap q [quit_key] nnoremap [quit_key] :q! " }}} " (r)eplace search visual selection {{{ " Description: " " These mappings help to search and replace content in your files. " " Mappings: " " - [replace_key] Works in vizual mode and replaces the current " marked text by a replacement defined by you. " " - [replace_key]s Is also a vizal mode mapping and Calls grep (ack) from current direcotry " recursive on its contents to find the currently " marked text. The results end up in a quickfix " window. This is really helpful when you like to " replace a string in all your project files. You " can combine it with the next command for " replacment. " " - [replace_key]a You can mark text in vizual mode and then call " this mapping. Does a quickfixdo which opens all the files " whith the occurence of the string you grepped " for in the quickfix window. It changes all " strings to a string defined by you and saves the " files. vnoremap [replace_key] vmap r [replace_key] vnoremap [replace_key] :call VisualSelection('replace') vnoremap [replace_key]s :call VisualSelection('acksearch') vnoremap [replace_key]a :call VisualSelection('quickfixdo') " }}} " (s)pellchecking {{{ " Description: " " This mappings help to spell check your files. " " Mappings: " " - [spell_key]s enables the spelling for the file. If you like to " auto enable spelling for a certain file type you " should have a look into the auto command section " below. " " - [spell_key]n Go to the next spelling error in the file. " " - [spell_key]p Go to the previous spelling error in file. " " - [spell_key]g Mark a word as good. " " - [spell_key]l Show a list of items which are suggested for the " misspelled word. " " - [spell_key]r Chose the first entry from list and replace the " misspelled word. nnoremap [spell_key] nmap s [spell_key] noremap [spell_key]s :setlocal spell! noremap [spell_key]n ]s noremap [spell_key]p [s noremap [spell_key]g zg noremap [spell_key]l z= noremap [spell_key]r 1z= " }}} " (t)toggle windows {{{ " Description: " " This mappings help you with file and tag navigation. They use the " plugin tagbar on one hand and on the other the vimfiler for file " navigation. The tagbar requires in background a working installation " of the ctags program. " " Mappings: " " - [toggle_key] opens a tagbar on the left side of a screen. In " this window you can navigate beween the functions " in your sourcecode. nnoremap [toggle_key] nmap t [toggle_key] nnoremap [toggle_key]t :TagbarToggle nnoremap [toggle_key]f :VimFiler -buffer-name=explorer -split -simple -winwidth=35 -toggle -no-quit "}}} " (v)izualize {{{ " Description: " " This mappings help to vizualize tabs and other invisivle " characters. Especially the tab vizualization is very helpful in " checking the indent of code. " " Mappings: " " - [vizualize_key] Vizualizes the indent with guide lines. nnoremap [vizualize_key] nmap v [vizualize_key] nnoremap [vizualize_key] :IndentGuidesToggle "}}} " (w)rite and quit fast {{{ " Description: " " This mappings help to write and to write and quit fast. " " Mappings: " " - [write_key] Write your document to file. " " - [write_key]q Write document and then quit Vim. nnoremap [write_key] nmap w [write_key] nnoremap [write_key] :w! nnoremap [write_key]q :wq! "}}} " (x)ecute a shell with interpreter {{{ " Description: " " The mappings around the letter x are thought to execute " shells with a certain interpreter. " " Mappings: " " todo: rework this mappings nnoremap [execute_key] nmap x [execute_key] " Send to shell nnoremap [execute_key]s :VimShellSendString vnoremap [execute_key]s :VimShellSendString " Start shell or shell with interpreter nnoremap [execute_key]b :ConqueTermSplit bash nnoremap [execute_key]r :VimShellInteractive R nnoremap [execute_key]c :VimShellInteractive rails console "}}} " (y)ank and paste management (Yankring) {{{ " Description: " " This mappings help you to deal with yanked text. They use the " yankring plugin. The yankring plugin maintains a yank history " which survives a Vim session. " " Mappings: " " - [yank_key]y Opens the yankring window where you can chose " which text you like to paste. " " - [yank_key]s Copy text from system Clipboard. After that you " can simply paste it by pressin p in normal mode. nnoremap [yank_key] nmap y [yank_key] nnoremap [yank_key]y :YRShow nnoremap [yank_key]s :YRPush '+' " }}} "}}} "}}} " Plugin configuration {{{ " (c)onque term {{{ let g:ConqueTerm_SendFunctionKeys = 0 let g:ConqueTerm_ExecFileKey = '' let g:ConqueTerm_SendFileKey = '' let g:ConqueTerm_SendVisKey = '' let g:ConqueTerm_FastMode = 1 let vimrplugin_underscore = 0 let vimrplugin_rnowebchunk = 0 let vimrplugin_ca_ck = 0 let vimrplugin_applescript = 0 let vimrplugin_screenplugin = 0 let vimrplugin_conqueplugin = 1 let ConqueTerm_CWInsert = 1 let ConqueTerm_Color = 0 let ConqueTerm_ReadUnfocused = 1 let vimrplugin_conquevsplit = 0 let g:ConqueTerm_TERM = 'vt100' " }}} " (l)usty juggler {{{ let g:LustyJugglerDefaultMappings = 0 " }}} " (n)eocomplcache and neosnippet {{{ " Set options let g:neocomplcache_enable_at_startup = 1 let g:neocomplcache_temporary_dir = '~/.vim/tmp/' let g:neocomplcache_enable_camel_case_completion = 1 let g:neocomplcache_enable_smart_case = 1 let g:neocomplcache_enable_underbar_completion = 1 let g:neocomplcache_min_syntax_length = 3 let g:neocomplcache_enable_auto_delimiter = 1 let g:neocomplcache_max_list = 15 let g:neocomplcache_auto_completion_start_length = 3 let g:neocomplcache_force_overwrite_completefunc = 1 let g:neocomplcache_enable_auto_select = 1 " Compatibility setting for LustyJuggler let g:neosnippet#disable_select_mode_mappings = 0 let g:neosnippet#snippets_directory='~/.vim/snippets/' " Define keyword. if !exists('g:neocomplcache_keyword_patterns') let g:neocomplcache_keyword_patterns = {} endif let g:neocomplcache_keyword_patterns['default'] = '\h\w*' " Enable omni completion. augroup neocomplcache_omni_completion autocmd! autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS autocmd FileType python setlocal omnifunc=pythoncomplete#Complete autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete augroup END " Enable heavy omni completion. if !exists('g:neocomplcache_omni_patterns') let g:neocomplcache_omni_patterns = {} endif let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\h\w*\|\h\w*::' let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::' let g:neocomplcache_omni_patterns.c = '\%(\.\|->\)\h\w*' let g:neocomplcache_omni_patterns.cpp = '\h\w*\%(\.\|->\)\h\w*\|\h\w*::' " For snippet_complete marker. if has('conceal') set conceallevel=2 concealcursor=i endif let g:header_author = "Claas-Thido Pfaff" " }}} " (n)erd commenter {{{ let g:NERDCreateDefaultMappings = 0 let g:NERDSpaceDelims = 1 let g:NERDCustomDelimiters = { \ 'snippet': {'left': '#'}, \ 'rnoweb' : {'left': '%', 'leftAlt': '#'} \ } " }}} " (p)owerline plugin {{{ let g:Powerline_symbols = 'fancy' " }}} " (r)ails plugin {{{ let g:rubycomplete_buffer_loading = 1 " }}} " (s)essionman session plugin {{{ set sessionoptions=blank,buffers,curdir,folds,tabpages,winsize " }}} " (s)yntastic {{{ let g:syntastic_stl_format = '[%E{Err: %fe #%e}%B{, }%W{Warn: %fw #%w}]' " }}} " (t)agbar options {{{ let g:tagbar_left = 0 " }}} " (t)ab guideline {{{ let g:indent_guides_enable_on_vim_startup = 0 let g:indent_guides_auto_colors = 0 let g:indent_guides_guide_size = 1 let g:indent_guides_start_level = 1 hi IndentGuidesOdd ctermbg=238 hi IndentGuidesEven ctermbg=243 " }}} " (u)nite vim {{{ " TODO: rework this configuration " Start insert. let g:unite_enable_start_insert = 1 let g:unite_source_file_mru_limit = 200 let g:unite_cursor_line_highlight = 'TabLineSel' let g:unite_abbr_highlight = 'TabLine' let g:unite_split_rule='belowright' " For optimize. let g:unite_source_file_mru_filename_format = '' " For ack. if executable('ack-grep') let g:unite_source_grep_command = 'ack-grep' let g:unite_source_grep_default_opts = '--no-heading --no-color -a' let g:unite_source_grep_recursive_opt = '' endif autocmd FileType unite call s:unite_my_settings() function! s:unite_my_settings() " Overwrite settings. nmap (unite_exit) imap kj (unite_insert_leave) imap (unite_select_next_line) "nmap (unite_toggle_auto_preview) nnoremap l \ unite#smart_map('l', unite#do_action('default')) let unite = unite#get_current_unite() if unite.buffer_name =~# '^search' nnoremap r unite#do_action('replace') else nnoremap r unite#do_action('rename') endif "imap - pumvisible() ? "\ "\(neocomplcache_start_unite_quick_match)" : '-' "imap (unite_delete_backward_path) "imap j unite#smart_map('j', '') "imap (unite_delete_backward_path) "imap - (unite_quick_match_default_action) "nmap - (unite_quick_match_default_action) "imap x "\ unite#smart_map('x', "\(unite_quick_match_choose_action)") "nmap x (unite_quick_match_choose_action) "nmap (unite_toggle_transpose_window) "imap (unite_toggle_transpose_window) "imap (unite_narrowing_path) "nmap (unite_narrowing_path) "nmap (unite_narrowing_input_history) "imap (unite_narrowing_input_history) "nnoremap cd unite#do_action('lcd') "nnoremap S unite#mappings#set_current_filters( "\ empty(unite#mappings#get_current_filters()) ? ['sorter_reverse'] : []) endfunction " }}} " (v)imshell {{{ " Global options let g:vimshell_split_command='belowright split' let g:vimshell_no_default_keymappings=1 let g:vimshell_temporary_directory='~/.vim/tmp/' " Buffer specific remapping " For all vimshells autocmd FileType int-* call s:vimshell_all_my_settings() function! s:vimshell_all_my_settings() imap (vimshell_int_execute_line) nmap (vimshell_int_previous_prompt) nmap (vimshell_int_next_prompt) nmap (vimshell_int_execute_line) nmap (vimshell_int_paste_prompt) nmap (vimshell_int_restart_command) nmap (vimshell_int_interrupt) nmap q (vimshell_int_exit) nmap cc (vimshell_int_change_line) nmap dd (vimshell_int_delete_line) nmap I (vimshell_int_insert_head) nmap A (vimshell_int_append_end) nmap i (vimshell_int_insert_enter) nmap a (vimshell_int_append_enter) nmap (vimshell_int_clear) " imap (vimshell_int_delete_backward_char) " imap (vimshell_int_delete_backward_char) " imap (vimshell_int_move_head) " imap (vimshell_int_delete_backward_line) " imap (vimshell_int_delete_backward_word) " imap (vimshell_int_delete_forward_line) " imap (vimshell_int_execute_line) " imap (vimshell_int_interrupt) " imap Start vimshell/history source " imap (vimshell_int_send_input) " imap " imap Select candidate or start completion endfunction " This can be done to have interpreter specific mappings "autocmd FileType int-R call s:vimshell_R_my_settings() "function! s:vimshell_R_my_settings() "imap (vimshell_int_execute_line) "endfunction "}}} " (v)imfiler plugin {{{ let g:vimfiler_as_default_explorer = 1 let g:vimfiler_no_default_key_mappings = 1 let g:vimfiler_tree_leaf_icon = ' ' let g:vimfiler_tree_opened_icon = '▾' let g:vimfiler_tree_closed_icon = '▸' let g:vimfiler_file_icon = '-' let g:vimfiler_marked_file_icon = '*' " For fll vimfiler autocmd FileType vimfiler call s:vimfiler_all_my_settings() function! s:vimfiler_all_my_settings() nmap (vimfiler_switch_to_other_window) endfunction " }}} " (y)ankring {{{ let g:yankring_history_dir = '~/.vim/tmp' " }}} "}}} " Functions {{{ " Delete trailing white space on save (Python and CoffeeScript) func! DeleteTrailingWS() exe "normal mz" %s/\s\+$//ge exe "normal `z" endfunc " " My fold text "function! MyFoldText() ""let nl = v:foldend - v:foldstart + 1 "let linetext = getline(v:foldstart + 1) "let text = linetext "return text "endfunction "set foldtext=MyFoldText() " " Small helper function! CmdLine(str) exe "menu Foo.Bar :" . a:str emenu Foo.Bar unmenu Foo endfunction " " Get visual selection function! VisualSelection(direction) range let l:saved_reg = @" execute "normal! vgvy" let l:pattern = escape(@", '\\/.*$^~[]') let l:pattern = substitute(l:pattern, "\n$", "", "") if a:direction == 'b' execute "normal ?" . l:pattern . "^M" elseif a:direction == 'gv' call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.') elseif a:direction == 'replace' call CmdLine("%s" . '/'. l:pattern . '/') elseif a:direction == 'f' execute "normal /" . l:pattern . "^M" elseif a:direction == 'acksearch' call CmdLine("Ack " . l:pattern . ' *') elseif a:direction == 'quickfixdo' call CmdLine("Qdo " . '%s/' . l:pattern . '/' . '/gc ' . '\|' . 'update') endif let @/ = l:pattern let @" = l:saved_reg endfunction " " Returns true if paste mode is enabled function! HasPaste() if &paste return 'PASTE MODE ' en return '' endfunction " "}}} " Autogroups {{{ " Return to last edit position when opening files augroup last_cursor_position autocmd! autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif augroup END "Remove trailing whilespaces augroup remove_trailing_spaces autocmd! autocmd BufWrite *.py :call DeleteTrailingWS() autocmd BufWrite *.coffee :call DeleteTrailingWS() augroup END " Tex files augroup tex_file_options autocmd! autocmd BufNewFile,BufRead *.tex set ft=tex augroup END " Rnw files augroup rnw_file_options autocmd! autocmd BufNewFile,BufRead *.Rnw set spell augroup END " Add $ to options augroup set_cp_options autocmd! autocmd BufNewFile,BufRead * set cpoptions+=$ augroup END "}}}