Jeff Cooper

Falling in Love (With an Editor)

Note: This post was imported from my old blog, created and written in my high school years

18 Aug 2009

So today I fell in love.  More specifically, I fell in love with the program Vim.  I have been a vim user for a little over a year, when I finally learned the basics and switched from nano. I knew Vim had more features than I could possibly imagine, but today that feeling doubled. One of the key features that I hadn't yet gotten around to learning was how vim handles multiple files. One of the reasons I still occasionally fired up something like Kate or used the pointer was copying large chunks of text from one file to another.

Enter Vim's Windowing system.

I learned about vim's windowing system from this fabulous vim tutorial.  Here's a brief summary of the windowing section

:split and :vsplit open new windows.  You can split as many times as you want in as many directions as you want.

^W (ctrl+w) and left/right/up/down/h/j/k/l moves between windows.  Keep in mind you must be in command mode (standard mode, hit escape a few times).  When you initially split a window, it will be two clones of the buffer (file) you were editing.  Simply move to that window and use :e filename to open the other file you want to edit.  Don't know it's name?  Use :e . to open the current directory in the file browser.  Navigation and selection is intuitive.  When you're done, just :wq (or :q or ZZ or :q!, whatever you want) to close the window, and the remaining windows fill the space.  Magic.

Not in the tutorial linked above but still useful are the commands to set the window sizes.  Simply use :set wiw=# (window width) or :set wh=# (window height) where # is a number of rows or columns.  If the number you give isn't absurd, vim will resize your window accordingly.

As I said, I love Vim.

comments powered by Disqus