Archive for the ‘vim’ Category

vim技巧一则

Sunday, December 6th, 2009

vim的用户应该都比较喜欢gf这个命令,直接编辑当前光标所在文件,方便快捷。其实还有另外两个类似的,只不过会在新窗口或者新标签中编辑。

    1. gf open in the same window (”goto file”)
    2. <c-w>f open in a new window (Ctrl-w f)
    3. <c-w>gf open in a new tab (Ctrl-w gf)

      比如,我用find/grep把一个匹配列表重定向到文件foo,然后在文件 foo 中用 <C-w> f 还是相当惬意的。

      Display Chinese TXT File in Vim/Emacs

      Saturday, July 18th, 2009

      For Vim, put the following line in ~/.vimrc:
      set fileencodings=utf-8,cp936

      For Emacs, add the following to ~/.emacs:
      (custom-set-variables
      '(current-language-environment "Chinese-GB"))

      Vim tips for SVN

      Tuesday, May 27th, 2008

      function! SVN_diff()
      let fn = expand(’%:p’)
      vnew +setl\ ft=diff\ bt=nowrite
      exe “:.!svn diff -r BASE ” . fn
      unlet fn
      endfunction

      map ,v :call SVN_diff()

      Paste above code in your ~/.vimrc, then you can use `,v‘ to display a diff in a vertical-split window.