mntnoe.com

Tips and tweaks making you more efficient with your favorite Linux tools.

Browsing Posts tagged tabs

Update: New version available. It is ported to native Vim Script, and support has been added for wildcards in &path. Download. Add the file to your .vimrc, or fit it in as a plugin.

On March 27, 2008:

When you use the normal gf and <C-]> bindings, you change the buffer in the current window. There is also an option to create a new window when doing it, but there are no way to reuse windows that already show the corresponding buffer, at least not natively.

You can reuse tabs and windows (like other IDE’s) with findtab.py, which is a simple Python script consisting of three functions. To use it, add something like the following to your .vimrc:

pyfile ~/.vim/extern/findtab.py
nnoremap <M-]> :python TabTag()<Cr>
nnoremap <C-w><M-f> :python TabFile()<Cr>

I have tried to make TabFile() work like gf, supporting path, includeexpr and suffixesadd. I think TabTag() works like <C-]>. The script also supplies a general Python function called FindTag(filename). It works as you think…

  • Facebook
  • Twitter
  • Digg
  • Reddit
  • del.icio.us
  • StumbleUpon

This is a simple, but important tip:

Tabbed interfaces have emerged everywhere, and also Vim 7 comes with support for it. For projects consisting of multiple files, I find it easier to work with tabs than with split windows and multiple buffers. Of course we need some better keybindings:

inoremap <M-n> <C-o>gt
inoremap <M-p> <C-o>gT
inoremap <M-w> <Esc>:tabclose<Cr>
inoremap <M-t> <Esc>:tabe<Cr>
nnoremap <M-n> gt
nnoremap <M-p> gT
nnoremap <M-w> :tabclose<Cr>
nnoremap <M-t> :tabe<Cr>

Also, making the tab bar always visible encourages you to use them more:

set showtabline=2

Now remember to use the -p parameter when you open Vim with multiple files:

vim -p *.tex

Having multiple files open in for instance LaTeX projects also allows you to use completion in references to labels in the corresponding files.

BTW add colon and underscore to iskeyword to enable completion for labels like fig:nice_figure. Oh yes, and use latex-suite

  • Facebook
  • Twitter
  • Digg
  • Reddit
  • del.icio.us
  • StumbleUpon