Nick Parker
My ramblings on .NET...

Vim + Firefox = Vimperator

Monday, 30 June 2008 20:39 by nickp

Okay, so I've lamented about how I enjoy using Vim/gVim several times now. If you are still using notepad.exe as your text editor I strongly advise you to check out some of the other editors out on the market. Vim and Emacs tend to be near the top of the list, are full of features and are both extensible. The bottom line is that you need to find an editor, learn it and use it - it's that simple. In fact Dave Thomas and Andy Hunt discuss this in The Pragmatic Programmer. So, while I enjoy using the keystrokes within Vim to navigate text, what about web browsing - we all do that quite a bit these days? The mouse is the obvious choice, however it is not my only option. Enter Vimperator, suggested by Zed, a Firefox addin that allow your browser to act like Vim.

A quick introduction, once you have it installed I like to turn a few things back on so that it still feels like a normal web browser for the times when I actually do want to use my mouse. Like Vim, Vimperator is configurable through a file you can create titled "_vimperatorrc" which needs to be stored within your %userprofile% directory. This file allows you to customize the way Vimperator integrates with Firefox, etc. Below I have included the contents of my _vimperatorrc file to get you started.

"Turn the menu and toolbar on.
:set guioptions+=mT

"Turn off the show tabs by default.
:set showtabline=1

"Turn session tracking off.
:set! browser.startup.page=1

"Allow user to click in address bar.
:set! browser.urlbar.clickSelectsAll=true
:set! browser.urlbar.doubleClickSelectsAll=true

"Map Ctrl + n for new windows
:map <C-n> <C-v><C-n>

"Map Ctrl + t for new tabs
:map 
<C-t> :tabopen<Enter>

"Map paste operation normally.
:imap 
<C-v> <C-v>


After you create this file you will need to restart Firefox and then the settings with be loaded. Standard navigation include:

  • j - down one line.
  • k - up one line.
  • o - open URL.
  • shift + h - navigate back 1 step in browser history.
  • shift + l - navigate forward 1 step in browser history.
  • f [number] - opens a link based on the number displayed on screen.
  • shift + f [number] - opens a link based on the number displayed on the screen (new tab).
  • gg - go to top of page.
  • shift + g - go to bottom of page.
  • ctrl + f - navigate down one screen length.
  • ctrl + b - navigate up one screen length.
  • b [number] - switches to the buffer (tab) based on the number supplied.
  • /[word] - search for [word], n goes to the next occurance, shift + n to the previous occurance.
If you want to read about the other options you can hit F1 or type :help.  You can grab a nightly build here.  One thing I didn't like about the default configuration within Vimperator was that it would track your session, so when you would close your browser, the next time you open Firefox, the site you were on was reloaded.  There are keyboard commands that will not save your session (i.e., ZQ), however there are many times I will simply close the Firefox window by mouse (old habits die hard).  Above in my configuration file I have turned off the session tracking.  I have found my web navigation experience has increased dramatically with this, and my reliance on the mouse continues to decrease.  Let me know if you decide to give it a try, it will defintely be worth your time.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Vim
Actions:   E-mail | del.icio.us | Permalink | Comments (1) | Comment RSSRSS comment feed

Vim Tip of the Day - File Explorer Navigation

Monday, 5 May 2008 21:17 by nickp

I don't know how I didn't come across this before, but when using the file explorer built into Vim, you can tell Vim to automatically switch the working directory to the current file you are editing.  Normally in Vim if you performed a ":cd c:\projects\blah" and subsequently navigated three folders deeper to edit a file (say “c:\projects\blah\foo\bar\foobar\fun.cs”), then choose to go back into the file explorer from your current location by issuing ":e .", the "c:\projects\blah" will be listed, not exactly where you might expect to be.  If you edit your _vimrc file and put the following command in when navigating the file explorer window, your current directory will automatically be set based on the file you are editing, and thus we would be dropped back into "c:\projects\blah\foo\bar\foobar").

autocmd BufEnter * lcd %:p:h 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   General | Open Source | Vim
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

TextMate for Windows

Sunday, 13 May 2007 11:25 by nickp

TextMate appears to be the de facto text editor for the Mac, it became extremely popular with the RoR crowd and has continued to grow. I had posted about Intype at the beginning of the year as it looked promising with it's template expansion support, however not much has happened with the product since then. I just came across E, a text editor for Windows that fully supports the bundle and command integration from TextMate. I really enjoy Vim, and I am used to the keyboard binds so this might be difficult to switch to, I'm going to give it a try, I already love the Go to File option (Shift + Ctrl - T).

Currently rated 1.3 by 3 people

  • Currently 1.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Software | Vim
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Vim Commands

Friday, 13 April 2007 08:58 by nickp

The other day I mentioned there are a ton of keyboard commands within Vim. This can initially make usage difficult if you're not familiar with the bindings. I've put together a simple sheet of basic commands you can find here. If you know of a good command that you think belongs on this sheet let me know and I will add it.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Open Source | Vim
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Choosing a Text Editor

Tuesday, 10 April 2007 21:08 by nickp

By and large I live in Visual Studio day in and day out. I picked up a copy of the Pragmatic Programmer back in 2000 and I continue to re-read it every so often, it’s a treasure trove of great information, I highly recommend it if you haven’t read through it before. One of the points Dave Thomas and Andy Hunt make in the book is to pick a text editor and know it well. The goal here is being proficient and learning the keyboard binding that your text editor provides can further improve your daily efficiency. Think how often any given day you are reading through code in one form or another. Notepad is not an acceptable option here, period.

Jeremy Miller and Jean-Paul Boodhoo have discussed switching from mouse driven work to the keyboard in attempt to gain efficiencies. Using the mouse simply slows you up.

Over the years I have looked at a lot of different editors, trying to weigh out their various features they provide, for a long time I was a fan of SciTe. However, time and time again I keep finding my way back to Vim (Vi Improved). Vim and the GVim (graphical) counterpart provide a tremendous amount of keyboard bindings; in fact, there is even a separate command mode for specific keyboard shortcuts (a lot of keyboard shortcuts too!). By keeping my hands on the keyboard I’m not wasting short cycles of time moving back and forth from the keyboard and mouse every so often. I remember using Vi back in college, and I never got comfortable with Emacs – entirely a personal preference although this has been a heated debate for several decades. I said earlier that Notepad is not an acceptable tool, as an example Vim and GVim will provide a type of intellisense through a simple <Ctrl> N keystroke. In fact, Bram Moolenaar, the author behind Vim has created a video titled 7 Habits For Effective Text Editing 2.0.

So now I can edit various files with this powerful text editor, but of course what about my IDE, which is what I said I spend most of my time in throughout the day. What about my email, the time I spend in Word, or SQL Server, this of course is normally where a breakdown occurs, in a sense. We tend to learn new keyboard bindings to do different things in different applications. Enter NGEDIT Software; they have produced Vim emulation within Visual Studio, Outlook, Word, and SQL Server Management Studio. Now my keyboard binding can be the same across the majority of applications I am in! If you have a Gmail account, you will note that Google provides the standard keyboard navigation through the use of the j and k keystrokes, which is rooted in Vim. Vim uses the / key to begin a search within an open document, Firefox supports this as well. The more consistent I keep my keyboard environment across the applications I use the faster I am. What editor do you use? Here is a nice Vim cheat sheet if you're looking for a new text editor to try.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Open Source | Software | Vim
Actions:   E-mail | del.icio.us | Permalink | Comments (1) | Comment RSSRSS comment feed