"==============================================================================
" Global Variables
"==============================================================================
-let g:BufsLeft = "" " Buffers to the left of our current buffer
-let g:CurBuffer = "" " Name of our current buffer
-let g:BufsRight = "" " Buffers to the right of the current buffer
+let g:TemplateDir = $VIMHOME . "/templates" " Directory to search for templates
+let g:BufsLeft = "" " Buffers to the left of our current buffer
+let g:CurBuffer = "" " Name of our current buffer
+let g:BufsRight = "" " Buffers to the right of the current buffer
"==============================================================================
" Function and Command Definitions
"==============================================================================
" Function and Command Definitions
"==============================================================================
+
+" ToFn - Converts a group of C function prototypes to definitions ----
+command! -range=% -nargs=0 ToFn execute "<line1>,<line2>s/;/\r{\r\r}\r/"
+
+" LoadProject - Searches for and loads project specific settings
function! LoadProject()
let proj = findfile("project.vim", ".;")
let path = strpart(proj, 0, match(proj, "[\\\/]project.vim$"))
endif
endfunction
+" ReformatWhiteSpace - Convert tabs to spaces and remove trailing whitespace
function! ReformatWhiteSpace()
if &modifiable
retab
endif
endfunction
+" Template - Finds and inserts the text of the given template
+function! Template(input)
+ let tdir = g:TemplateDir
+ let tname = substitute(split(a:input,' ')[0], '\r', '', '') . '.m4'
+ let targs = strpart(a:input,stridx(a:input,' ')+1)
+ if filereadable( tdir . '/' . tname )
+ execute(".-1read !m4 -DARGS='" . targs . "' -I" . tdir . " " . tname)
+ else
+ echoerr "No template found: " . tname
+ endif
+endfunction
+
+" UpdateStatus - Updates the status bar to display a list of buffers
function! UpdateStatus(lmarg,rmarg)
" Reset our Globals
let g:CurBuffer = '[' . bufnr('%') . ' ' . expand('%:t') . ((&modified) ? ' +]' : ']')
endif
endfunction
-" ---- ToFn - Converts a group of C function prototypes to definitions ----
-command! -range=% -nargs=0 ToFn execute "<line1>,<line2>s/;/\r{\r\r}\r/"
-
"==============================================================================
" Keyboard Mappings
"==============================================================================
map j gj
map k gk
-" ---- Quick Save ----
-map <Leader>w :w<CR>
-
" ---- Toggle Fold ----
map zz <ESC>za
" ---- Omni Complete ----
inoremap <C-Space> <C-n>
+" ---- Template Replacement ----
+map ;t :call Template(getline("."))<CR>jdd
+
" ---- Buffer Management ----
map <C-S-tab> :bp<CR>
imap <C-S-tab> <ESC>:bp<CR>
" Command mode abbreviations
cnoreabbrev format <ESC><S-g>=gg
cnoreabbrev trim %s/\s\+$//
-cnoreabbrev print hardcopy
cnoreabbrev tofn ToFn
cnoreabbrev fn ToFn
cnoreabbrev <expr> ff
" Update the buffer list in the status line
autocmd VimEnter,BufNew,BufEnter,BufWritePost,VimResized,FocusLost,FocusGained,InsertLeave * call UpdateStatus(0,20)
-" Set filetypes
-autocmd BufRead,BufNewFile *.md set filetype=markdown
-
"==============================================================================
" Doxygen Comment Configuration
"==============================================================================
" GVim
"==============================================================================
if has('gui_running')
- set guioptions-=T " no toolbar
- set guioptions-=m " no menubar
- set guifont=Monaco:h10 " use 10 point Monaco font in gui mode
+ set guioptions-=T " no toolbar
+ set guioptions-=m " no menubar
+ set guifont=Monaco:h10 " use 10 point Monaco font in gui mode
" GVim resets this for some stupid reason so disable visual bell ... again
autocmd GUIEnter * set visualbell t_vb=