You are not logged in.

#26 2009-11-13 06:52:36

tomd123
Developer
Registered: 2008-08-12
Posts: 565

Re: Simple but effective vim tricks

I may not always use them, but I find macros very convenient at times, especially on files with very large amounts of data with patterns all over the place smile http://vim.wikia.com/wiki/Macros If you don't know how to use them, you should definitely check them out when you have the time.

Offline

#27 2009-11-13 20:07:00

djszapi
Member
From: Cambridge, United Kingdom
Registered: 2009-06-14
Posts: 1,439
Website

Re: Simple but effective vim tricks

* To delete trailing whitespaces automatically during saving, but exclude in *.patch files.

function RemoveTrailingSpace()
  if expand('%') =~? '\.patch$'
      return
    endif
    try
      %s/\s\+$//
      norm! ``
    catch /E486/
    endtry
  endfunction

autocmd BufWritePre * call RemoveTrailingSpace()

* Automatic ctags handling

  function! UPDATE_TAGS()
    let _f_ = expand("%:p")
    let _cmd_ = '"ctags -a -R $HOME/Targizi/pacman-3.2.2/ --c++-kinds=+p --fields=+iaS --extra=+q " ' . '"' . _f_ . '"'
    let _resp = system(_cmd_)
    unlet _cmd_
    unlet _f_
    unlet _resp
  endfunction
  au BufWritePost *.cpp,*.h,*.c call UPDATE_TAGS()
  " au BufWritePre * %s/\s\+$//e | norm! ``

* some plugins, like vim-nerdcommenter, vim-pastie

Some others, you can see my vimrc in similar threads smile

Offline

Board footer

Powered by FluxBB