Contents |
VIM Configuration File
Standard Locations for vimrc
- Home Dir: ~/.vimrc
- Debian: /etc/vim/vimrc or /etc/vim/vimrc.local
Features
- F1 -> F4: set a marker
- F5 -> F8: jump to a marker
- F9: toggle light/dark background
- F10: toggle paste mode
- F11: toggle line numbers
VIM Configuration File
" " VIM Configuration File " ---------------------------------------------------------------------------------------------- " " Developed by Kenny Moens " " General Settings set nocompatible " do not behave in a way that is compatible with VI set nobackup " we do not want to make backups set history=100 " keep a history of 100 commands " Window handling set title " show a title in the console set background=dark " dark background by default set splitright " split windows vertically set laststatus=2 " always show a status line in the window set virtualedit=all " allow the cursor to move everywhere even if there is no text if has('cmdline_info') set ruler " show the ruler line set showcmd " show partially typed commands set showmode " show the mode we are operating in endif " Search helping tools set showmatch " show the matching bracket when closing it set mps+=<:> " also apply matching to < and > if has('extra_search') set hlsearch " highlight matches endif " Settings for Layout/Indentation set textwidth=0 " we do not want any automatic line wrapping set shiftwidth=2 " applies to the (auto)indent of cident technique set shiftround " always round to multiples of shiftwidth set softtabstop=2 " a tab always is 2 spaces set expandtab " always replace tabs by spaces set autoindent " simple indentation based on indentation of previous line " Settings for syntax highlighting if has('syntax') syntax on endif " Settings for filetype detection if has('autocmd') filetype on filetype plugin on endif " Save information for 20 files, do not save search highlighting across sessions and " keep a buffer of up to 1000 lines set viminfo='20,h,\"1000 " " get rid of the default style of C comments, and define a style with two stars " at the start of `middle' rows which (looks nicer and) avoids asterisks used " for bullet lists being treated like C comments; then define a bullet list " style for single stars (like already is for hyphens): set comments+=sl:/*,mb:\ *,ex:*/ " treat lines starting with a quote mark as comments (for `Vim' files, such as " this very one!), and colons as well so that reformatting usenet messages from " `Tin' users works OK: set comments+=b:\" set comments+=n:: " Formatting settings for cindent " ------------------------------- " reformat when the following special keys have been typed set cinkeys=0{,0},!^F,o,O,e,*<Return>,0# " how to format C code " > normal indent (1 shiftwidth) " e indent for braces starting at the end of a line " n indent after a keyword when NOT in braces (don't do " this, it's non-standard) " f indent of the first opening brace (braces that are " not in other braces) " { indent of opening brace for braces in other braces " } indent of closing brace (relative to matching open brace) " ^ indent inside braces (relative to current indent) " : indent of case labels relative to the switch statement " = indent after a case label " p indent of K&R style paramter declarations " t indent for a function's type declaration " + indentation of a continuation line " c indentation of a comment line " ( indentation when in an unclosed () block " ) how far to look for an unclosed bracket (5 lines) " * how far to look for an unclosed comment (15 lines) "set cinoptions=>s,e0,n0,}0,^0,:s,=s,ps,ts,(2s,)5,*15,+s,f0,{0 set cinoptions=>s,e0,n0,f0,{0,}0,^0,:s,=s,l0,gs,hs,ps,ts,+s,c3,C0,(0,us,\U0,w0,m0,j0,)20,*30 " " trust me :-) " since the indenting is handle by the macros, you " don't need vim to jump and and double the indenting! set cinwords= " tell vim not to do screwy things when searching (This is the " default value, without c) set cpoptions=BeFs " Shortcut keys " ------------- " setting of a mark noremap <F1> mA noremap <F2> mB noremap <F3> mC noremap <F4> mD " jumping to a mark noremap <F5> 'A noremap <F6> 'B noremap <F7> 'C noremap <F8> 'D " toggle background colour map <F9> :call ToggleBackgroundColour()<CR> " toggle paste mode on/off map <F10> :set paste!<CR>:set paste?<CR> " toggle line numbers map <F11> :set number!<CR>:set number?<CR> " File Type Specific Configuration " -------------------------------- " recognize anything in my .Postponed directory as a news article, and anything " at all with a .txt extension as being human-language text [this clobbers the " `help' filetype, but that doesn't seem to prevent help from working " properly]: augroup filetype autocmd BufNewFile,BufRead *.xmap set filetype=xml autocmd BufNewFile,BufRead *.txt set filetype=human autocmd BufNewFile,BufRead *.p*co set filetype=pico autocmd BufNewFile,BufRead .myowncshrc set filetype=csh autocmd BufNewFile,BufRead *.cc set filetype=cpp augroup END " in human-language files, automatically format everything at 100 chars: autocmd FileType mail,human set formatoptions+=t textwidth=100 " for C-like programming, have automatic indentation: autocmd FileType c,cpp,slang,java set cindent showmatch matchtime=2 " for actual C (not C++) programming where comments have explicit end " characters, if starting a new line in the middle of a comment automatically " insert the comment leader characters: autocmd FileType c set formatoptions+=ro " for Perl programming, have things in braces indenting themselves: autocmd FileType perl set smartindent " for CSS, also have things in braces indented: autocmd FileType css set smartindent " for HTML, generally format text, but if a long line has been created leave it " alone when editing: autocmd FileType html set formatoptions+=tl " for both CSS and HTML, use genuine tab characters for indentation, to make " files a few bytes smaller: autocmd FileType html,css set noexpandtab tabstop=2 " in makefiles, don't expand tabs to spaces, since actual tab characters are " needed, and have indentation at 8 chars to be sure that all indents are tabs " (despite the mappings later): autocmd FileType make,gms_macro set noexpandtab shiftwidth=8 softtabstop=0 tabstop=8 " for lisp based languages autocmd FileType lisp,scheme set lisp showmatch " for pico language autocmd FileType pico set syntax=pico lisp showmatch " xslt autocmd FileType xslt let b:xml_namespace='xsl' " Functions " --------- " background toggle function ToggleBackgroundColour () if (&background == 'light') set background=dark echo "background -> dark" else set background=light echo "background -> light" endif endfunction
- Views -
Page -
Discussion -
View source -
History -
- Personal tools - 38.107.179.228 - Talk for this IP - Log in -
- Special - Special pages -
- Personal tools - 38.107.179.228 - Talk for this IP - Log in -
- Special - Special pages -