Showing posts with label vim. Show all posts
Showing posts with label vim. Show all posts

vim 101 - my vimrc

Monday, December 20, 2010

 "colorscheme ron  
"colorscheme jagadeesh
"color ir_black
colorscheme koehler
set nu
set nocindent
set hlsearch
set tabstop=4 shiftwidth=4 expandtab
set laststatus=2
"i don't want a toolbar in gvim
set guioptions-=T
"i dont want to see menu in gvim
set guioptions-=m
"map "+y
"imap "+y
"map "+gP
"imap "+gP
nmap "+g
map tnext
map tprev
map "+y
map "+x
map "+gP
imap "+y
imap "+x
imap "+gP
map gj
map gk
imap gki
imap gji
map []
map ][
imap []i
imap ][i
map gg
imap ggi
"Tab navigation
map gt
imap gta
au FileType tex set ai et tw=70 spell
au FileType c set cindent tw=80 nospell
au FileType h set cindent tw=80 nospell
au FileType cpp set cindent tw=80 nospell
autocmd BufEnter *.cu set cindent tw=80 nospell
au FileType cuh set cindent tw=80 nospell
autocmd BufEnter *.c,*.C,*.cpp,*.CPP,*.h,*.H,*.cu,*.cuh set guifont=Courier\ 10\ Pitch\ 12
autocmd BufEnter *.c,*.C,*.cpp,*.CPP,*.h,*.H,*.cu,*.cuh map [[
autocmd BufEnter *.c,*.C,*.cpp,*.CPP,*.h,*.H,*.cu,*.cuh map ]]
filetype plugin on
set ofu=syntaxcomplete#Complete
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
let OmniCpp_MayCompleteDot = 1 " autocomplete after .
let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview
let c_no_if0=0

Read more...

vim 101 : tip 1

Normally I use vim with multiple splits and tabs. Once I quit vim, I have to open them up all again, and remember which file (and the location in the file) I was editing before I quit.

Here is trick:
Before quitting vim, just run ":mksession" (if you have multiple tabs open, then in just one of them). And then quit.

Next time you are in the same folder, and want to open the same session just run the command "gvim -S"

The contexts are stored in session.vim. So if you want to overwrite it at some later point of time run the command with an override ":mksession!"

Read more...

Copying from external clipboard in gvim

Sunday, February 28, 2010

Normally, to copy from inside vim 'yy' and 'p' works. But if you are copying from an external application (say web browser or some other editor) it will not work. The easiest way is to do Edit->Paste.

But, to make life easier, we can remap it. Put this in ~/.vimrc
map "+gP

Further, to copy from vim to external clipboard, add this too:
map "+y

Now Ctrl+c and Ctrl+v works for copy paste in vim.

Read more...

vim tricks: jumping between preprocessor directives

Sunday, May 3, 2009

If you are somewhere in the code between a #if and a #endif:

  • You can jump to the #if part by using [#
  • You can jump to the #endif part using ]#
The alternate, and the generic option (which can jump between braces, #directives etc.) is the % key.

Read more...