Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
docs:vim:vimrc [2009/06/22 11:17] – billh | docs: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. | ||
+ | :mkvimrc ~/.vimrc | ||
+ | </ | ||
+ | |||
+ | ===== 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. | ||
< | < | ||
if has(" | if has(" | ||
" 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!< | ||
+ | " | ||
+ | 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(" | if has(" | ||
- | colo delek | + | "colo delek |
+ | "colo mustang | ||
+ | "colo two2tango | ||
+ | colo darkZ | ||
+ | "colo biogoo | ||
+ | set gfn=Courier_New: | ||
+ | |||
+ | " gui font (Mac) | ||
+ | if has(" | ||
+ | set gfn=Monaco: | ||
+ | elseif has(" | ||
+ | "set gfn=Courier_New: | ||
+ | set gfn=Courier_New: | ||
+ | elseif has(" | ||
+ | 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!< | :map <F7> :set spell!< | ||
- | " | + | " |
- | :map <F5> <c-l> | + | :map < |
" toggle line wrapping | " toggle line wrapping | ||
Line 127: | Line 171: | ||
" // commenting/ | " // commenting/ | ||
- | map g/ :s/^\([ \t]*\)/ | + | map g/ :s/^\([ \t]*\)/ |
- | map g? :s/^\([ \t]*\)\/\/ \{0,1}\([ \t]*\)/ | + | map g? :s/^\([ \t]*\)\/\/ \{0,1}\([ \t]*\)/ |
" 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 ' | " set the hide pattern for browsing (use ' | ||
- | let g: | + | let g: |
" clear previous search highlighting | " clear previous search highlighting | ||
Line 224: | Line 268: | ||
amenu WMH.resync :syn sync fromstart< | amenu WMH.resync :syn sync fromstart< | ||
amenu WMH.nosyntax :syn clear< | amenu WMH.nosyntax :syn clear< | ||
- | amenu WMH.utf-8\ encoding :set encoding=utf-8< | ||
- | amenu WMH.remove\ carriage\ returns : | ||
amenu WMH.find\ non-ascii\ characters gg/ | amenu WMH.find\ non-ascii\ characters gg/ | ||
amenu WMH.find\ non-ascii\ characters\ (ex\ tab\ nl\ cr) gg/ | amenu WMH.find\ non-ascii\ characters\ (ex\ tab\ nl\ cr) gg/ | ||
+ | amenu WMH.highlight\ rows :autocmd ColorScheme * hi CursorLine guibg=# | ||
+ | amenu WMH.nohighlight\ rows :set nocul< | ||
+ | amenu WMH.remove\ closed\ folds :call RemoveFolds()< | ||
amenu WMH.-Sep- : | amenu WMH.-Sep- : | ||
+ | amenu WMH.Filetype.reload\ as\ unix\ file :set ffs=unix< | ||
+ | amenu WMH.Filetype.reload\ as\ dos\ file :set ffs=dos< | ||
+ | amenu WMH.Filetype.reload\ as\ mac\ file :set ffs=mac< | ||
+ | amenu WMH.Filetype.remove\ carriage\ returns : | ||
+ | amenu WMH.Filetype.utf-8\ encoding :set encoding=utf-8< | ||
+ | amenu WMH.Filetype.latin1\ encoding :set encoding=latin1< | ||
+ | amenu WMH.Bookmarks.projects :Explore C: | ||
amenu WMH.Doctypes.HTML\ 4\.01\ Strict i< | amenu WMH.Doctypes.HTML\ 4\.01\ Strict i< | ||
amenu WMH.Doctypes.HTML\ 4\.01\ Transitional i< | amenu WMH.Doctypes.HTML\ 4\.01\ Transitional i< | ||
Line 235: | Line 287: | ||
amenu WMH.Doctypes.XHTML\ 1\.0\ Transitional i< | amenu WMH.Doctypes.XHTML\ 1\.0\ Transitional i< | ||
amenu WMH.Doctypes.XHTML\ 1\.0\ Frameset i< | amenu WMH.Doctypes.XHTML\ 1\.0\ Frameset i< | ||
+ | amenu WMH.PHP.xdebug_start_trace Oxdebug_start_trace(getcwd() . "/ | ||
+ | amenu WMH.PHP.xdebug_start_trace_append Oxdebug_start_trace(getcwd() . "/ | ||
+ | amenu WMH.SQL.format_numbers_for_where gg: | ||
+ | amenu WMH.SQL.format_strings_for_where gg: | ||
amenu WMH.-Sep- : | amenu WMH.-Sep- : | ||
amenu WMH.837\ syntax :set filetype=837< | amenu WMH.837\ syntax :set filetype=837< | ||
Line 245: | Line 301: | ||
" default of sorting specific file types before others | " default of sorting specific file types before others | ||
let g: | let g: | ||
+ | |||
+ | " case-insensitive sorting in netrw | ||
+ | let g: | ||
" always change current (local) directory to directory of current buffer | " always change current (local) directory to directory of current buffer | ||
" http:// | " http:// | ||
- | if exists(' | + | autocmd BufEnter * silent! lcd %:p:h:gs/ /\\ / |
- | set autochdir | + | |
- | else | + | |
- | | + | |
- | 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: | autocmd ColorScheme * set fillchars=vert: | ||
- | |||
" 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, | ||
+ | |||
+ | " 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 < | ||
+ | |||
+ | if has(" | ||
+ | |||
+ | " open an explorer window at the current directory | ||
+ | map < | ||
+ | |||
+ | " http:// | ||
+ | " http:// | ||
+ | |||
+ | " Save current buffer and diff the file using Tortoise SVN | ||
+ | map < | ||
+ | |||
+ | " Save the current buffer and execute the Tortoise SVN interface' | ||
+ | map < | ||
+ | |||
+ | " show the Tortoise SVN check for modifications screen for the current directory | ||
+ | map < | ||
+ | |||
+ | " show the Tortoise SVN commit screen for the current directory | ||
+ | map < | ||
+ | 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:// | ||
+ | let php_large_file = 0 | ||
+ | |||
+ | let g: | ||
+ | function! ToggleStatusLine() | ||
+ | " a more informative status line | ||
+ | " http:// | ||
+ | |||
+ | let g: | ||
+ | |||
+ | if( g: | ||
+ | " default status line | ||
+ | :set statusline= | ||
+ | elseif( g: | ||
+ | " file name, mod flags, and lots of file/cursor info | ||
+ | :set statusline=%t%m%r%h%w\ [FORMAT=%{& | ||
+ | elseif( g: | ||
+ | " full path to filename | ||
+ | :set statusline=%F%m%r%h%w | ||
+ | elseif( g: | ||
+ | " 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: | ||
+ | endif | ||
+ | endfunction | ||
+ | nnoremap <F10> :call ToggleStatusLine()< | ||
+ | :call ToggleStatusLine() | ||
+ | |||
+ | " use ctrl-v to paste clipboard in insert mode | ||
+ | if has(" | ||
+ | inoremap <C-v> < | ||
+ | endif | ||
+ | |||
+ | " use ctrl-f2 to toggle toolbar/ | ||
+ | " http:// | ||
+ | map < | ||
+ | |||
+ | " git-vim settings | ||
+ | let g:git_bin = ' | ||
+ | |||
+ | " VCSCommand settings | ||
+ | let VCSCommandGitExec = ' | ||
+ | "let VCSCommandSVNExec = ' | ||
+ | let VCSCommandSVNExec = ' | ||
+ | |||
+ | 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: | ||
+ | return 0 | ||
+ | else | ||
+ | return GetPhpIndent() | ||
+ | endif | ||
+ | endfunction | ||
+ | autocmd BufReadPost *.php setlocal indentexpr=MyGetPhpIndent() | ||
+ | |||
</ | </ |