Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to survive the transition from tabbed-based to buffer-based coding (Vim)

Tags:

vim

tabs

buffer

I recently changed from notepad++ to Vim. In notepad++ I used to be aware of my open files by seeing them as tabs, so when I wanted to close or change them I just pressed Shift-Tab or Ctrl-W. In Vim there are also tabs, but when I use them I feel like I'm just going back to my notepad++ way of managing my files. Is there a good way of list, manage, switch and delete buffers other than splitting them?

like image 212
alexchenco Avatar asked Jan 23 '10 12:01

alexchenco


4 Answers

Yep. I recommend a buffer explorer plugin as well as learning buffer commands. I use this plugin.

http://www.vim.org/scripts/script.php?script_id=42

The buffer paradigm is quite elegant once you are used to it. Less visual clutter. but you are free with vim to find your own thing

like image 100
michael Avatar answered Nov 12 '22 21:11

michael


You can use these commands:

  • ls - list all open buffers
  • bp, bn - switch to the previous or next buffer
  • b number - switch to the buffer with that number
  • b text - switch to the buffer whose name includes the string text
like image 29
Nathan Fellman Avatar answered Nov 12 '22 20:11

Nathan Fellman


I've tried several setups for Vim. My previous was one where I tried to use tabs instead of buffers. It was not very satisfying.

Now I've returned to buffers and for navigating files and buffers I use only the NERDTree and fuzzyfinder (I guess ex Textmate users may prefer fuzzyfinder_textmate) plugins, both are great.

For locating files I use either NERDTree bound to n or fuzzyfinder's File mode. For navigating open buffers I use fuzzfinder's buffer mode solely, bound to b.

Recently I also discovered that I could switch to the previously open buffer with Ctrl-6 (I think maybe that is Ctrl-^ on most keyboard).

like image 3
vorpyg Avatar answered Nov 12 '22 20:11

vorpyg


There are so many ways to deal with buffers in vim.

CTRL-^ to switch between buffers.

:q is the same as Ctrl-W

For further details see http://vim.wikia.com/wiki/Easier_buffer_switching

like image 1
Yada Avatar answered Nov 12 '22 21:11

Yada