The vi input model
I don’t want to start a flame war. I don’t want to advocate anything over to anyone. I’m just going to tell a little tale pertaining to my use of text editors.
About 6-8 months ago, I started doing most of my work on a laptop. I hadn’t used a laptop extensively, and I felt quite happy editing with UltraEdit (my editor of choice for years) or the built-in editor of Microsoft Visual Studio. Using VS to edit gives you Intellisense (a tooltip-box showing you the prototype of the function whose name you’ve just typed), a quick type-compile-correct cycle, and no time to start debugging.
You see, these laptops we have are nifty and all. Plenty of horsepower, decent screens, and you can use them on top of your lap at the sofa. There are only two quirks to me: one is that, if you add a mouse, you need a surface, which usually means a table, and a lot of the mobility is lost. The bag also starts to become bulky. The second quirk is that arrow keys, and even worse navigation keys (Home/End/PgUp/PgDn), seem to be an afterthought.
For the past ten years, I’ve never even thought that I was moving the hand across the keyboard to reach all these magic little keys hundreds if not thousands of times a day, and performing all sorts of selection/copying/pasting/navigation quickly. A common idiom: selecting the current line completely, and pasting a copy below it. I used to do that by pressing Home twice (as the first one gets you to the first non-blank character in the line and I want the whole line), then pressing Shift and holding it depressed while pressing the down arrow, then Ctrl-C, and then Ctrl-V twice (either that or Down-Arrow then Ctrl-V).
It’s more or less that. I must have made this action more times than I’ve said “hi”.
Now comes the wonderful world of laptop editing. There are many small variations of the laptop keyboard torture devised by different incarnations of Evil. Mine is an Acer with Del on the top-right corner (a good choice), Ins just left to it, the arrows in a nice little inverted T on the bottom right (not incredibly easy to find by touch, you see, I am a quite proficient touch typist as most people who spend a lot of their day typing).
The worst comes with the Home-End and PgUp/PgDn keys. PgUp and PgDn are dutifully struck there on the two little gaps of the inverted T – PgUp is above the left arrow, and PgDn is above the right arrow. This alone makes you unable to distinguish the inverted T shape by touch, which is such an aid for quickly locating it. And the mental cue of having PgUp above PgDn is lost. But the worst is yet to come: Home and End are the same two keys, as long as you press a difficult to press “Fn” key almost on the bottom left corner on the keyboard (second from the left, between the Ctrl and the Windows key).
This layout is incredibly uncomfortable. Such a simple idiom as I spoke about above turns into something like this:
– Move the hand around the bottom right corner trying to locate the keys
– Give up trying blindly and look down to locate them
– Try to locate Fn directly with the left thumb or little finger
– Give up and locate it either as the second key on the row or just look down
– Fn-PgUp (Home) twice
– Shift-Down, usually by touch from the previous position but w/o feeling reliable
– Ctrl-C (with which you lose track of where your left keys are)
– Ctrl-V twice
– Swear about these damn keyboards and try to remember what you were trying to write.
You see, a few days of this and I was bound to find a better solution.
I started thinking that there must be a way to edit text which didn’t require the Home/End/Arrow keys. I started dreaming up about text editing interfaces that would save all the hand movement. During one of those daydreams, it struck me: “remember vi, that old-school, bizarre, complex, text-editor?”. I had used vi (most probably vim) maybe a couple of times, once at the University HP-9000 Unix system and another time when installing Linux circa 1994. I promptly switched to “pico” or “joe” or one of the other more standard editors and forgot about it – not without learning that “i” helped you enter text (?!) and quitting required typing ‘:’ and then q or quit or e or exit or x or whatnot. The only way to add text to a line would be to use ‘a’ instead of ‘i’ while at the end of line, really weird But I had sometime heard that you DID NOT USE ARROW KEYS WITH VI. It resounded as a syren song in my mind. I commented it with a coworker, quite a Linux supporter, and he praised the vi input model really strong – no, he wasn’t using it most of the time having succumbed to development under Windows using plain Microsoft Visual Studio, but it was the best way of editing text known to man.
You see, I was perfectly happy with my editor(s), but suddenly the input model was a pain to use with my environment.
I looked up some resources, downloaded vim, and I started using it. First web page I printed out and kept at arm’s length for emergency:
Efficient Editing With vim – Jonathan McPherson
This is the best introduction to the vi input model I have found. First thing it does is tell you to stay away from the arrow keys and use h,j,k,l for moving around. Sure its weird, and I probably couldn’t have done it on a regular keyboard, but the laptop nightmare got me avoiding the arrow keys by sheer instinct.
It felt weird to have your hands stuck there in their home position. It felt even a bit “restrictive”, and things didn’t come out quick. It took about 2 weeks to become basically fluent with the vi model, and I was playing games of what commands to use for every little thing (“How do I erase this word? Oh, it may be, what key was it? ah, yeah, ‘b’, to go to the beginning of the word, then ‘d’ to delete and maybe ‘w’ to delete to the next word HURRAH! IT WORKED!” – then “diw – Delete Inner Word does it as well!”).
But after the steeeeeeeep learning curve, I started to become very proficient with it. You could split, resize and move around editing windows with just keyboard commands (“you mean, ‘k’ is up, but Ctrl-W and then ‘k’ gets you to the window above the current one? NEAT!”). Everything is there at your finger tips.
So – there I was, early 2005, discovering the input model of a text editor written, what, 25 years ago?, and finding out that it is the best input model for my current platform.
Mind you, once I’ve learnt it, it’s also much quicker to use on a regular keyboard – the incentive just wasn’t there with a fancy regular keyboard.
Now editing is no less comfortable at the sofa, on the plane or bus, than on a non-portable full size desk.
And do you know how I make an additional copy of the current line nowadays?
yyp
[Update May 31, 2006: if you want to learn vi/vim editing yourself, I think the best way to do it is the graphical tutorial I prepared recently. Enjoy!]
June 3rd, 2005 at 2:58 pm
Very true. I find the most useful thing is being able to specify ranges over which to perform regexp’s to be a real killer. It’s not that I cannot do it in Ultraedit or other editors, I just find it a lot easier to do.
If it wasn’t for that steep learning curve…
June 3rd, 2005 at 3:36 pm
I don’t use regexp’s so often. Once in a while, but most days I don’t even type in a single regular expression. It’s the input model of the editor that bought me. vi without regexp’s would still be a winner for me.
Yeah, the learning curve is steep – less than I foresaw, but steep nonetheless. And I understand it’s not for everyone. I usually prefer not to drift off too much myself, but it made all sense for me.
June 3rd, 2005 at 4:49 pm
[…] really that nice? In my morning search of interesting sites I found a link to a blog entry that details why the vi editor input model is better than others. I found it fascinating to find a well […]
October 13th, 2005 at 4:34 pm
As with most vi commands, your example of copying and pasting a line:
yyp
Can be simplified to two keystrokes:
Yp
In reading your article, I learned a new and useful one myself: diw
Thanks!
October 13th, 2005 at 7:00 pm
Thanks Terry… my brain tends to forget about Y as it is not “regular” with D and C.
If you liked “diw”, and not sure if you know them or not, but you’ll love “>iB”, “>ip”, and “ci)” – and they’re repeatable with ‘.’ without loss of generality.
It seems vim 7 adds more of these “text block” selectors.
November 28th, 2005 at 8:04 pm
In fairness, you can duplicate a line in Visual Studio with
^C^V
And if you have ReSharper, you can do
^D
But I still agree with the positive comments about vi. I wrote my own version many years ago, and I was still coming up with new ways to use it six months later!
November 29th, 2005 at 2:15 am
Mark, I went and checked it – and sure you’re right! ^C with no selection copies the line. Thanks for the tip.
And… you wrote a version of it yourself? What was of it? I piques my curiosity – I guess there are not that many people that have implemented vi (although sure a few).
BTW, I recently used emacs a bit for some lisp tinkering, and after trying it “raw” for a while, I had to go M-x viper-mode 🙂
December 1st, 2005 at 1:48 am
It took me several years to learn that ^C without a selection copies a line in VS. I think in VS 6 that you had to turn this capability on in the options dialog.
My version of vi was somewhat stripped down, so I called it v. But it was a nice little 48K program. What was cool was when I started bootstrapping — using it to write itself (as I imagine you’re doing).
I really, really tried to like emacs, but I never did learn to love it.
December 1st, 2005 at 4:23 pm
I’ve used Visual C++ since 1.0 (yes, Win16) and I didn’t know until you told me. !
I’m using ViEmu all the time to work on itself, and I’ve also used NGEDIT as an external text editor “to develop itself”, alt tabbing back and forth with VS. The NGEDIT part is messier, as I edit, save the code, alt tab to VS, issue the “Build” command, and then get puzzled when the linker refuses to write on top the the running EXE. Duh 🙂
Your ‘v’ program sounds really cool.
Emacs is good as viper-mode is included. Plus a lisp based system is really “beautiful” in the geeky sense.
December 1st, 2005 at 9:58 pm
I never considered using emacs in viper-mode. That sounds like a really good idea, since you get the programmability.
BTW, I just started using your ViEmu, and I really like it–nice job! The problem is in having to bop back and forth between different editing methods, even within VS itself. But I’m going to soldier on and give it my best shot.
What’s funny is how your fingers remember vi, even after a 15 year absence. I literally couldn’t remember the command to move to the end of the line, but my fingers did. 🙂
December 1st, 2005 at 10:03 pm
Speaking of your fingers remembering what your brain forgot, did you know that Control+[ is equivalent to Esc? I used v for quite a while before I discovered that.
December 1st, 2005 at 11:53 pm
Mark,
I wanted to try my hand at some lisp development, and I also wanted to learn emacs for the development of my current project (a text editor) – but I can not get my fingers to press Ctrl- or Alt- for every single thing any more. I ended up using viper to do the lisp hacking.
Thanks a lot for the compliments on ViEmu!
Where do you find yourself going back and forth? Maybe for the project window / immediate mode window?
The thing of the fingers remembering – I play the piano a bit (not too much, but still quite a bit) – and it also happens there. There is a mechanical memory that simply can’t be recalled by evoking it, but it comes easily when the fingers get their place. I guess it also plays an important role when touch typing.
I researched on keyboard messages in too much detail a few months ago and I tried the ^[ stuff, it works in all “dumb” windows programs. But I have been unable to train myself to – on a desktop system it’s great, but on my laptop control is not confortable either.
I wonder when will laptop manufacturers actually *think* their keyboard layouts. They’re so bad it’s sick. I guess apple will be first.
Thanks for your comments!
December 2nd, 2005 at 12:01 am
> Where do you find yourself going back and forth? Maybe for the project > window / immediate mode window?
That’s it, exactly.
December 2nd, 2005 at 12:11 am
Ok – hooking the project window seemed a bit dangerous and difficult to make work well. On the other hand, the immediate mode window was hooked up to ViEmu 1.3, and it was much, much worse than not emulating vi/vim there – I just got around to removing it for ViEmu 1.4.
I’ll give it some more thought though.
March 29th, 2006 at 4:03 pm
VIM has some killer features that made me ditch Visual Studio’s editor and use the Windows version of vim back when I was developing Windows apps.
Ctrl-N and Ctrl-P in insert mode start keyword completion. Vim looks for a word starting with the prefix you typed in the current file, in all other open files, in #include’d files and in a TAGS file (if you built one with ctags). It then expands your prefix with the closest matching keyword. If you want another one, keep pressing Ctrl+N/Ctrl-P. It is not a direct replacement for IntelliSense, but it always worked much faster for me.
Tags — if you build a TAGS file for the project you’re working on (exuberant ctags, distributed with vim, does that), you can jump to the definiton of any class/function/variable by walking to a name and pressing Ctrl+]. Or you can do that from the ex command line with :tag SomeName.
March 29th, 2006 at 4:16 pm
Marius, you’re darn right on all facts.
I wanted to have the best of both worlds together (vim editing + VS’s project environment & debugging), so I developed ViEmu.
As of 1.4, ViEmu supports the features you mention with their equivalent in the VS environment: Ctrl-] uses VS’s “Go to Definition”, while Ctrl-N/Ctrl-P invoke Intellisense autocompletion. Plans are to implement proper Ctrl-N/Ctrl-P filescan-autocompletion in the future, leaving Ctrl-Space for Intellisense autocompletion.
April 5th, 2006 at 4:06 pm
I just recently started out with [g]vi[m] on linux. I found me way here twice via links to the vi cheat sheet… (that is what reawakened my interest for vi 😉 )
it seams very unusual, but as a former emacs zealot, I’ used to wierd key combinations and vi is a surprisingly nice break from Control (C-x C-s C-x C-c becomes :wq , C-k C-y C-y becomes Yp, C-n (or arrow down) becomes j, printf( C-y becomes iprintf(p *damn that insert mode* ESC X p)
Haven’t use Visual Studio for ages… I sometimes miss IntelliSence – but it doesn’t support linux or python yet, does it ?
April 5th, 2006 at 4:22 pm
Hey TJ, glad it reawakened your interest. I’ve found vi/vim very interesting & powerful – not only the input model, but :s/:g are my friends now when I want to generate a simple html page from a text-only list or so.
Funnily, I’m starting to learn a bit of emacs now – in order to complete my “cultural background”, in order to implement some emulation for my text editor, and for my lisp hacking adventures. I prefer vi input, available in emacs with M-x viper-mode, but it doesn’t fulfill the other needs.
I think the latest version of the Visual Studio SDK brings “IronPython”, which supports syntax highlighting, intellisense, and compiling it to .NET. But I might be mistaken, be sure to check it yourself. Of course, no linux support!
October 19th, 2006 at 8:40 pm
About keyboard layout: have you tried to map Escape to CapsLock key ? This solution works pretty well for me.
I think that Yp is not simplified yyp:
Shift+y,p = 3 keystrokes & y,y,p = 3 keystrokes
October 25th, 2006 at 2:34 am
I haven’t tried to remap caps lock, I think I nowadays I use either Esc or Ctrl-[ depending on the situation, but it’s pretty much unconscious.
As for ‘keystroke number’, you are right, but Yp looks like a two-char sequence, thus simpler. But I still use yyp anyway, and it also is closer from home row position.
December 17th, 2006 at 5:17 am
I remap esc to jk .. works great for me… right on the home row, and it’s a key combination that basically never gets used.
December 18th, 2006 at 12:08 pm
Don, I had heard about people mapping it to jj too. I might try it sometime in the future – since I’m using ViEmu most of the time, and since it doesn’t support multiple-key-chord mappings yet, it’s not an option now, but it will be in one of next few releases, so it could be a great idea. Best regards and happy holidays!
January 6th, 2007 at 1:46 am
Remapping escape! How could I not have thought of that. The number of times I hit that key… Great suggestion, thanks!
January 6th, 2007 at 3:17 am
I just use ctrl-] for escape, since that’s what it already is under Unix. I also use ctrl-h for backspace for the same reason. Talk about never having to leave the home row!
January 6th, 2007 at 3:18 am
Oops, I mean ctrl-[.
January 6th, 2007 at 3:51 am
Wow Jon, front page on Reddit. Good work! Now I want to learn vi. I know exactly what you’re talking about with the laptop development. I took my laptop on a one week trip and it was horrible for coding.
January 6th, 2007 at 4:29 am
Anonymous, I still use a few control keys, for example Ctrl-R for redo, but many fewer than in any previous editor I’ve used. I use Ctrl-[ some times, but also the Escape key – I think it helps me rest a bit. 100% home row can be too much!
Tim, thanks for that. I’ll drop you a line… I hope your project is chugging along fine.
Thanks everyone!
Jon
January 6th, 2007 at 7:20 am
There are a few laptops with normal keyboards. You gotta choose carefully:
http://www.notebookreview.com/assets/11088.jpg
http://www.notebookreview.com/assets/2792.jpg
January 6th, 2007 at 9:08 am
Vi sucks for dvorak, though. h j k l are randomly all over the place.
Then again, when I was trying to learn vi while still on qwerty, I was constantly annoyed by the whole having to shift your right hand one to the left when you’re on the home row. That’s just silly.
January 6th, 2007 at 9:11 am
Try doing text editing after sshing to a box over a modern satellite connection (where the one way latency is about 1 second) without vi. Yes, vi is still as relevant today as it was in years past.
January 6th, 2007 at 3:31 pm
Satisfied Customer: I wasn’t aware of the fact initially. Plus, you need a big laptop for that. All in all, I’m happy nowadays that I can do powerful editing just with the regular, alphanumeric keyboard. It will be great the day I migrate to MacOSX!
anonymous: some vi+dvorak users map hjkl to the equivalent-position keys in dvorak. But, in any case, one little known secret is that you hardly ever use h and l if you use vi/vim properly, there are *always* faster ways to get where you want. So jk are right there under the index and middle finger, and all is fine and dandy.
Tom, that must be a pain in any case 🙂
January 6th, 2007 at 8:47 pm
I absolutely love vim! Sure it has a steep learning curve, but it is my editor of choice. Once you learn the basics you can apply it to so much more. Add some nice plugins (like \c for commenting a line out) and it just feels right.
January 7th, 2007 at 4:38 am
Another alternative to remapping Esc to Caps is remaping Ctrl to Caps. This is assuming that Caps is right next to the A key, of course. This makes any Ctrl-key combinations boundlessly easier, esp. C-[. It’s also more universally beneficial than just Vi/Vim: few applications use Esc as often, but every application and its mother, and several of its children, use Ctrl. I’ve had it this way on my laptops/desktops, and it’s been making me happy for years.
The reason behind the existence of this option is a throwback to old Unix boxen (many Solaris keyboards are still this way).
Anyway, a great summary. I used Vi like a pleb for a long time, just hoping that it would get easier, and sucked very much at it. Then I decided to take my typing into my own hands, and the reward, like for you, was extensive. I just wish I’d seen your page then: it would have saved me a lot of hassle.
January 7th, 2007 at 5:00 am
For eclipse users here is the vi plugin.
http://www.satokar.com/viplugin/index.php
I tried its free trial version and was happy to pay for the license.
January 7th, 2007 at 5:05 am
MYW, I don’t remap, esp. since I’m accustomed to Ctrl on the bottom left on the desktop, where I can use the palm of my left hand to press it. It doesn’t work on a laptop, though, but since I mostly use vi(m) input and ctrl is much less used, I do ok. I know many old unix hackers always complain that capslock was put in the place where god planned control.
Jayesh, thanks for the link on behalf of those who use eclipse and didn’t know about it! It’s good that vi(m) is (almost) everywhere. I do miss it in firefox textareas, though!
January 7th, 2007 at 5:32 am
i just wish every program has a vi mode built in their editor
January 7th, 2007 at 5:33 am
[…] read more | digg story […]
January 7th, 2007 at 6:12 am
I use vi daily. Learned it using Aztec C68K on the Amiga.
FWIW: Yp is three keystrokes if you count the shift. 🙂
January 7th, 2007 at 6:13 am
vim
?????? ???????? ????????, ?????? ? ???? ????? ? ????????? “?????-?? ?????? ?????????? ???????? ?? Unix’?”, ???? ???? ??????? ? ????…
January 7th, 2007 at 7:10 am
[…] read more | digg story […]
January 7th, 2007 at 7:14 am
When I was good at vi circa 1986, friends called me viking (vi king). However, after Vim came out, I found that I kept learning new tricks every day. King no more.
January 7th, 2007 at 7:27 am
[…] “I don’t want to start a flame war. I don’t want to advocate anything over to anyone. I’m just going to tell a little tale pertaining to my use of text editors.” From The growing pains of NGEDIT » Blog Archive » The vi input model (via Digg) […]
January 7th, 2007 at 7:51 am
[…] http://blog.ngedit.com/2005/06/03/the-vi-input-model/ […]
January 7th, 2007 at 8:11 am
[…] read more | digg story […]
January 7th, 2007 at 9:18 am
Acutally if you’re in insert mode, you have to hit escape then Yp or yyp so its 4 chars. And I chord key are bad so they should count double.
And ctrl usually isn’t on the home row.
January 7th, 2007 at 10:21 am
[…] But after discovering this link, this one, and this one, I think it’s time I spend some time getting myself more efficient when using vi. […]
January 7th, 2007 at 1:05 pm
We need a graphical Vim wallpaper for Vim like this one for TextMate!!
http://www.wishingline.com/notebook/archives/2007_01.php#001122
January 7th, 2007 at 3:33 pm
“i just wish every program has a vi mode built in their editor”: I’ve got for Visual Studio and SQL Server, and about to release for Word and Outlook. Others have done it for Emacs, Eclipse and IDEA. Of course, vim is almost everywhere. There are not many more places missing! Firefox textareas anyone?
Doug: “Yp is three keystrokes if you count the shift”: true, I actually use yyp, but, in any case, the point above is just a sample. How about “>iB” to indent the current brace-delimited block? 3 or 4 keys get you almost everything.
Photar: the Esc keypress belongs logically to the previous command. It’s a common misconception, you should never *stay* in insert mode. Insert mode is for short bursts of typing, and then you press Esc. That’s why “Normal” is called “Normal”.
spankbot: have a look at the graphical cheat sheet and tutorial I prepared last year, pointed to from the bottom of the article, I think it should help!
January 7th, 2007 at 3:44 pm
If you learn the shortcuts and set up macros/tools in UltraEdit32 (or even TextPad) you’ll find it’s 100x faster and more powerful than VI, and doesn’t have the hideous obfuscated learning curve…
I know VI well as I had to use it for about two years, yet I still find a customised UE32 and TextPad far faster for most operations.
January 7th, 2007 at 3:52 pm
Andy, you must have been using vi wrong. I was a ultraedit user for many years, so I can compare them directly.
How do you indent the current brace-delimited block *and* the one enclosing this?
>2iB
How do you delete & copy to the clipboard the function call that starts in the current cursor pos, with its argument list?
d%
How do you re-auto-indent the current block (you’ve pasted from somewhere else and indentation is wrong)?
=aB
How do you delete the current word (no matter where in it the cursor is) *and* the next one?
d2aw
How do you replace every ‘peter’ by ‘john’ but only in lines where there is an ‘mary’?
:g/mary/s/peter/john/g
And I will stop, because the list is endless. Ultraedit does not even compare.
January 7th, 2007 at 4:56 pm
So – there I was, early 2005, discovering the input model of a text editor written, what, 25 years ago?
:s/25/30/
:wq
January 7th, 2007 at 5:16 pm
J, i have solutions everyone with ultraEdit with my macros, except for “:g/mary/s/peter/john/g”
that’s a vi killer still. Btw, i’m back to unix, so i don’t use uedit anymore. and don’t miss it.
January 7th, 2007 at 5:57 pm
I can’t believe that no one mentioned the command:
vimtutor
It launches an easy to follow and practical approach in VIM !
Recommended!
G.
January 7th, 2007 at 6:56 pm
i’m still not hooked on vim yet, EditPlus is pretty damn good, but i too learned vim when i bought my first laptop.
if you’re not using vim, remember you can cut to delete text rather than reaching for that delete key way up top. It’s an obvious trick, but helps a lot.
another trick for non-vim editors is that you can selected text with shift AND control. windows will selected word by word, so it’s faster than using shift+arrow alone. On a normal keyboard you’d probaby reach for the end key.
January 7th, 2007 at 7:22 pm
No one has mentioned this, but vim7 also has tabs in it. So you can edit multiple files without splitting now.
:tabnew
:tabnew browse
ctrl+pgup
ctrl+pgdown
January 7th, 2007 at 8:31 pm
Wow… so I’ve been using vim for years, but these comments have been an absolute treasure trove of new commands. >iB…. ah, I’m in love.
Thanks to all!
January 7th, 2007 at 9:50 pm
Gabriel: yes, 30 years ago – now I know. I thought it was *only* 25 back then 🙂 And everything can be done with all editors, but vi is specialized for text manipulation – the samples above are just that, samples.
Guzi, vimtutor is good, I ran that the first thing.
Anonymous, thanks for posting the extra tips. I still think that vi/vim is worth it. Even if I think programming will be done with a stylus in some time, there’s a few years to that yet.
unik, tabs are ok, but they are confusing to me together with buffers and windows. I may configure my vim to use those all the time.
And Jack, I’m glad you found out so many interesting tips. Here goes another great one: motion to find the next occurrence of the word under the cursor:
‘*’ (without the quotes)
‘#’ does the same backwards. A real godsend!
January 7th, 2007 at 10:49 pm
I am a long time vim user – and I love it. I think there are even Plugins for Firefox, that makes the text-editing in vim-style.
Interesting Tips – thanks to all.
One thin I use a lot is the . it will repeat the last action you did.
Btw – here: http://winadmin.forret.com/registry/wanocaps/ is an easy script for replacing your CapsLock with Ctrl.
January 8th, 2007 at 7:52 pm
[…] 2006 was vi’s 30th anniversary, but it’s still alive and kicking. Read about some of vi/vim’s power, and why it’s still as incredible as it ever was!read more | digg story […]
January 9th, 2007 at 1:16 am
[…] The story of why I got started with vi/vim editing […]
January 9th, 2007 at 2:26 am
Personally, I prefer VILE. I like its circular buffer (keep doing “:n”, and it comes back around to where you started).
Also, “__” bounces back to the previous file. Nice for reconciling between 2 files.
A “Ctrl-X 2” divides your edit space in half (you can do as many times as you have space). “V” makes the current half bigger, and “v” makes the current half smaller. Doing “:n” in the current half will put the next file in the current half.
I also like being able to make a bunch of changes to a bunch of files, and save them all out at the same time with a “:ww”.
If you’re fast with Vim, you can be faster with Vile. After using it for a week or two, you’ll likely understand why it is called “The Elegant Text Editor” by some:
http://drumlin.thehutt.org/vile/
Find out more at:
http://en.wikipedia.org/wiki/VILE
Nowadays, it is often an optional install on many Linux systems.
January 9th, 2007 at 3:45 am
J: “I’ve got [vi mode] for Visual Studio and SQL Server, and about to release for Word and Outlook.”
A-a-a-a! To have a VI mode in this megamonster they call Word – that would be SO cool! I love this! Please keep us posted (I’m not a regular reader, but I will tremendously appreciate a quick e-mail notification). Willing to be a beta tester.
Regards,
Lev
January 9th, 2007 at 4:26 am
Gary, I haven’t tried vile, but I’ll have a look at the links you post. all the things you mention can be done with vim, though, and it has this excelent ‘visual’ mode, where you visually select an area (‘v’, ‘V’ or ‘c-v’, depending if you want it charwise, linewise, or in a rectangular block – then move around with regular motions) and type an operator for direct editing (‘d’ for delete, etc… It seems vim is much more complete.
Lev, thanks for your kind comment. Check my latest blog post for a screenshot of ViEmu/Word:
http://blog.ngedit.com/2007/01/09/digg-reddit-vivim-for-word-and-outlook-and-happy-new-year/
I’ll get in touch with you for testing. Hopefully, really soon.
Regards,
Jon
January 9th, 2007 at 1:30 pm
[…] There have been a couple of interesting articles about vi recently. This essay describes why the vi input model is great for laptop keyboards. Also, The Register has a bit from Bill Joy on the origins of vi. […]
January 10th, 2007 at 7:23 pm
Regarding this:
How do you re-auto-indent the current block (you’ve pasted from somewhere else and indentation is wrong)?
=aB
When you paste, try using [p or ]p instead of p. They will paste the block the same way as as p but will match the indent to the previous or following line. There are also [P and ]P which correspond to P.
January 13th, 2007 at 3:25 pm
I am so glad that i use a text editor which is:
– so fast.
– found on every machine that i log in.
– makes life easier with its plugins(subversion, folding etc..)
– warns me with its text highlighting
– so customizable!
am so glad that i am using vim!
January 15th, 2007 at 11:57 pm
[…] The vi input model Reasons to learn vi/vim. Damn, i love my vi(m). (tags: vi vim programming editor tips reference linux hacks apps article) […]
January 30th, 2007 at 4:12 pm
[…] Why learning vi/vim still makes sense in 2007 (via reddit) Potentially related posts […]
February 11th, 2007 at 7:49 am
Finally! Just discovered ViEmu. I’ve been waiting for this for a long time. Thanks for the effort. Hope you make a few bucks with it.
Been using vi so long I don’t remember any learning curve. Glad to get it in VS.
Now if I can just figure out how to get VS2005 to open my .h’s on the left and .cpp’s on the right I’ll die happy. 🙂
February 11th, 2007 at 10:43 pm
Thanks Mike, I’m glad you like it. I will get back in touch with you by email to try to do something about the h/cpp thing (it’s difficult as far as I know).
March 25th, 2007 at 1:03 am
[…] vim is not the guy who approaches you with a smile and an outstretched hand. It’s the guy sitting in his cubicle consumed in his work and mumbling to himself. What originally got me interested in vim was not the strong endorsements from lots of people I had talked to it, it was actually this blog entry from a guy who’s selling vim integration plug ins for things like Visual Studio. There were two things about his text that resonated with me. First of all, if anyone is going to be looking for vim plug ins for probably the most popular IDE out there (ie. lots of people are already very happy with this IDE), there must be something pretty special about vim. And secondly, he loves vim because it’s ergonomic. Hah, ergonomic, imagine that! Have you ever tried editing away from your desk? It’s awful, you don’t know what to do with the mouse, the mousepad sucks, you can’t use the desktop normally, bleh. But he said vim works just as well on the train as it does on your desk. That got me thinking. […]
May 17th, 2007 at 10:36 pm
I was using SciTE, which I still recomend for anyone who isn’t a career coder. Fast, flexible, and I really liked the way I could map all sorts of custom functionality to hot-keys, but eventually I ran out of hotkeys 😉
This brought me to vim. The initial pain was well worth it, now I effectively have multiple keyboards of hot-keys AND I can chain them together.
May 19th, 2007 at 2:33 am
[…] The growing pains of NGEDIT » Blog Archive » The vi input model (tags: vi vim editor programming linux reference tips) […]
June 10th, 2007 at 7:13 pm
[…] http://blog.ngedit.com/2005/06/03/the-vi-input-model/ Tags: vi, vim, programming, editor, linux, tips, reference, keyboard(del.icio.us history) […]
July 10th, 2007 at 3:09 am
[…] So before I learned to use Vim (currently the editor I use for literally all editing tasks), I had a go at learning Emacs. But I could never get used to the strange choices for navigation keys (up, down, left and right are (using Emacs notation) C-p, C-n, C-b and C-f respectively, which are allegedly mnemonic, at least to English speakers, but certainly not ergonomic) or the fact that you have to stretch your pinkie to get to the Ctrl key to use them (this reliance on shift keys being the source of one of the jocular expansions of EMACS: “Esc Meta Alt Ctrl Shift”). When I got round to learning to use Vim, I found that using Vim was simply much more comfortable – up, down, left and right are k, j, h and l respectively, all on the home row (assuming a qwerty-ish keyboard – mine was UK qwerty at the time, now a German qwertz) and unshifted. […]
July 20th, 2007 at 3:41 am
Following up on my last post, I figured out how to get VS2005 to open my .Hs on the left and .CPPs on the right – I paid a few bucks to have a VSIP plugin written. And I’ve put it up on sourceforge http://codewinpos.sourceforge.net for the world to enjoy (or at least the few of us odd ones who’ll use it).
July 20th, 2007 at 3:43 am
Hey Mike, thanks for posting about it. I hope to incorporate similar functionality in future versions of ViEmu or Codekana.
August 11th, 2007 at 2:58 am
[…] Started learning to use VIM again on Monday. I just think I can get more done with it. I need to get better at it. So I’ve started trying to use it for all my basic text editing needs. Within one week of use, I’m getting pretty decent at using VIM. It seems like it encourages you to write text like a programmer, thinking about how to minimize steps as you take them. […]
October 2nd, 2007 at 2:00 pm
[…] read more | digg story […]
October 21st, 2007 at 1:18 am
Personally, I think vim is great in dvorak, without any sort of remapping. J and K are right underneath the home row, with my index and middle fingers. H and L accessed with the index finger and the pinky finger on the right hand, respectively, and B and W are the index and the middle finger on the right hand. There’s a sort of directional correlation between keys on the keyboard and the action they do – it sort of accidentally works out like that, even though vi was obviously designed with QWERTY keyboards in mind.
October 22nd, 2007 at 7:31 pm
Ed, thanks for the comment. I’m not going to try dvorak soon but it’s good to know that it can kind of make sense. I use that kind of tricks as often as possible, as they help in memorizing stuff, and it’s surprising how often there are these kinds of coincidental cues.
November 19th, 2007 at 4:08 am
http://addons.mozilla.org/firefox/4125
With It’s All Text! one is able to edit Firefox textareas in vim!
November 19th, 2007 at 12:31 pm
Hi torzsmokus, indeed, I have “It’s all text” installed – I tend not to use it though, as I don’t like losing the context of the web page. But thanks for pointing it out! – Jon
November 30th, 2007 at 4:10 am
I’ve had two revelations in my life as a professional nerd, and the first was vi[m]. I tried learning emacs multiple times both before and after vi but ultimately couldn’t justify it — my hands hurt and I was angry after each attempt.
The second revelation for the *nix command line folks out there (possibly Cygwin on Windows?), GNU screen and the similar ‘ratpoison’ WM for X11. They are similar to vi in an abstract way: ergonomics, no mouse or moving your hands from the home row, screen also has vi movement.
Between screen and vi[m] I can do almost anything faster and easier than my coworker counterparts, except those that also use vi[m][/screen] 🙂
Nice post and thanks to the many people with useful keystrokes, as a seasoned vi user I learned a lot of really useful stuff here.
December 10th, 2007 at 2:07 pm
Thanks Nat. I do most of my work in Windows, so the window manager stuff is not useful to me, but I’ve been and remain interested in trying out better window management systems. Windows is not too rich on those, so I’ll give Linux a try at some time in the future (when I have more spare time!).
January 27th, 2008 at 11:42 pm
May I ask? The starting point always seems to be that you have a file, and would like to rearrange parts of it, injecting some small snippet of text here and there.
How suitable is vi(m) for entering text in the first place, making corrections and reformatting as you’re going. My guess has been that vim is not the right tool in these cases (since, conceptually, you would normally be in insert mode). But now I see people requesting it for, e.g., e-mail – where you would spend more time entering text than editing it.
So, is it possible to use, and get used to, vim as text-entering tool?
January 28th, 2008 at 3:30 pm
Hi Patrick, you’re right. The case for vi/vim is less strong for regular ‘prose’ than it is for code or configuration files, etc… When writing, for example, an email, you stay much longer in insert mode. Once you’re accustomed to it, though, you miss being able to press ESC and start moving around with compact commands.
One way I like to see vi/vim editing is ‘ESC on steroids’: it’s like a regular editor, but ESC opens a world of compact & very powerful commands. Since it’s unobstrusive, you definitely miss it at least some times if you’re used to it.
So, yes, it’s possible to use & useful for text entering, although if that’s the sole use you do the case is not as strong as for code or other regularly formatted content.
January 28th, 2008 at 10:10 pm
Thanks J, for the reply.
I am hanging in the balance a bit, on whether to commit to vim or not. On the one hand, the underlying concepts appeal strongly to me – if nothing else, for it’s sheer elegance. On the other hand, I will not be able to use it exclusivly or even for the most part, and I worry about only learning it half-assed. I do code sometimes, but maybe not often enough to keep me fluent in vi-commands.
But you’re saying that it’s possible to treat is a normal editor at first, without being hampered. That’s going on the pro list.
It’s a bit of a shame that the insert mode commands tend to be left out in the tutorials. They would really be helpful in giving you a “way in” to vi.
There is also an issue with using other keyboards than standard english. Ctrl-] e.g. is quite difficult on a scandinavian keyboard – Ctrl-AltGr-9. Remapping isn’t straightforward either in this case, since the target key is a dead key – it isn’t even visible to the program until you press the next key. Same goes for backticks.
October 11th, 2008 at 1:54 am
There is a full-fledged Firefox makeover addon that turns your browser into a glorified vim. It’s called vimperator, and it allows you to browse with hjkl, use : and other vi-centric methods to browse, open and browse bookmarks, open and close tabs, and just about everything you could think of. I haven’t checked yet, but I don’t think there’s a polished version ready for Firefox 3.0 yet.
I’m hoping Google Chrome will have something like that baked in. If it does, then I will likely switch to it. I’m thinking not anytime soon though, as Alt-# doesn’t work for tab navigation… yet.
October 14th, 2008 at 12:45 pm
Sllik, I know about vimperator, but I’m not really much into it. I’m fine with a mouse for web browsing, it’s only when editing that I miss vi/vim if I don’t have them. I do know a few people who swear by vimperator though!
I guess there will be many extensions for Chrome in time, but they should definitely build a common platform for Firefox/Chrome add-ons if they don’t just want to dillute the efforts.
Thanks for your feedback!
– Jon
March 25th, 2009 at 6:11 am
Just kill yourself
October 4th, 2009 at 11:49 am
I’ve been a faithful ViM for over four years. My muscle memory had progressed to the level where I couldn’t even say which keys I was typing to do what- it just came to me naturally, much like touch typing. Felt absolutely awesome to be able to chain complex commands together unconciously and quickly build keyboard macros to repeat them. It’s an absolutely awesome text editor, and there’s no doubt about it.
Early this year, as I became more of a programmer, I realized that I need a lot more than just plain text editing. It was extremely painful, but I finally switched to Emacs. It’s possible that you’ll discover Emacs someday too; and it’s better that you do it earlier than later, especially if you’re a very heavy programmer. ViM is undoubtedly a fantastic dumb-text editor, no doubt, but I encourage you to look at the other side just to get a glimpse of what you’re missing.
October 4th, 2009 at 12:17 pm
Artagnon, as the saying goes, Emacs is a great OS… it just lacks a decent editor!
May 21st, 2011 at 12:04 am
Another thing worth mentioning is that Vim is ideal for telnet sessions or certain terminals where extended keys may not work as expected.