docs:vim:vimrc

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
docs:vim:vimrc [2009/06/22 11:17] billhdocs:vim:vimrc [2011/12/16 10:24] (current) – [my .vimrc] fixed bug where browse listing was lost and a file was sometimes showing in place on that tab billh
Line 1: Line 1:
 ====== .vimrc ====== ====== .vimrc ======
-This is my current .vimrc configuration file (for the Mac, GUI Vim or MacVim)+ 
 +===== starting a new vimrc ===== 
 +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:<code> 
 +:mkvimrc ~/.vimrc 
 +</code> 
 + 
 +===== my .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.
 <code> <code>
 if has("gui_running") if has("gui_running")
  " size the initial window  " size the initial window
  :set columns=120  :set columns=120
- :set lines=55+ :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 endif
  
 " make unix (NL) the default file format " make unix (NL) the default file format
 :set ff=unix :set ff=unix
 +
 +" always show the status line
 +:set laststatus=2
  
 " syntax highlighting in color " syntax highlighting in color
Line 42: Line 61:
 :set nobackup :set nobackup
 :set writebackup :set writebackup
 +
 +" preserve file system modes on unix and in cygwin
 +:set backupcopy=yes
  
 " enable folding for php classes and functions " enable folding for php classes and functions
Line 56: Line 78:
 " color theme " color theme
 if has("gui_running") if has("gui_running")
- colo delek+ "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 else
- colo evening+ "colo evening 
 + "colo morning 
 + "colo zellner 
 + colo delek
 endif endif
  
Line 95: Line 136:
 " make .js.php files be recognized as javascript " make .js.php files be recognized as javascript
 au BufReadPost *.js.php setl filetype=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 " don't use changelog filetype
Line 105: Line 149:
 :map <F7> :set spell!<CR> :map <F7> :set spell!<CR>
  
-easy refresh of directory listings +use F5 to refresh 
-:map <F5> <c-l>+:map <F5> :e!<CR>
  
 " toggle line wrapping " toggle line wrapping
Line 127: Line 171:
  
 " // commenting/uncommenting on visual block selections " // commenting/uncommenting on visual block selections
-map g/ :s/^\([ \t]*\)/\1\/\/ /g<CR>:let @/=''<CR> +map g/ :s/^\([ \t]*\)/\1\/\/ /g<CR>:let @/=histget("search", -2)<CR> 
-map g? :s/^\([ \t]*\)\/\/ \{0,1}\([ \t]*\)/\1\2/g<CR>:let @/=''<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 " use , and . to shift indent and keep selection
Line 146: Line 190:
  
 " set the hide pattern for browsing (use 'a' to toggle) " set the hide pattern for browsing (use 'a' to toggle)
-let g:netrw_list_hide= '^\.[^\.]*$'+let g:netrw_list_hide= '^\.[^.]\|\.bak$'
  
 " clear previous search highlighting " clear previous search highlighting
Line 224: Line 268:
  amenu WMH.resync :syn sync fromstart<CR>  amenu WMH.resync :syn sync fromstart<CR>
  amenu WMH.nosyntax :syn clear<CR>  amenu WMH.nosyntax :syn clear<CR>
- amenu WMH.utf-8\ encoding :set encoding=utf-8<CR>:e!<CR> 
- amenu WMH.remove\ carriage\ returns :%s/\r//g<CR> 
  amenu WMH.find\ non-ascii\ characters gg/[^\o40-\o172]<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.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.-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\ 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\ Transitional i<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"<CR>   "http://www.w3.org/TR/html4/loose.dtd"><CR><ESC>
Line 235: Line 287:
  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\ 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.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.-Sep- :
  amenu WMH.837\ syntax :set filetype=837<CR>gg  amenu WMH.837\ syntax :set filetype=837<CR>gg
Line 245: Line 301:
 " default of sorting specific file types before others " default of sorting specific file types before others
 let g:netrw_sort_sequence = '[\/]$' 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 " always change current (local) directory to directory of current buffer
 " http://vim.wikia.com/wiki/Change_to_the_directory_of_the_current_file " http://vim.wikia.com/wiki/Change_to_the_directory_of_the_current_file
-if exists('+autochdir'+autocmd BufEnter * silent! lcd %:p:h:gs/ /\\ /
-  set autochdir +
-else +
-  autocmd BufEnter * silent! lcd %:p:h:gs/ /\\ / +
-endif+
  
 " make diff colors more like winmerge " make diff colors more like winmerge
Line 260: Line 315:
 autocmd ColorScheme * hi DiffText gui=NONE guibg=gold guifg=black autocmd ColorScheme * hi DiffText gui=NONE guibg=gold guifg=black
 autocmd ColorScheme * set fillchars=vert:\|,fold:-,diff: autocmd ColorScheme * set fillchars=vert:\|,fold:-,diff:
- 
  
 " make sure we are using unicode encoding " make sure we are using unicode encoding
 set encoding=utf-8 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()
 +
 </code> </code>
  • docs/vim/vimrc.1245691066.txt.gz
  • Last modified: 2009/06/22 11:17
  • by billh