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

Monday, May 12, 2008

Vim tips for SWIG

I've ever annoyed with the mixed tab and spaces in SWIG's code. Just talked it with William Fulton in #swig-gsoc. He suggested some tips.

This is a way to specific coding style by project:

au BufRead */[SWIG|swig]*/* set tabstop=8 | set shiftwidth=2 | set softtabstop=2 | set expandtab " SWIG

And a Syntax file for SWIG, add this in ~/.vimrc or ~/.vim/filetype.vim to use it:

" SWIG filetype file
if exists("did_load_filetypes")
finish
endif
augroup filetypedetect
au! BufRead,BufNewFile *.swg setfiletype swig
au! BufRead,BufNewFile *.i setfiletype swig
augroup END

Finally, a big thanks to William! :)

Friday, May 2, 2008

Auto-bracketing within Vim

The AutoClose Vim script inserts matching brackets automatically. It is useful for me, since I am lazy. But what annoying me is the script runs buggy in my Linux box. When I press , it often overwrite my program with a lot of brackets!

I looked into its codes, and commented out these two lines of code:

      "inoremap <silent> <Esc> <C-R>=<SID>CloseStackPop('')<CR><Esc>
"inoremap <silent> <C-[> <C-R>=<SID>CloseStackPop('')<CR><C-[>



Now it works well! Cheers!