Vim tips of the day

I’m using Vim text editor for more than decade now.  And I still can’t say I really know Vim.  I’m used to it and my fingers remember the commands.  And for those commands that I don’t remember, I’ve found some way of working around and got used to it too.  Today I came across not one, but two tips that I’m adding to my arsenal of Vim tricks.

Re-selecting visual block

Usually I only need to select the block once.  I then process it and never get back to it.  But sometimes, I need to select the same section of the text a few moments later.  Until today I was simply switching to visual selection and marking the block again.  Not too much of a problem, but it would be nice to have a shortcut for re-selecting the previous selection.  Of course, there is such a shortcut in Vim.  I just didn’t know it.  Simply type ‘gv‘ (without quotes) while in normal mode and your last visual selection will be selected again.

Increasing line limit on cross-file copying

There is no limit to number of lines copied between files, if all files are being edited in the same instance of Vim.  However if you copy a large selection from one file, then quit Vim, then open another file, and paste, you’ll probably see that only the first 50 lines or so were copied and the rest was lost.  Again this is not such a frequent scenario for me, and when it was happening I was simply opening both files in the same instance of Vim and copy all that I needed.  It turns out, I don’t really have to do that.

Vim uses ~/.viminfo file (default location) to remember things like command history, file marks, and registers between Vim instances.  There is a way to configure what and how much of what is going into this file.  If you are annoyed by any limits, you can easily raise them or totally remove them.  Have a look at “:help ‘viminfo’” manual page to see what is possible.   Adding “set viminfo=’100,<1000,s100” to ~/.vimrc file solved my problem.

 

P.S.: my messy Vim configuration files are available from GitHub, in case you wanted to take a pick at what else I have there.

Day in brief

Firefox 4 is awesome!

If you’ve been reading this blog for a while, you know that I switched my default browser a few times already.  I went from Mozilla Firefox and Opera to Google Chrome and back a few times.  Recently, I’ve been very satisfied with Google Chrome.  The main advantage of it is that its super fast.  And the initial downside – extensions – got way better now.  There is pretty much any extension that I need.  Some extensions still have a bit of Firefox catching up to do, but overall, I’m covered.

Recently, Firefox 4 was released.  There has been quite a few improvements, especially in the area that concerned me the most – performance.  Firefox 4 is blazing fast.  Not as fast as Google Chrome, but pretty close.  But.  It also has a few things that I wanted for a long time and that Google Chrome doesn’t have yet.  Here are the two features that were a deciding factor for me to switch back to Firefox as my primary browser for the time being:

  1. Tab groups.
  2. Browser sync with support of the Android.

Tab groups is a feature I wanted for a really long time.  In fact, I’ve blogged about it back in October of 2007!  I was using hundreds of open tabs back than and not having groups was a real pain.  Now I am much more moderate with my tabs, but groups still make a lot of sense.  Have a look at the screenshot below.

With just a couple of clicks I can now group related tabs into groups.  When I switch between groups, in the list of tabs I see only the tabs open within the current group.  This saves plenty of time and confusion.  Also it makes keeping track of open tabs much easier.  Tabs can be dragged from one group to another group.  Groups can be renamed, rearranged, resized, and so on.  When I’m done with the task, I can close either a single tab or a whole group.  And I can even undo the closing operation on both.  Now that is the tool to boost productivity!

The new Firefox 4 also has the browser synchronization functionality, with which one can sync several computers and (now) even mobile devices.  You can choose what to synchronize and where. Bookmarks, history, passwords, form data, and even open tabs are supported! And this solves yet another problem for me.  I’ve been looking for an elegant solution to send URLs from my desktop to the mobile and back.  It’s a problem that I have on a daily basis.  And now it’s solved!  I simply installed Firefox 4 for Android on my mobile, enabled browser synchronization, and that was it.

With these new features in, and much improved performance, I don’t see any reason for why I shouldn’t switch to Firefox 4.  So that is exactly what I am doing starting today.

On a separate note, I have to once again highlight how important are competition and open standards.  Competition brings in the cutting edge technology and much improved end user experience. Open standards allow for simple switch between different implementations.  Kudos to all the open source developers, participating companies, and anyone else involved.  Keep it up guys!

Terminator in PHP

I’ve mentioned a few times in this blog that one particular bit I love about open source software is humor in documentation.  While most commercial applications stick to a strict, official language in their manuals, open source developers often expose their humane side with jokes, references to movies, television shows and so on.

Today I came across yet another example of that.  Not strictly in a software manual, but close enough.  Here is a partial screenshot of a comment on PHP.net website, page about get_object_vars() function.

A well places Terminator references – how cool is that!