" Loads bundles
execute pathogen#infect()
" 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...
" Amazing - it never did.
"
" Implication here is that following a tag to another
" file will write the current file if modified
set autowrite
"
" Setting for Mac, but perhaps not always want this
"
"set makeprg=xcodebuild
" Ctrl-M shortcut to execute make
set makeprg=make
map <C-M> :make<CR>
" 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
" Ctrl-L to list current directory
" Enter when over item in the list, it opens it
map <C-D> :set splitright \| vnew \| r!svn cat #<CR>:windo :diffthis<CR><C-W><C-W>1G
map <C-E> <C-W><C-W>:q!<CR>
map <C-C> :!svn commit --editor-cmd vim %:p<CR>
map <C-S> :new \| r!svn st `svn info --show-item wc-root` \| sort -r<CR>1G
map <C-L> :new \| r!ls -la<CR>1G
map <CR> $b<C-W>gf
" Get SVN log on current file:
" map <C-L> :new \| r!svn log #<CR>1G
" Also useful might be being able to load particular revisions
" Or get the diff between revisions
" Or show the blame
" map <C-B> :new \| r!svn blame #<CR>1G
"
" Defaults for Bash-Support Vim plugin
"
let g:BASH_AuthorName = $USER_NAME
let g:BASH_AuthorRef = $USER_REF
let g:BASH_Email = $USER_EMAIL
let g:BASH_Company = $USER_COMPANY
"
" Appearance settings
"
set guifont=Monaco:h13
syn on
colorscheme obsidian
" colorscheme chlordane
" colorscheme colors
" My personal preference on Mac with no PgUp/PgDn
" Don't need up,down,left,right mapping if have arrow keys so make these keys more useful
" On keyboard the keys are arranged H L J K so for latin based language readers, it makes
" logical sense that H goes left/prev char and K goes right/next char, but normally L goes
" down and J goes up which makes no sense to me. Logically L should go up/prev line and K
" go down/next line to be consistent. So I have remapped them as follows:
" H -> go to beginning of the current line
" L -> go to the end of the current line
" 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 <PageUp>
map k <PageDown>
" 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 <C-Q> :qa!<CR>
" Next/Prev error in list
map <C-X> :cn<CR>
map <C-Z> :cp<CR>
map <C-N> :cn<CR>
map <C-P> :cp<CR>
" Indentation and tab settings
set expandtab
set shiftwidth=2
set softtabstop=2
set tabstop=2
" Justin informs me that :0 in your cinoptions is how you prevent the extra indentation on switch statements.
"cinoptions=[options],:0
"cinoptions+=:0
set tags=./tags;
map <space> <C-]>
map <tab> <C-O>
map <s-tab> <C-I>
" map <tab> <C-T>
" map <s-tab> b<C-V>w<left>g]
set shiftround
set autoindent
" P4 integration (from Trolltech days)
" map <C-E> :!p4 edit %<CR>:set noreadonly<CR>
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
syn keyword cType Q_UINT8 Q_UINT16 Q_UINT32 Q_ULONG
syn keyword cConstant TRUE FALSE
syn keyword cStorageClass Q_EXPORT
filetype on
set ignorecase
set smartcase
set incsearch
set hlsearch
" Spelling
let IspellLang = 'british'
let PersonalDict = '~/.ispell_' . IspellLang
abbreviate teh the
" * Keystrokes -- Moving Around
" have the h and l cursor keys wrap between lines (like <Space> and <BkSpc> do
" by default), and ~ covert case over line breaks; also have the cursor keys
" wrap in insert mode:
set whichwrap=h,l,~,[,]
" use <F6> to cycle through split windows (and <Shift>+<F6> to cycle backwards,
" where possible):
nnoremap <F6> <C-W>w
nnoremap <S-F6> <C-W>W
" have % bounce between angled brackets, as well as t'other kinds:
set matchpairs+=<:>
" have <F1> prompt for a help topic, rather than displaying the introduction
" page, and have it do this from any mode:
nnoremap <F1> :help<Space>
vmap <F1> <C-C><F1>
omap <F1> <C-C><F1>
map! <F1> <C-C><F1>
" * Keystrokes -- Formatting
" have Q reformat the current paragraph (or selected text if there is any):
" nnoremap Q gqap
" vnoremap Q gq
" Reformats the current function
map Q ]}=%
" have the usual indentation keystrokes still work in visual mode:
vnoremap <C-T> >
vnoremap <C-D> <LT>
vmap <Tab> <C-T>
vmap <S-Tab> <C-D>
" have Y behave analogously to D and C rather than to dd and cc (which is
" already done by yy):
noremap Y y$
" * Keystrokes -- Insert Mode
" allow <BkSpc> to delete linue breaks, beyond the start of the current
" insertion, and over indentations:
set backspace=eol,start,indent
" Why, because some MORON decided that gcc would be better at wordwrapping then anything else, and GOT IT WRONG!
set errorformat=%A%f:%l:%m,%C\ \ \ %m,%*[^\"]\"%f\"%*\\D%l:\ %m,\"%f\"%*\\D%l:\ %m,%-G%f:%l:\ (Each\ undeclared\ identifier\ is\ reported\ only\ once,%-G%f:%l:\ for\ each\ function\ it\ appears\ in.),%f:%l:%m,\"%f\"\,\ line\ %l%*\\D%c%*[^\ ]\ %m,%D%*\\a[%*\\d]:\ Entering\ directory\ `%f',%X%*\\a[%*\\d]:\ Leaving\ directory\ `%f',%DMaking\ %*\\a\ in\ %f
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
autocmd BufReadPost *
\ if expand("<afile>:p:h") !=? $TEMP |
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ let b:doopenfold = 1 |
\ endif |
\ endif
" Need to postpone using "zv" until after reading the modelines.
autocmd BufWinEnter *
\ if exists("b:doopenfold") |
\ unlet b:doopenfold |
\ exe "normal zv" |
\ endif
" set nowrap
" Enable right-clicking on things for a pop-up menu (instead of selecting)
" :set mousemodel=popup_setpos
set ruler
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 <buffer> execute bufwinnr(' . bufnr('#') . ') . ''wincmd w'''
" silent! execute 'nnoremap <silent> <buffer> <LocalLeader>r :call <SID>ExecuteInShell(''' . command . ''')<CR>'
" echo 'Shell command ' . command . ' executed.'
" endfunction
" command! -complete=shellcmd -nargs=+ Shell call s:ExecuteInShell(<q-args>)
function! PrintHelp()
" 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('$', " Ctrl-Q to quit all (without saving) ")
call append('$', " space to follow link under cursor ")
call append('$', " tab to go back in cursor history ")
call append('$', " Ctrl-T to navigate back ")
call append('$', " j / k to page up or down ")
call append('$', " [[ / ]] next/prev code block ")
call append('$', " % move to matching pair ")
call append('$', " Ctrl-I/O fwd/back in cursor history ")
call append('$', " ")
call append('$', " Editing keys: ")
call append('$', " Q reformat the current function ")
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('$', " Ctrl-L to list current directory ")
call append('$', " Enter to open file from status list ")
call append('$', " ")
endfunction
function! ShowHelp()
new
call PrintHelp()
endfunction
:command Help call ShowHelp()
function! ShowOnStartHelp()
" 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
call PrintHelp()
" No modifications to this buffer
setlocal nomodifiable nomodified
" When we go to insert mode start a new buffer, and start insert
nnoremap <buffer><silent> e :enew<CR>
nnoremap <buffer><silent> i :enew <bar> startinsert<CR>
nnoremap <buffer><silent> o :enew <bar> startinsert<CR>
endfunction
" Run after doing all the startup stuff
autocmd VimEnter * call ShowOnStartHelp()