Monday August 11, 2008 at 01:57
Subject: "Book" mode editing of code in vim.
Keywords:
Technical, vim
Posted by: Sean Reifschneider
When I'm coding, and sometimes when I'm writing, I like to see a lot
of code. Usually I just maximize my window vertically, which gives me
around 51 lines, and to the side of it I have a couple of windows I can use
for a Python shell, regular shell, or another editing session. Sometimes I
just want to see more code... Read on for a nifty trick I found in vim.
I had an idea that I might like to run with a vim window in full
screen mode, split into two long windows side by side. I did a quick
help search in vim and found the "scrollbind" option, which causes multiple
windows to scroll together. This is how the "vimdiff" scrolling works.
So, you can have two windows side-by-side with one page continuing
onto the next, like with a book.
To try it out, open up vim on /etc/services (for example), preferably
with your window as big as you can make it, then do the following:
(Post Reply)
-
1G -- Move to the first line of the file if you aren't
already there.
Control-W v -- Create two windows, split vertically.
:set scrollbind<ENTER> -- Set the current window to
have scrollbind enabled.
Control-W l -- Move to the window to the right.
Control-F -- Scroll forward a page.
:set scrollbind<ENTER> -- Set the current window to
have scrollbind enabled.
Control-W h -- Move to the window to the left.
(Post Reply)
| Comment |
Steve Webb Subject: Now I'm confused |
I'm a huge VIM user and I love using different windows, but this is just tweaking with my head. I don't like that scrolling/searching for something in one window also scrolls the other windows, but I can see what you're talking about about having more lines visible at the same time.