Tuesday, October 11, 2011

Sample vimrc file

syntax enable
set incsearch
set nocompatible
set showcmd
set hlsearch
set ai
set si
set ts=4 sw=4 smarttab
set nu
"set nowrap
set formatoptions+=r
set softtabstop=4
set smartindent
set autoindent
set showmatch
"set cursorline

source $HOME/.vim/plugin/taglist.vim
source $HOME/.vim/plugin/comments.vim

"highlight DiffAdd term=reverse cterm=bold ctermbg=white ctermfg=black
"highlight DiffChange term=reverse cterm=bold ctermbg=cyan ctermfg=black
"highlight DiffText term=reverse cterm=bold ctermbg=gray ctermfg=black
"highlight DiffDelete term=reverse cterm=bold ctermbg=cyan ctermfg=black

nnoremap <silent> <F1> :TlistToggle<CR>
"map <C-v><C-v> : vs<cr>
"map <C-q> : q<cr>

command CDC lcd %:p:h

hi LineNr   ctermfg=darkyellow
"hi Function ctermfg=cyan
hi Function ctermfg=yellow
"hi Type  ctermfg=cyan
hi Type  ctermfg=lightred
hi String ctermfg=darkgreen
"hi String ctermfg=150
hi Number ctermfg=brown
"hi Operator ctermfg=brown
hi Search ctermbg=yellow
hi Conditional ctermfg=green
hi Comment ctermfg=lightblue
"""
"if &term =~ "xterm\\|rxvt"
  " use an orange cursor in insert mode
  "let &t_SI = "\<Esc>]12;orange\x7"
  " use a red cursor otherwise
  "let &t_EI = "\<Esc>]12;red\x7"
  "silent !echo -ne "\033]12;red\007"
  "" reset cursor when vim exits
  "autocmd VimLeave * silent !echo -ne "\033]112\007"
  " use \003]12;gray\007 for gnome-terminal and rxvt up to version 9.21
"endif
highlight Cursor ctermfg=yellow ctermbg=black
"highlight iCursor guifg=white guibg=steelblue
"set guicursor=n-v-c:block-Cursor
"set guicursor+=i:ver100-iCursor
"set guicursor+=n-v-c:blinkon0
"set guicursor+=i:blinkwait10
"""

" Copyright abbreviations
iab cfn /*<CR>Function<CR><CR>Description<CR><CR>Parameter(s)<CR><CR>Return Value<CR>/<Up><Up><Up><Up><Up><Up>
iab todo // TODO Remove this
iab cpr Broadcom Proprietary and Confidential. Copyright © 2019 Broadcom.<CR>All Rights Reserved.<CR>The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.

iab testbin TOPDIR<TAB>= ../../..<CR>MAKEDIR<TAB>= $(TOPDIR)/make<CR><CR>include $(MAKEDIR)/Tools.make<CR>include $(MAKEDIR)/Targets.make<CR>include $(MAKEDIR)/Fabos.make<CR>include $(MAKEDIR)/Man.make<CR><CR>TESTBIN = testbin<CR>TESTBIN_SRCS = testbin.c<CR>TESTBIN_OBJS = $(TESTBIN_SRCS:.c=.o)<CR><CR>$(TESTBIN): $(TESTBIN_OBJS)<CR><TAB>$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)<CR>all:: $(TESTBIN)<CR><CR>clean::<CR><TAB>rm $(TESTBIN) $(TESTBIN_OBJS)


iab log_this #define LOG_THIS(format, ...) { \<CR>if (access("/harish", F_OK) != -1) { \<CR>char buf1[128] = {}; char buf2[256] = {}; \<CR>char tbuf[20] = {}; time_t now = time(0); struct tm *sTm = gmtime(&now); \<CR>strftime(tbuf, sizeof (tbuf), "%Y-%m-%d %H:%M:%S", sTm); \<CR>snprintf(buf1, sizeof (buf1), "[%s %s:%d]" format, tbuf, __func__, __LINE__, ##__VA_ARGS__); \<CR>snprintf(buf2, sizeof (buf2), "echo '%s' >> /harish_log", buf1); \<CR>system(buf2); } }


function! LoadCscope()
  let db = findfile("cscope.out", ".;")
  if (!empty(db))
    let path = strpart(db, 0, match(db, "/cscope.out$"))
    set nocscopeverbose " suppress 'duplicate connection' error
    exe "cs add " . db . " " . path
    set cscopeverbose
  " else add the database pointed to by environment variable
  elseif $CSCOPE_DB != ""
    cs add $CSCOPE_DB
  endif
endfunction
"au BufEnter /* call LoadCscope()

" http://cscope.sourceforge.net/cscope_maps.vim
nmap <C-\>ss :cs find s <C-R>=expand("<cword>")<CR><CR>
"nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>cc :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>tt :cs find t <C-R>=expand("<cword>")<CR><CR>
"nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>ff :cs find f <C-R>=expand("<cfile>")<CR><CR>
"nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
"nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>s :cs find s
nmap <C-\>g :cs find g
nmap <C-\>c :cs find c
nmap <C-\>t :cs find t
nmap <C-\>e :cs find e
nmap <C-\>f :cs find f
nmap <C-\>i :cs find i
nmap <C-\>d :cs find d

" quick fix options
nmap qf :set cscopequickfix=s-,c-,d-,i-,t-,e-
nmap noqf :set cscopequickfix=""
nmap cw :cwindow

"function! AddCscope()
    "echom "Adding CSCOPE file.. please wait"
    "silent! exec "r!goto_base_ws"
    ":cs add cscope.files
"endfunction
"nnoremap <silent> <F3> :call AddCscope()<CR>
"nnoremap <F3> :! ~/bin/goto_base_ws && cd vobs/projects/springboard/fabos <CR>:cs add cscope.files<CR>