10 ms·
Your problem with Vim is that you don't grok vi
Inspired by a comment [1] made today by kaylarose. It points to a most useful list of resources [2].
[1] http://news.ycombinator.com/item?id=2910991
[2] https://github.com/carlhuda/janus
- ez77 15y agoInspired by a comment [1] made today by kaylarose. It points to a most useful list of resources [2], which in turn refers to this in-depth post. [1] http://news.ycombinator.com/item?id=2910991 http://news.ycombinator.com/item?id=2910991 [2] https://github.com/carlhuda/janus https://github.com/carlhuda/janus
- dramaticus3 15y ago> A sampling of more advanced tricks I don't do tricks.
- 4ad 15y agoI agree. I know my view is very unpopular here, but I really don't think an editor that requires that massive block of text to understand is good. I used vi (not vim) for at least 10 years. The power of ed is what makes vi powerful, but if that's all I care about, I could just use ed (especially Plan9's ed which is more GUI than your old ed). I switched a couple of years ago to acme (http://acme.cat-v.org http://acme.cat-v.org) and sam (http://sam.cat-v.org http://sam.cat-v.org). Sam is a graphical version of ed, just like vi is supposed to be but for me sam is better. It's really GUI (unlike gvim which is GUI patch on vim) and it does everything a modern ed (from Plan9) does and much more (structured regular expressions). Both editors were designed by Rob Pike and are used today by key UNIX/C figures like Ken Thompson, Bjarne Stroustrup, Dennis Ritchie and Brian Kernighan. All things considered, I'd still take vi(m)? over emacs anytime :-).
- dramaticus3 15y agoFunny you should say that. The screenshot here http://en.wikipedia.org/wiki/Acme_(text_editor) http://en.wikipedia.org/wiki/Acme_(text_editor) is my screen
- ez77 15y agoed (especially Plan9's ed which is more GUI than your old ed). 'More GUI' because it added the b[rowse] command [1]? That's a bit of a stretch! [1] http://plan9.bell-labs.com/magic/man2html/1/ed http://plan9.bell-labs.com/magic/man2html/1/ed
- dramaticus3 15y agoPerhaps he means Sam, which is a kind of GUI ed
- 4ad 15y agoAh, no, sorry. It's more GUI because Plan9 terminals allow editing everything on screen. So I can type my text in ed and then use my mouse to position the cursor somewhere up, select text, and make a change. Perhaps I should have phrased it differently, if all I cared about was ed commands I could have used Plan9's ed in conjunction with a plan9 terminal, like 9term. In UNIX I use plan9port which has a port of ed, and 9term, a terminal that acts like a Plan9 terminal.
- dramaticus3 15y ago> So I can type my text in ed and then use my mouse to position the cursor somewhere up, select text, and make a change. No you can't, not in ed on Plan9.
- p9idf 15y agoSure you can. Turn on rio's hold mode.
- dramaticus3 15y agoYes you can type away all you like but ed only reads commands from the prompt, just like a line orientated terminal.
- 4ad 15y ago
- spacemanaki 15y ago"I really don't think an editor that requires that massive block of text to understand is good." Isn't that a bit disingenuous? From what it sounds like, you were probably able to become quickly proficient with sam and acme because you were experienced with vi and ed. It doesn't look like those editors are without any need for documentation. http://doc.cat-v.org/plan_9/4th_edition/papers/sam/ http://doc.cat-v.org/plan_9/4th_edition/papers/sam/
- 4ad 15y agoYou don't need to know ed command language and regular expressions to use sam or acme. All you need is a mouse. Knowing them would make a huge productivity boost but you can start using them gradually. Yes, you need documentation. How much though? I'd say very very little compared to traditional editors.
- mercurial 15y agoIt's a matter of taste. Many people here prefer to use the mouse as little as possible, and from what I understand, that's not the direction sam has taken.
- danparsonson 15y agoI bet you do, though - my experience of learning anything to a reasonable depth has been that I developed short-cut ways of doing things that are necessary but laborious to a beginner. Maybe vi has a higher-than-average density of tricks due to its steep learning curve, but once you know them it's very capable.
- jodoherty 15y agoThis is one of the reasons I wish all standard text controls came with an optional VI mode.
- icebraining 15y agoIt's All Text! achieves pretty much that by letting you write any text in your editor of choice (which can be gvim). Similar extensions exist for Chrome, but they require running a server in the background since Chrome doesn't let them execute external processes.
- ZeroGravitas 15y agoAnd one step further is to have vi-like binding for navigating the web, switching tabs etc. Vimperator and its recent fork Pentadactyl do this for Firefox, there's similar (though when I looked into it, less advanced) add-ons for Chrome/ium too, I think the one I tried was called Vimium. I was worried using such an invasive add-on would trip me up with Firefox's new rapid release schedule, particularly as I jumped to Pentadactyl because it supported version 4 first/better) but I'm up to Firefox 6 with no problems as yet.
- peedy 15y agoMy first browser was Netscape Navigator and today but obvious I'm on firefox. The only reason I am still stuck and not moved to chrome/ium is due to Vimperator. Your comment was a validation to me :) . I have nightmares that with chrome/ium becoming so popular, I might lose Vimperator.....
- deleted 15y ago[deleted]
- jodoherty 15y agoThanks. I think it'd still be useful though to shift from the paradigm of everything goes in my text editor to the paradigm that my text editor is already in everything.
- Triumvark 15y ago> I've often done things iteratively and interactively that could probably have been done more efficiently if I'd taken the time to think out the correct incantation. Maybe not. Efficiency is a measure of the time it takes accomplish something. 'Puzzling out how' can sometimes be a more relevant bottleneck than 'number of keystrokes.'
- swombat 15y agoThe difference is, if you just do it mechanically, you'll never get faster at it - the limit is the speed at which you can hit keys in a coordinated manner, which is not going to improve much over time. Something that takes you 100 keystrokes and a mouse movement today will still take you that much in a year's time. However, if, with a minute of thinking through the correct incantation, you can turn that into 10 keystrokes and no mouse movement, next time it will probably only take you 40 seconds to remember how to do it. Then, 30 seconds. Then, 20 second. Then, 10 seconds. Soon enough, if you do it often, it'll become automatic. And then you'll have locked in a more than 10x gain in productivity which would have been impossible the dumb way. This is also the reason we spend years learning how to program instead of just copying and modifying bits by hand, by the way.
- tyree732 15y agoWhile I agree with your initial arguments, that last sentence doesn't make a whole lot of sense.
- swombat 15y agoLearning to program takes almost as long as learning to use vi (hah!). Many people learn to program to automate a simple, boring task. Many people learn to program better by automating more of those tasks, before they progress onto "full programs" that have more of a stand-alone nature. Within those full programs, there are many times when we continue to have a choice between doing it the quick but dumb way, or taking a little more time and doing it the clever and reusable way. Of course, sometimes this can be taken too far - see yak shaving - but there are many points, while learning to program and while programming, where we face the choice between "do it manually in half an hour" and "take two hours to program something that will do it in 3 seconds". The difference between a programmer and a non-programmer is, largely, that given this type of choice, the programmer will tend to pick the latter option.
- hackermom 15y agoI think most people's problem with vim and vi is that they just don't feel like crossing the river to get their water.
- adelevie 15y agoOr maybe their Kool-Aid :)
- Tloewald 15y agoGood post, and worth reading if you're stuck with vim and don't like it. But, reading this reminds me of how much I like GUIs. Yup these movements are great. I get the appeal of turning selecting text into a dumb programming trick, I'm sure it makes you feel very clever and productive. Of course I can do all this stuff and more without even consciously thinking about it using a mouse. Go do multi file grep in BBedit in front of an emacs jock one day. Look what I can do by finding a menu item! Douglas Adams used to talk about how powerful formatting features in word processors were a great way to procrastinate.
- dmethvin 15y ago> Of course I can do all this stuff and more without even consciously thinking about it using a mouse. One of the reasons vi/vim is so much faster for me is that there isn't a need to move between the mouse and keyboard with the requisite hand/eye/mouse/re-home coordination. Yes the key combos are bizarre, but so is the querty keyboard layout for that matter. Once you learn it, your fingers act as a direct connection between your brain and the editor. A mouse can't do that.
- larsberg 15y ago> Go do multi file grep in BBedit in front of an emacs jock one day. Is there something it does that's better than M-x grep? I'm asking honestly, not to be snarky. And either way, it's not that menu items are bad... it's just, well, I've been using Emacs for ~20 years now. Across god knows how many different platforms, installations, and technology tool chains. How many times have you re-found that menu item? And how does their menu item differ from the one in (TextMate|VisualStudio|XCode|Eclipse|...). If BBedit is the only editor you've ever used or will use, great. But honestly, I don't want to find move next paragraph, spell check region, or reindent block ever again. They may be in the editor, in some menu somewhere. It may even be similar to the place I found it last time...
- eftpotrm 15y agoFlame suit on, but I really don't understand the appeal. I have reams of arcane bits of information to commit to memory already. .Net in two languages plus VB6 for legacy code. SQL in more dialects than I care to list, each with their own quirks and limitations. HTML and JavaScript. XML and various associated technologies like XPath. That's just professionally; once I go home I can add in photography and music straight off with others at different levels. There's only so many things one can usefully commit to memory (edit - yes, I meant am prepared to dedicate the time to committing to memory); odd bits are just easier to look up. So why, exactly, should I voluntarily use a text editor whose interface was already far behind the state of the art when I started school? :q!. I've had others try to persuade me of the joys and power of vi; I'm not even slightly convinced and that is the one command I'm committing to memory.
- jvanenk 15y agoVIM is muscle memory to me. I don't usually think about what I'm typing. I just think: 'I want this text over here' or 'I need all these phrases replaced with this new one' and then my fingers do it...like scratching an itch. That being said, one still needs to learn it to begin with. I'm lucky that I decided to sit down during college and at least learn the basics. I'm not convinced that it makes sense for every one to learn VIM or Emacs if they are perfectly proficient as they are now. For me, it's the right answer as long as I'm not pairing with some one who doesn't know VIM.
- Yhippa 15y agoI've found that using vi is like driving a manual transmission car after driving an automatic for a long time. There's a brief adjustment period but then it all comes back to me in terms of knowing how to use it. I tend to be lazy and use keyboard shortcuts as much as possible regardless of the OS I'm using. With vi it's basically heaven since they were able to make it a powerful text editor without a modern GUI.
- rhizome31 15y ago> There's only so many things one can usefully commit to memory Can you refer to any scientific research to back up that statement? My impression is that the more you use your memory, the easier it is to remember new stuff. Memory seems to be more like a muscle, the more you use it the stronger it gets, rather than a bucket that can get filled up.
- s00pcan 15y agoIs it a good or bad sign that I'm starting to see a lot of stories repeat on here? I installed Ubuntu on my work machine last friday and I was just looking at this earlier this morning (I had saved this the last time it was posted).
- erikb 15y agoI remember that the question was posted here before. This thread is focussed on one single answer of this SO discussion. First I was surprised, too. But now I think it is really great, because in this answer is so much more then what is connected to that question.
- snorkel 15y agoYes, I get it: some hackers of lore kept adding magic commands to the unix line editor until it grew into a stand-alone editor. Still doesn't appeal to me. Too many arcane keystrokes to do simple edits.
- Schmidt 15y agopress i, use the regular keys?
- jberryman 15y agoSimple edits require understanding 'i' to get into insert mode, 'v' to start selecting text, 'esc' to get out of either, 'y' to copy, 'd' to cut, 'p' to paste. Type ":wq" to save and exit. There, you're all caught up.
- CJefferson 15y agoWhat about things I know how to do in every app I ever use: Cut, Copy, Paste, Find, Find Next, Replace, Load, Save, Print, New Document, Undo, Redo. All of those things are standard in all mac apps, except vim of course. It occurs to me (just now, so this might be a poorly thought out point), that vim (and emacs) can be viewed as the 'anti-unix'. Unix is designed around tools that fit together in a coherent manner. vim and emacs are huge worlds, uniquely designed to be nothing like anything else.
- burgerbrain 15y agoYou won't hear any defense from me for Emacs, and Vim is certainly very debatable, but Vi is as UNIX as it gets: http://pubs.opengroup.org/onlinepubs/9699919799/ http://pubs.opengroup.org/onlinepubs/9699919799/ And expecting Vi(m) to use whatever shortcuts are standard for Mac applications is of course absurd. It isn't a Mac application, it's Vi.
- spwmoni 15y agoAll those features are in Vim. Unless your complaint is that the keystrokes are different from what you're used to on the Mac, in which case you should try googling "mac vim": http://code.google.com/p/macvim/ http://code.google.com/p/macvim/
- funkah 15y agoWhy should I have to grok a text editor? Up, down, left and right should get me around and if they don't, I'm not the one who's wrong. "You guys just don't understand why I eat dirt. I'm on a higher plane of existence and you just don't get it."
- evilduck 15y agoUp, down, left and right should get me around This works fine in vim. It's not suggested practice since moving your hand over to the arrow keys is slow, but it works like any other editor.
- kragen 15y agoIt turns out that moving the cursor using the mouse is dramatically faster than using the arrow keys, and moving using incremental search (Raskin's LEAP) is dramatically faster than that. So while you're eating your dirt off the arrow keys, the rest of us are already at the point where we want to make our edits, we've already made the edits, and we've rerun the test suite with another keystroke to verify that the edits fixed the bug. See you later, I gotta go to lunch. Have fun with your arrow keys.
- exDM69 15y agoMoving your hands from the keyboard to the mouse (and back) takes longer than getting to where you want using Vim navigation on the keyboard. You can also use intelligent movements (e.g. f" = to the next " on this line, or /foo = to the next line with foo or 362G = to line 362) instead of pounding the keyboard like crazy.
- kragen 15y agoYes, I'm sorry if it wasn't clear that was what I was saying. Thanks for the examples. I also use t a lot, but more with c, e.g. ct. or ct).
- JulianMorrison 15y agoMy problem with Vim is that it can't be configured to validate and correctly complete code in realtime (except by mad-science brain grafts like eclim). Note that ctags style word completion is like 1% of enough. The important thing is that code is either visibly wrong (red squigglies) or visibly syntactically valid (no red squigglies). That massively cuts down the contribution of trivial typos to bug hunting. And to do it requires a full parse and analysis of the language being edited, going on in the background as you type. Without that, Vim is reduced to a quick hacks editor, or an editor for languages where no realtime parse is possible.
- gte910h 15y agohttp://symbolsystem.com/pyflakes-vim/ http://symbolsystem.com/pyflakes-vim/ ? There are similar plugins for other languages.
- Schmidt 15y agoHalfway there is syntastic...
- dzorz 15y agoI use clang complete for vim. For me it is more precise than Visual Studio 2010 Intellisense (they use edg for code completion).
- oinksoft 15y agoMaybe I just don't fat-finger as much as the typical programmer...but intelligent code completion and typo detection are really not things I value in an editor. <C-N> buffer-based completion is more than sufficient when I need to save some typing.
- snprbob86 15y agoThis used to be something I greatly valued in IDEA and VS when writing Java and C# respectively. Now, I much more highly value consistency. In any given day, I may edit one of a dozen languages or hundreds of config file formats.
- 15y ago
- deleted 15y ago[deleted]
- freddealmeida 15y agoInterestingly emacs seems to be popular in Japan (where I'm based) but I always preferred Vim. Though it is rather complex. Interestingly if you want to do any Japanese text editing, most IDE's or editors fail horribly. I almost always find myself falling back to Vim. Mind you, I really like textmate. Sadly, it sucks at Japanese. And will for the time being.
- dasil003 15y agoI switched from TextMate to Vim last year because I realized that I don't want my editing eggs in a closed-source basket.
- aikinai 15y agoI just have to say thank you so much for this comment! I do a lot of Japanese text editing and I've also been learning Vim recently, but I had no idea that Vim recognizes Japanese words. Many times I've thought, "It's too bad I can't (effectively) use Vim for Japanese also," but I was just assuming it wouldn't be able to parse the words without spaces. I just tried it and my mind was blown when w moved forward in completely logical increments without plugins or anything. I still can't believe something like Vim would include a native Japanese parser, but now I think it's time to rethink my workflow... EDIT: I just tested some more and realized there isn't actually a semantic parser, but it's just treating any grouping of one syllabary (kanji, hiragana, katakana) as a word. Except for some debatable weirdness around conjugated verbs, it actually feels fairly natural given the rhythm of the different characters used in Japanese.
- exDM69 15y agoIt's funny how there are regional differences in this. I'm from Finland and for some reason Emacs is very popular here too. But I guess it comes from the fact that some default keybindings in Vim are horrible to type with a Finnish keyboard layout. On the other hand, it doesn't take a whole lot of customization to get comfortable with Vim.
- JoshTriplett 15y agoThis article captures the one thing about vim that took me the longest to "get", and which proved the most powerful once I did: vim has a rich set of movement commands, and a pile of commands which operate on those movement commands. Putting the two together gives a huge set of useful commands with a simple two-part form.
- scarmig 15y agoI wonder how much kvetching could have been avoided simply by making Vim open up in insert mode.
- Jach 15y agoI think that for a long time vim or gvim on cygwin used to do exactly that (I could be misremembering here). It's literally just an addition to the vimrc file, so I've personally set up a few people's installs to do that if they asked. (Along with other handy vimrc things.) But I really don't think it's any good. In order to save or quit you still have to return to command mode (unless you're using gvim all the time), and I edit more than I insert for non-new files (that there's a difference surprises people), so you're not really buying anything. Explain the command mode, some basic editing commands, how to get to insert mode and back (perhaps even adding an imap instead of using escape; I like 'jk' myself), and let people use it for it and not just a notepad substitute.
- dionidium 15y agoThe only time I might want vi in insert mode at startup is when I'm creating a new document. Every subsequent time I open the document I'll need to first navigate to somewhere else in the file before I begin typing. They made the right decision.
- erikb 15y agoIn terms of usability yes! But how many people would then just stay in insert mode forever, without ever understanding the depth of vi? Most programs are about getting results now. There usability is most important. But some programs (like vi) are about getting extremely, awesomely better results later on. These tools need the student/user to be in the valley of pain for a long time that they can actually reach this point of enlightment. I would argue that such kind of program also needs to get rid of users, who don't have the motivation or persistence to stay until a certain point of enlightment. Giving up on vi is good for the people who do. They probably wouldn't need this kind of power anyway. And those who desperately want and/or need it will eventually come to that point of understanding the other modes and commands of vi in the end.
- tmhedberg 15y ago
- dionidium 15y agoOne thing I think a lot of the naysayers here are missing is that you don't sit down and read a book on vim -- or even this stackoverflow answer -- and immediately expect to begin using all you've learned. It takes time. And it's painful at first. But it's a lot like gripping a tennis racket correctly or properly positioning your fingers at a piano. Your default method is indubitably the most comfortable -- by definition -- but the payoff of attempting the more difficult path can be likened to the magic of compound interest.
- NickPollard 15y agoEvery week or two, I teach myself one - ONE - new Vim technique/keybind/trick. Right now, I'm teaching myself { and } for jumping paragraphs. In a couple of weeks, that will become muscle memory. Then I pick something new. I know probably less than 0.1% of Vim, and I still find it better than any other editor I've used. One day I hope to reach 1%.
- alnayyir 15y agoBut I already know how to use Emacs and have been using it for years. I can navigate around vim but there's little advantage to me for using it when I can do almost any fathomable task in Emacs up to and including use viper-mode (vim emulator that works really well).
- atomicdog 15y agoExcept disregarding over three decades of human-computer-interaction progress is not the "proper" way of editing text.
- sabat 15y agoActually it's just that I'm not a fan of editor modes.
- swah 15y agoI wonder if the set of folks discussing here is completely different from the set of folks that saw Notch (Minecraft creator) coding on the weekend. Everyone seemed to agree he was very productive developing his game inside Eclipse.
- thequux 15y agoEclipse is not fundamentally less productive than vim; it's just productive along a different axis. Eclipse can sling around Java syntax like no other, but it's no better than notepad at editing text. On the other hand, vim has a very cursory understanding of Java syntax (as in, it knows that "for" is a keyword and "{" starts an indented block; i.e., just what is necessary for syntax highlighting and indenting). As a result, eclipse is really good at moving around your source, which is important when editing large software. Vim, on the other hand, is more of a tactical editor; it lets you compose a small set of primitives into a incantation that will rearrange arguments in a function call, and then compose that with the repetition primitives to do basic refactoring. The effect is the same, but the way you go about it is very different.
- swah 15y agoAnd hopefully you train to make those in a way that no syntax errors are generated...
- CmdrKrool 15y agoA thing that nobody ever seems to mention which unsettles me far more than learning key commands or modal behaviour in my brief tryouts with Vim is how its cursor visually highlights a current character rather than a point between characters like every other editor I've ever used. Say I have a line as follows: abcdef In other editors: to delete "abc" from the left: put the cursor on the a C-d C-d C-d to delete "abc" from the right: put the cursor on the character after the c (the d) C-h C-h C-h to delete "def" from the left: put the cursor on the d C-d C-d C-d to delete "def" from the right: put the cursor on the character after the f (the EOL) C-h C-h C-h Symmetrical and consistent, to my mind. In Vim: to delete "abc" from the left: put the cursor before the a xxx to delete "abc" from the right: put the cursor on the character after the c (the d) XXX to delete "def" from the left: put the cursor on the d xxx to delete "def" from the right: put the cursor on the f xxx The last case there is exceptional. It's a small thing, but not being able to put the cursor on a real or virtual 'end-of-line' character in Vim makes me feel constricted. I think that the between chars cursor model is simpler because you then have two choices: act on the preceding chars (thus, delete with C-h or <Backspace>) or act on the succeeding chars (thus, delete with C-d or <Delete>). By contrast Vim is more complicated because from the current character you have three choices: act on the preceding chars (thus, delete with X), act on the current char (thus, delete with x), and the principle of 'completeness' suggests a third: act on the succeeding chars - which AFAIK is not available in Vim and so it feels lop-sided to me. Ironically I think that it's my 'programmer head' which makes the between chars model appeal to me more, as I think of the file as a bunch of bytes (well, maybe multibyte characters) and the text editor as a glorified hex editor, and I just want to choose a position and insert or delete chars regardless of whether they're alphanumeric, LFs, or whatever. Whereas Vim's model of manipulating words, lines and sentences suggests to me a fit with people writing in human languages. Why, non-geeks should love Vim, perhaps except for all the key commands to learn; one imagines an alternate universe where the common keyboard evolved with two Return keys instead of one, labelled "Open new line above" and "Open new line below", and other Vim-inspired niceties - and I wonder whether your archetypal 'grandmother' might find it easier to write letters on the computer in that world than her current futzing about in Microsoft Word.
- num1 15y ago
- scelerat 15y agoI have been enjoying using Vico for the past month or so, a pretty Mac face on vi, with extras like support for Textmate Bundles. The mac-ness of the interface helped me through some vi adjustment rough spots, and now I'm extremely comfortable doing almost everything the vi way.
- binaryjohn 15y agoIt's great to see all the vimmers on this thread. One question, WHERE are all you guys? I work at a very large corp. and I am hard pressed to find another vimmer when it comes to discussing the beauty/elegance/purity of vi at the water cooler. May be we need a secret handshake or nod?
- tednaleid 15y agoFrom my experience, at Very Large Corp, if there are any vim users, they're likely in ops rather than developers. In smaller companies, you're much more likely to run into vim users. My company of ~10 developers has 6 devs that are significant vim users. I think the recent DevOps movement (which is actually a label to something that's been around for a while), is strongly correlated with vim (or emacs) users as well. Developers who get their hands dirty on remote systems often want a tool as ubiquitous as vim.
- methodin 15y agoIt took me far too long to really start using vim. I have to say, though, that as an avid user now I find it really annoying to find dw yy p :q and :w in the other editors I have to use on other machines. It does take discipline, though, but it is really FUN. How awesome is it to find some really sweet new key combination you didn't know existed? I almost never seek out the obscure settings of newer IDEs yet I often randomly search out new key combinations for vim. Love it.