diff --git a/VimSetup.rc b/VimSetup.rc index 593d3b0..ae53725 100644 --- a/VimSetup.rc +++ b/VimSetup.rc @@ -1,4 +1,8 @@ +" Make vim behave like vim rather than like vi +set nocompatible +" set backup + " " set guioptions-=T " going to use this until it comes back to bite me... @@ -10,9 +14,22 @@ " Setting for Mac, but perhaps not always want this " "set makeprg=xcodebuild -set makeprg=make -set guifont=Monaco:h13 +" Ctrl-M shortcut to execute make +set makeprg=make +map :make + +" SVN related integration +" Ctrl-D to diff working copy +" Ctrl-E to go back to editing +" Ctrl-C to commit working copy +" Ctrl-S to list repository status +" Enter when over item in the list, it opens it +map :set splitright \| vnew \| r!svn cat #:windo :diffthis1G +map :q! +map :!svn commit --editor-cmd vim %:p +map :new \| r!svn st `svn info --show-item wc-root` \| sort -r1G +map $bgf " " Defaults for Bash-Support Vim plugin @@ -22,18 +39,15 @@ let g:BASH_Email = $USER_EMAIL let g:BASH_Company = $USER_COMPANY +" +" Appearance settings +" +set guifont=Monaco:h13 syn on - -" -" Set color scheme -" -" colorscheme obsidian -color obsidian +colorscheme obsidian " colorscheme chlordane " colorscheme colors -" set backup -set nocompatible " My personal preference on Mac with no PgUp/PgDn @@ -47,17 +61,23 @@ " J -> go up a page " K -> go down a page " If you want to move about by characters, there are the arrow keys -map h ^ -map l $ -map j  -map k  +" map h ^ +" map l $ +map j +map k -map  :cn -map  :cp -" or -" map N :cnVM -" map P :cpVM +" Lets various keys like ^S and ^Q pass through to vim, rather than caught by the terminal +silent !stty -ixon > /dev/null 2>/dev/null + +" Quit all (without writing) +map :qa! + +" Next/Prev error in list +map :cn +map :cp +map :cn +map :cp " Stuff From wiki @@ -80,9 +100,13 @@ set shiftround set autoindent -map :!p4 edit %:set noreadonly + +" P4 integration (from Trolltech days) +" map :!p4 edit %:set noreadonly map Q :" Q enters EX mode. You don't want EX mode. + + syn keyword cType uchar ushort uint ulong syn keyword cType pchar puchar pcchar syn keyword cType Q_INT8 Q_INT16 Q_INT32 Q_LONG @@ -153,13 +177,11 @@ if !exists("autocmd_loaded") let autocmd_loaded = 1 - " autocmd BufNewFile,BufRead *.cpp,*.c,*.h,*.txt,*.qdoc,*.doc setlocal spell spelllang=en_us autocmd BufNewFile,BufRead *.doc,*.qdoc,*.book,*.leaf set filetype=doc autocmd BufNewFile,BufRead *.pro,*.pri set filetype=pro autocmd BufNewFile,BufRead *akefile*,*.inc,*.mak set noexpandtab autocmd BufNewFile,BufRead *akefile*,*.inc,*.mak set filetype=make - endif " Remember the position of the cursor from previous edits @@ -170,6 +192,7 @@ \ let b:doopenfold = 1 | \ endif | \ endif + " Need to postpone using "zv" until after reading the modelines. autocmd BufWinEnter * \ if exists("b:doopenfold") | @@ -177,11 +200,92 @@ \ exe "normal zv" | \ endif -set nowrap +" set nowrap " Enable right-clicking on things for a pop-up menu (instead of selecting) " :set mousemodel=popup_setpos set ruler -" set number +set number + +highlight LineNr ctermfg=5 + + +" function! s:ExecuteInShell(command) +" let command = join(map(split(a:command), 'expand(v:val)')) +" let winnr = bufwinnr('^' . command . '$') +" silent! execute winnr < 0 ? 'botright vnew ' . fnameescape(command) : winnr . 'wincmd w' +" setlocal buftype=nowrite bufhidden=wipe nobuflisted noswapfile nowrap number +" echo 'Execute ' . command . '...' +" silent! execute 'silent %!'. command +" silent! execute 'resize ' +" silent! redraw +" silent! execute 'au BufUnload execute bufwinnr(' . bufnr('#') . ') . ''wincmd w''' +" silent! execute 'nnoremap r :call ExecuteInShell(''' . command . ''')' +" echo 'Shell command ' . command . ' executed.' +" endfunction +" command! -complete=shellcmd -nargs=+ Shell call s:ExecuteInShell() + + +function! ShowHelp() + " Only continue if started without opening a file or anything fancy + if argc() || line2byte('$') != -1 || v:progname !~? '^[-gmnq]\=vim\=x\=\%[\.exe]$' || &insertmode + return + endif + + " Start a new buffer ... + enew + + " ... and set some options for it + setlocal + \ bufhidden=wipe + \ buftype=nofile + \ nobuflisted + \ nocursorcolumn + \ nocursorline + \ nolist + \ nonumber + \ noswapfile + \ norelativenumber + + " Now we can just write to the buffer, whatever you want. + call append('$', " ") + call append('$', " John's .vimrc Extensions 1.0 ") + call append('$', " " . split(system('vi --version'),'(')[0] ) + call append('$', ' ' . split(system('uname -v'),':')[0]) + call append('$', " ") + call append('$', " Navigation keys: ") + call append('$', " space to follow tag/symbol under cursor ") + call append('$', " tab to follow tag/symbol under cursor ") + call append('$', " Ctrl-Q to quit all (without saving) ") + call append('$', " j / k to page up or down ") + call append('$', " ") + call append('$', " Compiling integration: ") + call append('$', " Ctrl-M to execute make ") + call append('$', " Ctrl-N/X to jump to next error ") + call append('$', " Ctrl-P/Z to jump to prev error ") + call append('$', " ") + call append('$', " SVN related integration: ") + call append('$', " Ctrl-D to diff working copy ") + call append('$', " Ctrl-E to go back to editing ") + call append('$', " Ctrl-C to commit working copy ") + call append('$', " Ctrl-S to list repository status ") + call append('$', " Enter to open file from status list ") + call append('$', " ") + + " No modifications to this buffer + setlocal nomodifiable nomodified + + " When we go to insert mode start a new buffer, and start insert + nnoremap e :enew + nnoremap i :enew startinsert + nnoremap o :enew startinsert + +endfunction + + +" Run after doing all the startup stuff +autocmd VimEnter * call ShowHelp() + +