| 1 |
" First things first - turn on no-compatible |
|---|
| 2 |
" (for advanced features) - otherwise we might |
|---|
| 3 |
" as well just use vi :-) |
|---|
| 4 |
set nocompatible |
|---|
| 5 |
|
|---|
| 6 |
" mac specific settings |
|---|
| 7 |
if exists( "$HOME" ) |
|---|
| 8 |
if $HOME == '/Users/kentcowgill' |
|---|
| 9 |
" my mac and terminal settings need this |
|---|
| 10 |
" to display color correctly. |
|---|
| 11 |
set term=xterm-color |
|---|
| 12 |
" take advantage of the perldoc filetype plugin |
|---|
| 13 |
helptags /Users/kentcowgill/.vim/doc |
|---|
| 14 |
" this is really only helpful where i have a browser |
|---|
| 15 |
" handy to view URLs |
|---|
| 16 |
function! Browser () |
|---|
| 17 |
let line = getline (".") |
|---|
| 18 |
let line = matchstr (line, "htt[^ ]*") |
|---|
| 19 |
exec "!open ".line |
|---|
| 20 |
endfunction |
|---|
| 21 |
" and a keymap to call it |
|---|
| 22 |
map <Leader>w :call Browser ()<CR> |
|---|
| 23 |
else |
|---|
| 24 |
" other unixen prefer this, and $HOME is likely different |
|---|
| 25 |
set term=xterm |
|---|
| 26 |
helptags /home/kcowgill/.vim/doc |
|---|
| 27 |
endif |
|---|
| 28 |
else |
|---|
| 29 |
" just in case, but ought to confirm this first |
|---|
| 30 |
set term=xterm |
|---|
| 31 |
helptags /home/kcowgill/.vim/doc |
|---|
| 32 |
endif |
|---|
| 33 |
|
|---|
| 34 |
set tags=./tags,../tags,../../tags,../../../tags |
|---|
| 35 |
|
|---|
| 36 |
" Display oriented settings |
|---|
| 37 |
" turn on syntax highlighting |
|---|
| 38 |
syntax enable |
|---|
| 39 |
" i prefer light on dark terminals |
|---|
| 40 |
set background=dark |
|---|
| 41 |
" load filetype plugins |
|---|
| 42 |
filetype plugin on |
|---|
| 43 |
filetype plugin indent on |
|---|
| 44 |
" the following scheme is good for presentations. |
|---|
| 45 |
colors desert |
|---|
| 46 |
"set cursorline |
|---|
| 47 |
" the desert colorscheme sets these a little |
|---|
| 48 |
" funny, so they're adjusted here |
|---|
| 49 |
highlight Folded term=standout ctermfg=6 |
|---|
| 50 |
\ guifg=SkyBlue |
|---|
| 51 |
highlight Pmenu ctermfg=1 ctermbg=4 |
|---|
| 52 |
\ guibg=grey30 |
|---|
| 53 |
highlight FoldColumn term=standout cterm=bold |
|---|
| 54 |
\ ctermfg=white ctermbg=0 guifg=gold guibg=grey30 |
|---|
| 55 |
highlight Ignore term=standout cterm=bold |
|---|
| 56 |
\ ctermfg=white ctermbg=0 guifg=gold guibg=grey30 |
|---|
| 57 |
"highlight CursorLine term=none cterm=none ctermbg=8 |
|---|
| 58 |
highlight Special ctermfg=13 |
|---|
| 59 |
" long lines are bad! |
|---|
| 60 |
highlight link rightMargin Error |
|---|
| 61 |
match rightMargin '\(^.\{78,\}\)\@<=.' |
|---|
| 62 |
" highlight whitespace at EOL: |
|---|
| 63 |
highlight link WhitespaceEOL Error |
|---|
| 64 |
2match WhitespaceEOL '\s\+$' |
|---|
| 65 |
" SpecialKey maps to at least the tabs I'm displaying |
|---|
| 66 |
high SpecialKey term=reverse ctermfg=4 |
|---|
| 67 |
" wrap long lines, don't make me scroll |
|---|
| 68 |
set wrap |
|---|
| 69 |
" balance braces |
|---|
| 70 |
set showmatch |
|---|
| 71 |
" how long to show matches (in 1/10ths of seconds) |
|---|
| 72 |
set matchtime=4 |
|---|
| 73 |
" add brackets |
|---|
| 74 |
set matchpairs+=<:> |
|---|
| 75 |
" filetype additions |
|---|
| 76 |
autocmd BufNewFile,BufRead *.t,*.ptml,*.cgi setf perl |
|---|
| 77 |
autocmd BufNewFile,BufRead *.tt,*.tt2 setf tt2html |
|---|
| 78 |
"autocmd FileType text call TextMode() |
|---|
| 79 |
autocmd FileType mail call TextMode() |
|---|
| 80 |
autocmd FileType perl call PerlMode() |
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
" Status line settings |
|---|
| 84 |
" show what mode we're in |
|---|
| 85 |
set showmode |
|---|
| 86 |
" always show the status line |
|---|
| 87 |
set laststatus=2 |
|---|
| 88 |
" always show cursor position |
|---|
| 89 |
set ruler |
|---|
| 90 |
" enhanced commandline/status completion |
|---|
| 91 |
set wildmenu |
|---|
| 92 |
set wildmode=longest:full,full |
|---|
| 93 |
" options for this are list, list:longest, list:longest,full |
|---|
| 94 |
|
|---|
| 95 |
" Searching and matching settings |
|---|
| 96 |
" jumps to search word as you type |
|---|
| 97 |
set incsearch |
|---|
| 98 |
" highlight search matches (but if you |
|---|
| 99 |
" like this, you can make it a more pleasant |
|---|
| 100 |
hi Search ctermbg=8 ctermfg=white cterm=bold |
|---|
| 101 |
hi IncSearch ctermbg=8 ctermfg=white cterm=bold |
|---|
| 102 |
set hls |
|---|
| 103 |
|
|---|
| 104 |
" Tabs and indenting settings |
|---|
| 105 |
" how to deal with tabs. indent of two |
|---|
| 106 |
set tabstop=2 |
|---|
| 107 |
" expand tabs to spaces |
|---|
| 108 |
set expandtab |
|---|
| 109 |
" number of spaces to use for autoindenting |
|---|
| 110 |
set shiftwidth=2 |
|---|
| 111 |
" auto indenting features |
|---|
| 112 |
set autoindent |
|---|
| 113 |
set smartindent |
|---|
| 114 |
"make tab in visual mode indent code |
|---|
| 115 |
vmap <tab> >gv |
|---|
| 116 |
vmap <s-tab> <gv |
|---|
| 117 |
" in insert mode, remaps tab to ctrl-n, for autocomplete |
|---|
| 118 |
inoremap <Tab> <C-N> |
|---|
| 119 |
" stop left indenting comments |
|---|
| 120 |
inoremap # X<C-H># |
|---|
| 121 |
" show tabs and spaces |
|---|
| 122 |
set list listchars=tab:\|-,trail:. |
|---|
| 123 |
|
|---|
| 124 |
" OS and environment settings |
|---|
| 125 |
set path=$PATH,.,/usr/bin,/usr/local/bin |
|---|
| 126 |
" how many lines of history to save |
|---|
| 127 |
set history=500 |
|---|
| 128 |
" backspace over newlines,autoindents, |
|---|
| 129 |
" and insertion point in insert mode |
|---|
| 130 |
set backspace=eol,indent,start |
|---|
| 131 |
"jump to last sursor position |
|---|
| 132 |
autocmd BufReadPost * |
|---|
| 133 |
\ if line("'\"") > 0 && line("'\"") <= line("$") | |
|---|
| 134 |
\ exe "normal g`\"" | |
|---|
| 135 |
\ endif |
|---|
| 136 |
augroup END |
|---|
| 137 |
" current directory follows the file being edited |
|---|
| 138 |
" as long as it's not a remote file (or a test file) |
|---|
| 139 |
function! AlwaysCD() |
|---|
| 140 |
if bufname("") !~ "^scp://" && bufname("") !~ "\.t$" |
|---|
| 141 |
lcd %:p:h |
|---|
| 142 |
endif |
|---|
| 143 |
endfunction |
|---|
| 144 |
autocmd BufEnter * call AlwaysCD() |
|---|
| 145 |
" backups, swapfiles |
|---|
| 146 |
set nobackup |
|---|
| 147 |
set nowb |
|---|
| 148 |
set noswapfile |
|---|
| 149 |
" allow to write any file we're allowed to |
|---|
| 150 |
" write, no ! necessary |
|---|
| 151 |
set writeany |
|---|
| 152 |
" set some easy key mappings for switching |
|---|
| 153 |
" buffers: when switching to a buffer above or |
|---|
| 154 |
" below, completely expand it, shrinking |
|---|
| 155 |
" all others maximally |
|---|
| 156 |
nmap <c-k> <c-w>k<c-w>_ |
|---|
| 157 |
nmap <c-j> <c-w>j<c-w>_ |
|---|
| 158 |
" shorthand for switching to right/left buffers and maximizing vertically |
|---|
| 159 |
nmap <c-l> <c-w>l<c-w>| |
|---|
| 160 |
nmap <c-h> <c-w>h<c-w>| |
|---|
| 161 |
" set a min window height for stacking windows |
|---|
| 162 |
set wmh=0 |
|---|
| 163 |
" set a min window width for stacking window left/right |
|---|
| 164 |
set wmw=0 |
|---|
| 165 |
" handily re-sources .vimrc on saving .vimrc file ;-) |
|---|
| 166 |
" <buffer> applies mapping as a local buffer mapping only |
|---|
| 167 |
autocmd BufEnter *.vimrc noremap <buffer> :w :w<cr>:source %<cr> |
|---|
| 168 |
"don't use Q for Ex mode |
|---|
| 169 |
map Q :q |
|---|
| 170 |
" keep the cursor in the center of the screen! |
|---|
| 171 |
set scrolloff=999 |
|---|
| 172 |
" support unicode |
|---|
| 173 |
set encoding=utf-8 |
|---|
| 174 |
" page on extended output |
|---|
| 175 |
set more |
|---|
| 176 |
" shift-f1 to toggle paste |
|---|
| 177 |
set pastetoggle=<S-F1> |
|---|
| 178 |
" set xterm title |
|---|
| 179 |
set title |
|---|
| 180 |
" ignore directories matching |
|---|
| 181 |
set wildignore+=*/CVS/ |
|---|
| 182 |
set wildignore+=*/SVN/ |
|---|
| 183 |
|
|---|
| 184 |
" Settings or text files. |
|---|
| 185 |
" turn on spelling when entering a text file: |
|---|
| 186 |
"autocmd BufRead,BufNewFile *.txt setlocal spell spelllang=en_us | set tw=78 |
|---|
| 187 |
|
|---|
| 188 |
" Settings for perl stuff. |
|---|
| 189 |
" perltidy things! true, perl-support provides this, but i had gotten |
|---|
| 190 |
" used to hitting "_t" to run my source through perltidy. |
|---|
| 191 |
nnoremap <silent> _t :%!perltidy -q<Enter> |
|---|
| 192 |
vnoremap <silent> _t :!perltidy -q<Enter> |
|---|
| 193 |
" instead of man pages, read perldoc on hitting K over a keyword! |
|---|
| 194 |
autocmd BufRead,BufNewFile *.pm,*.pl,*.t,*.ptml setlocal keywordprg=perldoc\ -f |
|---|
| 195 |
" type "#!P<CR>" in insert mode, and it expands to a default perl fileheader |
|---|
| 196 |
iabbrev #!P #!/usr/bin/perl<CR><CR>use strict;<CR>use warnings;<ESC>:filetype detect<CR>o |
|---|
| 197 |
" hit "#!+" when cursor is on a \w+, and a POD stub will be created above |
|---|
| 198 |
" the cursor, and you'll be dumped into insert mode in the appropriate place. |
|---|
| 199 |
nnoremap <silent> #!+ bywko<cr>=item <ESC>p$xo<CR><CR>=cut<CR><ESC>3ko |
|---|
| 200 |
vnoremap <silent> #!+ bywko<cr>=item <ESC>p$xo<CR><CR>=cut<CR><ESC>3ko |
|---|
| 201 |
" hit "#!-" and you get POD stub doumentation for the top of a file |
|---|
| 202 |
nnoremap <silent> #!- i<cr>=head1 NAME<cr><cr><cr>=head1 SYNOPSIS<cr><cr><cr>=head1 DESCRIPTION<cr><cr><cr>=head2 Header<cr><cr>=over 20<cr><cr>=item ItemName<cr><cr>=cut<cr><ESC> |
|---|
| 203 |
vnoremap <silent> #!- i<cr>=head1 NAME<cr><cr><cr>=head1 SYNOPSIS<cr><cr><cr>=head1 DESCRIPTION<cr><cr><cr>=head2 Header<cr><cr>=over 20<cr><cr>=item ItemName<cr><cr>=cut<cr><ESC> |
|---|
| 204 |
" hit "#!_" and you get POD stub doumentation for the bottom of a file |
|---|
| 205 |
nnoremap <silent> #!_ i<cr>=back<cr><cr>=head1 AUTHOR<cr><cr>Kent Cowgill - <kent@c2group.net><cr><cr>=head1 BUGS<cr><cr><cr>=head1 ACKNOWLEDGEMENTS<cr><cr><cr>=head1 SEE ALSO<cr><cr><cr>=cut<ESC> |
|---|
| 206 |
vnoremap <silent> #!_ i<cr>=back<cr><cr>=head1 AUTHOR<cr><cr>Kent Cowgill - <kent@c2group.net><cr><cr>=head1 BUGS<cr><cr><cr>=head1 ACKNOWLEDGEMENTS<cr><cr><cr>=head1 SEE ALSO<cr><cr><cr>=cut<ESC> |
|---|
| 207 |
|
|---|
| 208 |
noremap ,ai :r!grep "^sub" % \| awk '{print "=item " $2}' |
|---|
| 209 |
noremap ,ap maG:r ~/.vim/codesnippets-perl/podtemplate<cr>'a |
|---|
| 210 |
|
|---|
| 211 |
" Settings specific for the perl-support plugin |
|---|
| 212 |
" my perl includes pod |
|---|
| 213 |
let perl_include_pod = 1 |
|---|
| 214 |
" syntax color complex things like @{${"foo"}} |
|---|
| 215 |
let perl_extended_vars = 1 |
|---|
| 216 |
" give package names another color |
|---|
| 217 |
let perl_want_scope_in_variables = 1 |
|---|
| 218 |
" folding! |
|---|
| 219 |
"let perl_fold = 1 |
|---|
| 220 |
" misc settings, not that i've ever used them |
|---|
| 221 |
let g:Perl_AuthorName = 'Kent Cowgill' |
|---|
| 222 |
let g:Perl_AuthorRef = 'Mr.' |
|---|
| 223 |
let g:Perl_Email = 'kent@c2group.net' |
|---|
| 224 |
let g:Perl_Company = 'C2 Group, Inc.' |
|---|
| 225 |
|
|---|
| 226 |
" Setting for the VSTreeExplorer (vim -> IDE) |
|---|
| 227 |
" vim in terminal, so no setting the width! |
|---|
| 228 |
let Tlist_Inc_Winwidth=0 |
|---|
| 229 |
" make vtreeexplorer split vertically |
|---|
| 230 |
let treeExplVertical = 1 |
|---|
| 231 |
" and have it be 30 chars wide |
|---|
| 232 |
let treeExplWinSize = 30 |
|---|
| 233 |
" make it a bit more compact |
|---|
| 234 |
let treeExplIndent = 2 |
|---|
| 235 |
|
|---|
| 236 |
" tab navigation - ctrl-t opens new tab |
|---|
| 237 |
nmap <C-t> :tabnew<cr> |
|---|
| 238 |
imap <C-t> <ESC>:tabnew<cr> |
|---|
| 239 |
" hold shift and 'h' to go to next tab to the right |
|---|
| 240 |
map <S-h> gT |
|---|
| 241 |
" hold shift and 'l' to go to next tab to the left |
|---|
| 242 |
map <S-l> gt |
|---|
| 243 |
|
|---|
| 244 |
" ctags settings Stolen from Jason Crome |
|---|
| 245 |
set tags=tags |
|---|
| 246 |
let Tlist_Ctags_Cmd='/usr/local/bin/ctags' |
|---|
| 247 |
let Tlist_Inc_Winwidth=0 |
|---|
| 248 |
let Tlist_Show_One_File=1 |
|---|
| 249 |
let Tlist_Exist_OnlyWindow=1 |
|---|
| 250 |
let Tlist_Use_Right_Window=1 |
|---|
| 251 |
let Tlist_Sort_Type="name" |
|---|
| 252 |
let Tlist_Display_Prototype=0 |
|---|
| 253 |
let Tlist_Compact_Format=1 " Compact? |
|---|
| 254 |
let Tlist_GainFocus_On_ToggleOpen=1 |
|---|
| 255 |
let Tlist_Display_Tag_Scope=1 |
|---|
| 256 |
let Tlist_Close_On_Select=0 |
|---|
| 257 |
let Tlist_Enable_Fold_Column=0 |
|---|
| 258 |
let TList_WinWidth=50 |
|---|
| 259 |
map <S-F4> :TlistToggle<CR> |
|---|
| 260 |
map <silent> ,tl :TlistToggle<CR> |
|---|
| 261 |
|
|---|
| 262 |
function! TextMode() " Stolen from David Hand by way of Andy Lester |
|---|
| 263 |
set nocindent " nocin: don't use C-indenting |
|---|
| 264 |
set nosmartindent " nosi: don't "smart" indent, either |
|---|
| 265 |
set autoindent " ai: indent to match previous line |
|---|
| 266 |
set noshowmatch " nosm: don't show matches on parens, &c. |
|---|
| 267 |
set comments=n:>,n:#,fn:- " com: list of things to be comments |
|---|
| 268 |
"set textwidth=78 " tw: wrap at 72 characters |
|---|
| 269 |
"set formatoptions=tcrqn " fo: word wrap, format comments |
|---|
| 270 |
set dictionary+=/usr/share/dict/* " dict: dict for word completion |
|---|
| 271 |
set complete=.,w,b,u,t,i,k " cpt: complete words |
|---|
| 272 |
endfunction |
|---|
| 273 |
|
|---|
| 274 |
function! PerlMode() " Stolen from David Hand by way of Andy Lester |
|---|
| 275 |
set shiftwidth=2 " sw: a healthy tab stop |
|---|
| 276 |
"set textwidth=78 " tw: wrap at 72 characters |
|---|
| 277 |
set autoindent " ai: indent to match previous line |
|---|
| 278 |
set cindent " cin: Use C-indenting |
|---|
| 279 |
set cinkeys=0{,0},!^F,o,O,e " cink: Perl-friendly reindent keys |
|---|
| 280 |
set cinoptions=t0,+4,(0,)60,u0,*100 " cino: all sorts of options |
|---|
| 281 |
set cinwords=if,else,while,do,for,elsif,sub |
|---|
| 282 |
set comments=n:# " com: Perlish comments |
|---|
| 283 |
"set formatoptions=crql " fo: word wrap, format comments |
|---|
| 284 |
set nosmartindent " nosi: Smart indent useless under C-indent |
|---|
| 285 |
set showmatch " show matches on parens, bracketc, etc. |
|---|
| 286 |
endfunction |
|---|
| 287 |
|
|---|
| 288 |
|
|---|
| 289 |
" misc testing bits. |
|---|
| 290 |
|
|---|
| 291 |
" lookup docs for: |
|---|
| 292 |
" :set iskeyword |
|---|
| 293 |
" :set complete+=~/data/my_std_identifiers |
|---|
| 294 |
|
|---|
| 295 |
" set options by browsing |
|---|
| 296 |
" :options | resize |
|---|
| 297 |
|
|---|
| 298 |
" words to increase indent level for: |
|---|
| 299 |
" :set cinwords=if,else,etc |
|---|
| 300 |
|
|---|
| 301 |
" vim functions in perl: |
|---|
| 302 |
" :help :perl-using |
|---|
| 303 |
|
|---|
| 304 |
" K in normal mode looks up word under cursor |
|---|
| 305 |
" :set keywordprog=perldoc |
|---|
| 306 |
" |
|---|
| 307 |
" z= gives word list |
|---|
| 308 |
" ]s move to next misspelled word |
|---|
| 309 |
" [s move to previous misspelled word |
|---|
| 310 |
" zg add word under cursor to the spell file |
|---|
| 311 |
" zug undo that |
|---|
| 312 |
" zG temporarily remember word |
|---|
| 313 |
" zuG undo that |
|---|
| 314 |
" zw mark the word as a bad word |
|---|
| 315 |
" zuw undo that |
|---|
| 316 |
" zW temporarily |
|---|
| 317 |
" zuW undo that |
|---|
| 318 |
set tw=0 |
|---|
| 319 |
set formatoptions=tcrqn " fo: word wrap, format comments |
|---|
| 320 |
set fo+=t |
|---|
| 321 |
set fo-=o |
|---|
| 322 |
set fo-=l |
|---|
| 323 |
|
|---|