Vim Viewports (Windowing tips for a Text Editor)

Posted: January 29th, 2009 | Author: Jeff | Filed under: software | Tags: , | 2 Comments »

If you didn’t know it about me, I’m a very big fan of using text as my default method of storing information.  Whether it’s a note about the specific hex colors for a website, my daily tasks, projects or  todo lists, I keep them all in plaintext files.  I made the transition to text-only years ago when I ran into issues trying to move my palm-pilot memos to a new platform.  It took quite a bit of manipulation before finally being able to migrate my information from a proprietary format into one that is ubiquitous.  Plaintext is ultimately portable and can be taken everywhere.  I will always be able to read my plaintext files.  No, they’re not formatted all nice and pretty, but I can use html or some other markup language if I want to make them look nice.  No, my primary concern is that I can read them.  Twenty years from now, I am confident that whatever office suite word processor is in vogue, it will be able to read my meager text files.   Those old Wambulator 5 files?  I’m probably gonna be out of luck with those.

Emacs

Emacs

Text editors are varied and many-flavored.  In the unix world, there are two primary editors: Vim and Emacs.  Both have their strengths and weaknesses.  (please, no need to get all huffy about it, I use both.  It’s true and I admit it: I am ambi-textrous)   For the quick editing of small scripts, notes, or log files I tend to favor the use of Vim.   I have a handful of basic Vim commands that I use constantly to edit and save files; a few commands such as search and replace functions that get used occasionally; and then there is a whole world of commands that I am completely unfamiliar with.  Vim Viewports is one such category of commands.

Did you know that the text editor Vim (which stands for Visual editor IMproved) is capable of providing a windowed editing page?   In Vim-land, these windows are called ‘viewports’   When you first invoke Vim from the unix command line you start out with a single viewport.

Vim - Single viewport

Vim - Single viewport

This is the default view that most users of Vim are used to seeing.   I’ve been using Vim (or it’s predecessor Vi) for well over a decade now and this single-viewport view is the only one I’ve used until very recently.   There are times when I want to be able to edit one file, while referencing another.  Before utilizing viewports, that meant opening another terminal, setting up another connection, and displaying the reference file using cat, less or more (depending on the system)

That all changed when I re-discovered the fact that Vim supports multiple viewports!  From the command mode of Vim (there are two modes; command mode and edit mode.  If you are unfamiliar with these concepts then this article is most likely not for you. Go learn some Vim basics over at the Vim homepage: http://www.vim.org/ then please come back!)

::ahem:: Where were we?

Vim - Three Viewports

Vim - Three Viewports

Ah yes, from the command mode of Vim enter :split to split the current viewport horizontally.  Entering :vsp will split the window vertically.  Different text can then be loaded into each viewport using :e <filename>  Moving from one viewport to the next is accomplished using Ctrl-w Ctrl-w.  (that’s Ctrl-w twice, not a typo)   Or the standard Vim cursor movement keys modified with a Ctrl-w will also move you between viewports.  So Ctrl-w j will move you one viewport down, Ctrl-w k will move you one viewport up, and so on.  (for h j k l )

The content of each viewport can be swapped back and forth or rotated by using Ctrl-w r to move the current viewport contents to the right or Ctrl-w R to move the contents to the left.

It’s easy to open a bunch of viewports and have them all different sizes, making the contents difficult to read.  Issuing Ctrl-w = will resize all of the viewports, making them equal sizes (or as close as possible)

Some Vim commands for manipulating viewports

:sp|:split will split the Vim window horizontally.

:vsp|:vsplit will split the Vim window vertically.

Ctrl-w Ctrl-w moves between Vim viewports.

Ctrl-w j moves one viewport down.

Ctrl-w k moves one viewport up.

Ctrl-w h moves one viewport to the left.

Ctrl-w l moves one viewport to the right.

Ctrl-w = tells Vim to resize viewports to be of equal size.

Ctrl-w – reduce active viewport by one line.

Ctrl-w + increase active viewport by one line.

Ctrl-w q will close the active window.

Ctrl-w r will rotate windows to the right.

Ctrl-w R will rotate windows to the left.

Do you have a great Vim tip?  Or an <editor of your choice> tip?  Then be sure to comment below, I’d love to learn something new!


Brief Notes on Installing OpenSolaris in VMWare Fusion

Posted: January 25th, 2009 | Author: Jeff | Filed under: Macintosh, Solaris | Tags: , , , | 1 Comment »

These notes pertain specifically to OpenSolaris build 105 and VMWare Fusion v.2.01 on MacOS Leopard 10.5.6 ~ The host machine is a 13″ macbook with 2GB ram.


solaris_vm

When initially creating a new virtual machine for Solaris 10 the default memory size is set to 580Mb.   At  this setting the install  either hangs or progresses so slowly that it might as well be hanged.  Increasing the memory to 1024Mb solves this problem and the install progresses and enters the graphical (X-windows) install for OpenSolaris.

Getting past the memory issue, the install continues but eventually fails due to lack of disk space.  The failure does not show up until  all questions have been answered from within the graphical install portion and the installer attempts to partition the provided disk space.  The default hard drive size is set to 8GB.  Setting this to 12GB does not prevent the failure of the installation.  Pre-allocating the disk space as a single file (not broken into 2GB chunks) was also ineffective; the installation still failed due to lack of disk space.  The install fails and the diagnostics appear to show that there was little to no disk space available.  This can be circumvented by manually partitioning the disk space.

Once the install process has reached the graphical portion, I was able to open a new terminal window and used the ‘fdisk’ command to create a new disk label (using solaris defaults) for the disk space provided within VMWare.  Once the disk was labeled and written, the install procedure was able to identify the disk space correctly and the install continued to completion.