Apr 20 2009

How ViEmu failed to win my heart

Category: zvolkov @ 17:38

Alright, before making decision I actually did some evaluation of ViEmu in context of my typical code editing patterns. As you see from the title the result was negative.

Before I begin trolling Vi let's review my normal editing habits (w/o ViEmu)

I use left Shift and Ctrl exclusively, with my left thumb usually not far from left Ctrl and my left ring finger near left Shift.

I use numeric keyboard for navigation. I know most people have NumLock On most of the time which I find totally wrong! Numeric keyboard is much better than "normal" arrow keys as it gives you more convenient access to Home and End with your index finger, Insert with you thumb, Delete with ring finger and Enter with your pinky while still keeping PgUp/PgDn at your ring finger's reach.

If I happen to work with bigger document and I still have my hand on the mouse after opening new file from Solution Explorer I use the mouse to quickly get where I need to be, otherwise I just Page, Home/End and Ctrl+Arrow to make my way to the place of attention. Once I'm there I either End-Enter (using numeric keypad) to add a new line or I edit the current line with Ctrl+Shift+Arrows/Home/End followed by Ctrl+Ins, Shift+Ins and Shift+Del for clipboard operations and Ctrl+Z for Undo.

Sometimes, but not often, I scroll with Ctrl+Up/Down just to keep my working area in the middle of the screen without interrupting the edit burst. I also do Home-Ctrl+Shift+End followed by Ctrl+Left if I want to cut a sequence of words ending closer to the end of the line.

These plus an occasional Alt+Enter to apply Resharper's suggestion is how I spend most of my (non-typing) editing time. Perhaps you should also know that I'm not a touch-typist. I do blind type but I only use index and middle fingers, plus pinkies for left Shift and Return.

This should make it very clear why I found ViEmu pretty pointless even after I memorized most of commands. Indeed, to draw Vi parallels to my editing habits, the most useful commands would be:

  • Ctrl+F/B to page -- extra Ctrl
  • j and k to move down and up
  • w and b to quickly move sidewise -- less Ctrl -- (using an occasional W or B to skip to the next space -- extra Shift)
  • x and X to delete
  • vwww....w or vbbbb.....b followed by y, c or shift+P to copy, cut or replace a sequence of words -- less Ctrl+Shift to begin but extra Shift to Paste before cursor
  • u to Undo -- less Ctrl
  • o to add new line -- less End
  • zz to center the screen on the current line -- much faster as this gets me centered in N(0) time regardless of how far I am from the center
  • cc to cut entire line - much faster than Home-Ctrl+Shift+End-Del sequence I sometimes use

Of these only the nice-to-have zz and not-so-frequently-used cc are much faster and most others only eliminate a single Ctrl press, while still requiring me to press Esc to return to the Command mode after each edit. Now these saved Controls don't actually save much since as I said I'm not a touch typist so my hands still need to move significant distance to press all these Js, Ks and Us.

Truth be told, there are many unique commands in Vi that don't have "normal" counterparts but I just don't see a need to use them as often as Vi zealots seem to suggest I'm supposed to. Let's see.

  • cib - cut (text + text = text)
  • ci" - cut "text, text; and text!"
  • cW - cut to next space
  • f( - move to next (
  • % - move to the matching bracket
  • * - move to next occurance of this word
  • . - repeat last edit sequence

These are nice but arguably not worth the effort, especially in comparison with following Resharper shortcuts:

  • Ctrl+W - expand selection
  • Alt+Up/Down - go to next/previous method
  • Ctrl+Shift+Alt+Up/Down - move current block up or down
  • Ctrl+] - go to matching bracket
  • Ctrl+Shift+F7 to highlight all usages of current identifier followed by Ctrl+Alt+Up/Down to jump the usages
  • Ctrl+B - go to declaration

Note that most useful of these are semantic movements. I.e. they rely on background compilation of the text being edited as opposed to simple pattern match. This is not to mention Resharper's perfect refactorings like F2 to rename etc.

Don't know about you but I'm sold. Long live Resharper! Goodbye ViEmu!

 

Tags:

Comments

1.
David David says:

zvolkov, you've probably given up on Vim, but for anyone else, here's the Vim equivalent of the Resharper commands you gave:

I don't know what expand selection means.
[[ and ]] - go to next/previous method
V%xjp and V%xkP - move current block up or down (requires that you're on the opening or closing brace)
% - go to matching bracket
* and # - to highlight all usages of current identifier followed by n to jump the usages (searches for word under cursor and n/N go to next/previous)
Ctrl+] - go to declaration

Part of the power of Vim (including ViEmu) is that you can change the key mappings. V%xjp and V%xkP are pretty awkward, so you could use the following to map moving a block up and down to be the same as Resharper:
nmap <a-n-c-down> V%xjp
nmap <a-s-c-up> V%xkP

Put that in your _vimrc (for Vim) or _viemurc file (in the installation dir for ViEmu) and you have it always.


I do concede that there is great benefit to having semantic vs syntactic movements.



Oh, and Ctrl+] (go to matching bracket) is a VisualStudio feature, not ReSharper.

2.
zvolkov zvolkov says:

David, it's actually called Extend Selection, here's how it looks: www.jetbrains.com/.../extendSelection.html

3.
Joe Joe says:

Nice blog.. really like it..

4.
sotto sotto says:

reading your blogpost, it seems like you've invested some time in Vi and turned away from it, but you didn't mention its macro possibilities, and built in regexp features... both very powerful!

5.
cg cg says:

Another big advantage of vim/viemu is the portability. You've already invested time in learning resharper shortcuts, but you can't use them outside visual studio. The same shortcuts I memorised for viemu help me in the sql managment studio (viemu sql). Instead of notepad, i use gvim for all my general, quick and dirty text editing and again, I fly through it with the shortcuts. I dabble in linux once in a while and again, its great to fire up gvim and slice and dice text. A few months ago, a collegue of mine had to ssh into a remote system to maintain something and was very uncomfortable navigating it. We ended up needing to change a few configuration files and even in the console, i did vi xxx and was slicing and dicing text like there is no tommorrow. I was searching, changing and manipulating the configuration files faster in the console window than he could ever have done with visual studio or any non modal editor.

There are vi emulators for outlook, word, basically anything you can think of. And another 30 years from now, assuming you are manipulating english text with a keyboard, you will be able to find a vim emulator and use all your keybindings . Resharper works in such a narrow field.

Basically, vim will be a huge force multiplier that will provide enormous returns on your investment over a staggeringly long periods of time. Minority report's futuristic manipulations aside, most people believe that as far as programming is concerned, 30 years from now, you will still be coding in english language with a keyboard.

6.
zvolkov zvolkov says:

cg, very good points!

7.
trackback Yesterday's news says:

Learning ViEmu, part 3

Learning ViEmu, part 3

Comments are closed