You can download many vimrc files from the internet. If you want to start one with the current settings in your vim program, run this command:
:mkvimrc ~/.vimrc
This is my current .vimrc configuration file (for the Mac, GUI Vim or MacVim). Note that I allowed vim to set me up with a default vimrc on windows (see starting a new vimrc above), so some of the common windows key mappings are in place. These lines would be before the following.
if has("gui_running") " size the initial window :set columns=120 :set lines=50 " highlight the entire line the cursor is on ":set cul :map <F9> :set cul!<CR> "autocmd ColorScheme * hi CursorLine guibg=#E9EFF8 else " allow ctrl-z to suspend during terminal usage since it may be mapped to " undo in windows :unmap <C-z> endif " make unix (NL) the default file format :set ff=unix " always show the status line :set laststatus=2 " syntax highlighting in color :syntax enable " show line numbers and set number column width :set number if v:version >= 700 :set nuw=5 endif " don't soft wrap text :set nowrap " incremental search :set incsearch " highlight all matches for last used search pattern :set hls " automatic indenting :set ai " smart indenting :set si " don't restrict your backspace key :set backspace=start,indent,eol " only backup when trying to write, and don't keep backups " after vim closes :set nobackup :set writebackup " preserve file system modes on unix and in cygwin :set backupcopy=yes " enable folding for php classes and functions :let php_folding=1 :filetype plugin on :filetype indent on ":set omnifunc " ! only in Vim >= 7 ! " when a bracket is inserted, briefly jump to the " matching one :set showmatch matchtime=3 " color theme if has("gui_running") "colo delek "colo mustang "colo two2tango colo darkZ "colo biogoo set gfn=Courier_New:h12:cANSI " gui font (Mac) if has("mac") set gfn=Monaco:h13 elseif has("win32") "set gfn=Courier_New:h12:cANSI set gfn=Courier_New:h11:cANSI elseif has("unix") set gfn=Courier\ New\ 12 endif else "colo evening "colo morning "colo zellner colo delek endif " gui font (Mac) if has("mac") set gfn=Monaco:h13 endif " open files clicked or selected in Explore view in a new tab :let netrw_browse_split=3 " keep from polluting your folders with .swp (swap) files during editing if has("unix") set dir=~/tmp elseif has("win32") set dir=c:\\temp endif " code folding for javascript function! JavaScriptFold() setl foldmethod=syntax setl foldnestmax=1 syn region jsBlock start=/{/ skip=/\s*\/\/.*\|{.*}/ end=/}/ contains=ALL fold keepend extend transparent syn clear javaScriptComment syn region javaScriptComment start=+/\*+ end=+\*/+ contains=@Spell,javaScriptCommentTodo,jsBlock function! FoldText() return substitute(foldtext(), '{.*', '{...}', '') endfunction setl foldtext=FoldText() endfunction au FileType javascript call JavaScriptFold() au FileType javascript setl fen " make .js.php files be recognized as javascript au BufReadPost *.js.php setl filetype=javascript " make changelog.txt files have a set textwidth au BufReadPost changelog.txt setl textwidth=80 " don't use changelog filetype au FileType changelog setl filetype=text " delete a buffer :map <F4> :bd<CR> " toggle spelling :map <F7> :set spell!<CR> " use F5 to refresh :map <F5> :e!<CR> " toggle line wrapping :map <F3> :set wrap!<CR> " toggle invisibles :map <F6> :set list!<CR> " configure non-text preferences :set lcs=trail:_,eol:$,tab:>- " make tab stop (tab width in spaces) smaller :set ts=4 " make shift width (spaces for indenting << >>) smaller :set sw=4 :au GUIEnter * hi clear SpecialKey :au GUIEnter * hi link SpecialKey StatusLineNC " // commenting/uncommenting on visual block selections map g/ :s/^\([ \t]*\)/\1\/\/ /g<CR>:let @/=histget("search", -2)<CR> map g? :s/^\([ \t]*\)\/\/ \{0,1}\([ \t]*\)/\1\2/g<CR>:let @/=histget("search", -3)<CR> " use , and . to shift indent and keep selection vmap . >gv vmap , <gv " make unix the default file format for new files, and " first attempt at reading existing files :set ffs=unix,dos " make sure we can select the character under the " cursor when in visual mode :set selection=inclusive " show the ruler by default set ruler " set the hide pattern for browsing (use 'a' to toggle) let g:netrw_list_hide= '^\.[^.]\|\.bak$' " clear previous search highlighting :map <F8> :let @/=''<CR> " make vertical the default diff split (filler was already there) set diffopt=filler,vertical " html commenting (single lines only right now) map gh :s/\(.*\)/<!--\1-->/<CR>:let @/=''<CR> map gH :s/<!--\(.*\)-->/\1/<CR>:let @/=''<CR> " fold all lines not matching search pattern ( press \z ) map <silent><leader>z :setl foldexpr=getline(v:lnum)!~@/ foldlevel=0 foldcolumn=1 foldmethod=expr foldtext=v:folddashes<CR><CR> " javascript fold using search pattern technique (press zfj ) map zfj :/^\s*function.*{\s*$\\|^.*prototype.*=.*function.*$/<CR>:setl foldexpr=getline(v:lnum)!~@/ foldmethod=expr foldlevel=0 foldcolumn=1 foldtext=v:folddashes<CR><CR> " space toggles the fold state under the cursor. nnoremap <silent><space> :exe 'silent! normal! za'.(foldlevel('.')?'':'l')<cr> " disable cmd opt mappings for MacVim (interferes with winmerge mappings) let macvim_skip_cmd_opt_movement = 1 " use diff navigation like winmerge, using alt with up, down, left, right nnoremap <M-Down> ]c nnoremap <M-Up> [c function! CopyToLeft() if !&diff return endif let currwin = winnr() if( currwin == 1 ) :diffget else :diffput endif endfunction function! CopyToRight() if !&diff return endif let currwin = winnr() if( currwin == 1 ) :diffput else :diffget endif endfunction nnoremap <M-Right> :call CopyToRight()<CR> nnoremap <M-Left> :call CopyToLeft()<CR> " turn off anti-aliasing text set noanti " don't wrap around when searching set nowrapscan " fast window resizing map <C-kMinus> <C-W>- map <C-kPlus> <C-W>+ map <S-kMinus> <C-W>< map <S-kPlus> <C-W>> " use F12 to highlight and run the entire contents of the current file in the " next window (nice for testing syntax commands) map <F12> ggVGy:@"<CR> hi SpellBad ctermfg=white au FileType cpp setl foldmethod=syntax au FileType cpp setl foldnestmax=1 if has("gui_running") amenu WMH.resync :syn sync fromstart<CR> amenu WMH.nosyntax :syn clear<CR> amenu WMH.find\ non-ascii\ characters gg/[^\o40-\o172]<CR> amenu WMH.find\ non-ascii\ characters\ (ex\ tab\ nl\ cr) gg/[^\o40-\o172\o11\o12\o15]<CR> amenu WMH.highlight\ rows :autocmd ColorScheme * hi CursorLine guibg=#E9EFF8<CR> :set cul<CR> amenu WMH.nohighlight\ rows :set nocul<CR> amenu WMH.remove\ closed\ folds :call RemoveFolds()<CR> amenu WMH.-Sep- : amenu WMH.Filetype.reload\ as\ unix\ file :set ffs=unix<CR>:e ++ff=unix<CR> amenu WMH.Filetype.reload\ as\ dos\ file :set ffs=dos<CR>:e ++ff=dos<CR> amenu WMH.Filetype.reload\ as\ mac\ file :set ffs=mac<CR>:e ++ff=mac<CR> amenu WMH.Filetype.remove\ carriage\ returns :%s/\r//g<CR> amenu WMH.Filetype.utf-8\ encoding :set encoding=utf-8<CR>:e!<CR> amenu WMH.Filetype.latin1\ encoding :set encoding=latin1<CR>:e!<CR> amenu WMH.Bookmarks.projects :Explore C:\htdocs\projects\<CR> amenu WMH.Doctypes.HTML\ 4\.01\ Strict i<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"<CR> "http://www.w3.org/TR/html4/strict.dtd"><CR><ESC> amenu WMH.Doctypes.HTML\ 4\.01\ Transitional i<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"<CR> "http://www.w3.org/TR/html4/loose.dtd"><CR><ESC> amenu WMH.Doctypes.HTML\ 4\.01\ Frameset i<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"<CR> "http://www.w3.org/TR/html4/frameset.dtd"><CR><ESC> amenu WMH.Doctypes.XHTML\ 1\.0\ Strict i<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"<CR> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><CR><ESC> amenu WMH.Doctypes.XHTML\ 1\.0\ Transitional i<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<CR> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><CR><ESC> amenu WMH.Doctypes.XHTML\ 1\.0\ Frameset i<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"<CR> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"><CR><ESC> amenu WMH.PHP.xdebug_start_trace Oxdebug_start_trace(getcwd() . "/trace");<ESC> amenu WMH.PHP.xdebug_start_trace_append Oxdebug_start_trace(getcwd() . "/trace", XDEBUG_TRACE_APPEND);<ESC> amenu WMH.SQL.format_numbers_for_where gg:%s/^/,/g<CR>gg0xVGJgwgg:noh<CR> amenu WMH.SQL.format_strings_for_where gg:%s/^\(.*\)/,'\1'/g<CR>gg0xVGJgwgg:noh<CR> amenu WMH.-Sep- : amenu WMH.837\ syntax :set filetype=837<CR>gg amenu WMH.show\ 837\ syntax\ file :split ~/vimfiles/syntax/837.vim<CR> amenu WMH.Progress\ syntax :set filetype=progress<CR>gg amenu WMH.Progress\ quick\ folding gg/\c^[\s]*procedure\\|^[\s]*for each\\|^[\s]*load file\\|^[\s]*if<CR>\z endif " sort directory browsing by showing directories first, but don't use the " default of sorting specific file types before others let g:netrw_sort_sequence = '[\/]$' " case-insensitive sorting in netrw let g:netrw_sort_options="i" " always change current (local) directory to directory of current buffer " http://vim.wikia.com/wiki/Change_to_the_directory_of_the_current_file autocmd BufEnter * silent! lcd %:p:h:gs/ /\\ / " make diff colors more like winmerge autocmd ColorScheme * hi DiffAdd gui=NONE guibg=gold guifg=black autocmd ColorScheme * hi DiffChange gui=NONE guibg=lightyellow guifg=black autocmd ColorScheme * hi DiffDelete gui=NONE guibg=gray guifg=black autocmd ColorScheme * hi DiffText gui=NONE guibg=gold guifg=black autocmd ColorScheme * set fillchars=vert:\|,fold:-,diff:\ " make sure we are using unicode encoding set encoding=utf-8 " keep a few lines of padding when scrolling set scrolloff=3 " allow preview window to show even when there is only one match set completeopt=menuone,preview " set a maximum popup window height for completion results so it isn't allowed " to take up the whole screen set pumheight=8 " allow control space to act as omni-completion trigger, like IntelliSense inoremap <C-space> <C-x><C-o> if has("win32") " open an explorer window at the current directory map <silent> <leader>E :silent !"explorer.exe ."<CR> " http://vim.wikia.com/wiki/Call_TortoiseSVN_commands_from_within_Vim " http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-automation.html " Save current buffer and diff the file using Tortoise SVN map <silent> <Leader>td :w<CR>:silent !"C:/Progra~1/TortoiseSVN/bin/TortoiseProc.exe /command:diff /path:"%" /notempfile /closeonend"<CR> " Save the current buffer and execute the Tortoise SVN interface's log map <silent> <Leader>tl :w<CR>:silent !"C:/Progra~1/TortoiseSVN/bin/TortoiseProc.exe /command:log /path:"%" /notempfile /closeonend"<CR> " show the Tortoise SVN check for modifications screen for the current directory map <silent> <Leader>ts :silent !"C:/Progra~1/TortoiseSVN/bin/TortoiseProc.exe /command:repostatus /path:. /closeonend"<CR> " show the Tortoise SVN commit screen for the current directory map <silent> <Leader>tc :silent !"C:/Progra~1/TortoiseSVN/bin/TortoiseProc.exe /command:commit /path:. /closeonend"<CR> endif " don't allow NERDTree to take over our :E (explore) functionality let NERDTreeHijackNetrw = 0 " don't allow large php files to stop vim from folding, etc... " see http://www.mail-archive.com/pld-cvs-commit@lists.pld-linux.org/msg143762.html let php_large_file = 0 let g:statusline_mode = 0 function! ToggleStatusLine() " a more informative status line " http://www.linux.com/archive/feature/120126 let g:statusline_mode += 1 if( g:statusline_mode == 0 ) " default status line :set statusline= elseif( g:statusline_mode == 1 ) " file name, mod flags, and lots of file/cursor info :set statusline=%t%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L] elseif( g:statusline_mode == 2 ) " full path to filename :set statusline=%F%m%r%h%w elseif( g:statusline_mode == 3 && exists("*GitBranch") ) " relative path to filename with git info :set statusline=%f%m%r%h%w\ [GITBRANCH=%{GitBranch()}] else " restore default (wrap around) :set statusline= let g:statusline_mode = 0 endif endfunction nnoremap <F10> :call ToggleStatusLine()<CR> :call ToggleStatusLine() " use ctrl-v to paste clipboard in insert mode if has("win32") inoremap <C-v> <C-r>* endif " use ctrl-f2 to toggle toolbar/menubar " http://www.linux.com/archive/feature/120126 map <silent> <C-F2> :if &guioptions =~# 'T' <Bar> set guioptions-=T <Bar> set guioptions-=m <bar> else <Bar> set guioptions+=T <Bar> set guioptions+=m <Bar> endif<CR> " git-vim settings let g:git_bin = 'c:\cygwin\bin\git' " VCSCommand settings let VCSCommandGitExec = 'c:\cygwin\bin\git' "let VCSCommandSVNExec = 'C:\Program Files\svn-win32-1.6.6\bin\svn.exe' let VCSCommandSVNExec = 'c:\cygwin\bin\svn' function! RemoveFolds() folddoc :d endfunction " we need to override the default php indenting for heredoc to always put the " first line at the far left margin function! MyGetPhpIndent() if v:lnum > 1 && getline(v:lnum - 1) =~ '\s*<<<\s*' return 0 else return GetPhpIndent() endif endfunction autocmd BufReadPost *.php setlocal indentexpr=MyGetPhpIndent()