News for hackers. Stuff that matters.
Re:Efficient Editing With vim by scott_s on Friday September 25, 2009 @01:57PM (#843951)
I feel silly for only recently discovering tabs in vim.

  :tabnew file
Opens up a new tab,

  :tabn
Goes to the next tab, and

  :tabp
Goes to the previous tab. Works great in both gui and non-gui mode.
Re:Efficient Editing With vim by cturner on Friday September 25, 2009 @02:54PM (#844061)
Similar to this, you can open up multiple files at the same time without saving.

    set bufhidden
    nmap <C-h> :bp
    nmap <C-l> :bn
If you put this in your .vimrc file, you'll need to put a '^M' at the end of the nmap lines. You do this by doing <C-v><C-m> and it puts in a special character that means newline. Then you can switch between open buffers with ctrl+l and ctrl+h even if you have unsaved changes. it will end up looking like this:

    set bufhidden
    nmap <C-h> :bp^M
    nmap <C-l> :bn^M
Unfortunately if you have many files open and don't touch them all it prevents you from quitting with a message 'E173: 17 more files to edit'. I haven't worked out how to obliterate this without damaging features I want (e.g. not quitting when there's unsaved data in those other files).

The default vim that ships with linux distributions is often a pile of junk that has been hacked by the distribution, is missing features like these. You want to get vim-extended under redhat-like distributions (they've significantly improved the quality if their junk vim in recent releases), and vim-nox or vim-full in debian-like distributions.

Re:Efficient Editing With vim by graywh on Friday September 25, 2009 @04:50PM (#844329)
Instead of a literal ^M in the file, just use <CR>.

And I think you mean "set hidden".

And regarding E173: You can :qa, which won't lose any unsaved changes.

And the proper vim package for Debian or Ubuntu is "vim". "vim-full" is the old name and it just installs "vim".

Re:Efficient Editing With vim by Prolitheus on Friday September 25, 2009 @10:36PM (#844898)
I rely on buffers rather than tabs, too, and find minibufexplorer.vim to be a great addition: http://www.vim.org/scripts/script.php?script_id=159
Re:Efficient Editing With vim by EAMiller on Friday September 25, 2009 @08:05PM (#844742)
I never got the hang of tabs. I got comfortable with buffers before tabs were out, and I didn't see anything that tabs could offer that buffers don't. I probably have my screen split between two buffers 60% of the time. Once in a while I have my screen split with screen AND with vim :D
Re:Efficient Editing With vim by apinstein on Friday September 25, 2009 @09:20PM (#844831)
tabs are pretty cool, but I like split and a set of macros I use for easily switching. The main reason I prefer split screen to tabs is that I often want to see code in the other buffer while I work.

Open up a file, :split a new one, and then try these:

map <C-j> <C-w>j80<C-w>+ " up one window, maximized map <C-k> <C-w>k80<C-w>+ " down one window, maximized map <C-h> 80<C-w>+ " maximize current window map <C-i> <C-w>= " all windows equal height

Re:Efficient Editing With vim by apinstein on Friday September 25, 2009 @09:18PM (#844827)
tabs are pretty cool, but I like split and a set of macros I use for easily switching. The main reason I prefer split screen to tabs is that I often want to see code in the other buffer while I work.

Open up a file, :split a new one, and then try these:

map <C-j> <C-w>j80<C-w>+ " up one window, maximized map <C-k> <C-w>k80<C-w>+ " down one window, maximized map <C-h> 80<C-w>+ " maximize current window map <C-i> <C-w>= " all windows equal height

Re:Efficient Editing With vim by DannoHung on Friday September 25, 2009 @02:17PM (#843988)
gt and gT in command mode also do next tab and previous tab
Re:Efficient Editing With vim by apotheon on Saturday September 26, 2009 @02:29AM (#845165)
I never bothered to learn that stuff before I started using Vimperator. I tend to prefer buffers over tabs for dealing with multiple files in a single Vim instance, so I never had much use for tab-related keybindings until I started using a vi-like interface for a tabbed browser.

Maybe that's just me, though.

Re:Efficient Editing With vim by bockris on Friday September 25, 2009 @02:39PM (#844037)
also #gt will go that tab number. I've changed my tab text to show the number in parenthesis before the name.
Re:Efficient Editing With vim by graysnorf on Friday September 25, 2009 @06:54PM (#844618)
For those who prefer alt navigation, you can add to your gvimrc

  " tab navigation
  map <A-1>  1gt
  map <A-2>  2gt
  map <A-3>  3gt
  map <A-4>  4gt
  map <A-5>  5gt
  map <A-6>  6gt
  map <A-7>  7gt
  map <A-8>  8gt
  map <A-9>  9gt
  map <A-0>  10gt
Re:Efficient Editing With vim by apotheon on Saturday September 26, 2009 @01:12AM (#845065)
What is that heretical "g" doing in front of "vimrc"?
Re:Efficient Editing With vim by graysnorf on Wednesday October 07, 2009 @06:28PM (#867808)
You know, if I had a terminal emulator that I could run vim with 24-bit colour depth in, that would go a long way towards turning me from the path of heresy.
Re:Efficient Editing With vim by graywh on Sunday September 27, 2009 @09:15AM (#846810)
Maybe it's some config he only uses in gvim.
Re:Efficient Editing With vim by apotheon on Monday September 28, 2009 @09:37PM (#849617)
Whoosh . . . ?
Re:Efficient Editing With vim by apotheon on Saturday September 26, 2009 @01:11AM (#845062)
This also works with Vimperator. I'm now thinking about installing that Firefox extension that gives all the tabs numbers, for ease of reference. Alas, I don't remember what it was called -- but I'm sure I'll find it again.
Re:Efficient Editing With vim by solutionyogi on Friday September 25, 2009 @03:30PM (#844137)
That's a neat idea. How do you change it to show tab number in the tab header?
Re:Efficient Editing With vim by bockris on Friday September 25, 2009 @03:40PM (#844160)
This is for GVIM.

  set guitablabel=(%N%M)\ %f
Re:Efficient Editing With vim by greyfade on Friday September 25, 2009 @10:23PM (#844888)

    :help setting-tabline
Re:Efficient Editing With vim by solutionyogi on Friday September 25, 2009 @02:32PM (#844023)
Awesome, I didn't know this shortcut before! Much better than using :tabn :tabp !
Re:Efficient Editing With vim by wooby on Friday September 25, 2009 @08:15PM (#844754)
You can always open files as tabs at startup too with -p, like this: vim -p foo.c foo.h
Re:Efficient Editing With vim by scott_s on Saturday September 26, 2009 @12:17AM (#844973)
Thanks, I've made frequent use of doing that with -o (horizontal split) and -O (vertical split).