9 ms·
Seven habits of effective text editing
- h2s 14y agoA few developers I've known have made the case that they just don't see text editing speed as the bottleneck in their day-to-day work. They're perfectly happy with the speed at which they can edit text and that's fine. What gets to me a bit is the dismissive attitude this type of developer tends to take towards usage of Vim, as if using it makes me some sort of misguided autist. The reason I think it matters is that there are a limited number of hours in the day. When I get home from work I have maybe three or four hours on a good day to make some progress on my own projects. If during that time I can save 10 minutes of holding down arrow keys and carefully maneouvring the mouse cursor around my code and so on, then in a week that's an extra hour or so of extra project time.
- oelmekki 14y ago> They're perfectly happy with the speed at which they can edit text and that's fine. I think they miss the point. Speed editing with vim is not about how many lines you may produce in the day. It's about the lag between the moment you think about what you want to write and the moment when it's written. Your editor should not be in the way, and that's what vim, when mastered, is all about : you simply don't think about it anymore. It's for the same reason that vim tries to reduce hand movements, so you won't feel your editor in those extra displacements.
- tyrmored 14y agoYes, I think you've nailed it. See my own reply to this comment.
- minikomi 14y agoAlso, it's extremely satisfying to record a complex macro and then 100@@ it across a wide swath of your file
- mcantor 14y agoRecording macros correctly and quickly is an art. Text objects help immensely, since they can handle a lot of edge cases in different places across your code.
- dasil003 14y agoOne of my favorite tricks was binding @q to <space>. It really speeds up playback so I don't need to necessarily count occurrences or go recursive.
- deleted 14y ago[deleted]
- mistercow 14y ago> It's about the lag between the moment you think about what you want to write and the moment when it's written. I think this is it exactly. In particular, when people start trying to incorporate typing speed into their arguments, it's a sign that they really don't understand where the bottlenecks are.
- snprbob86 14y ago> It's about the lag between the moment you think about what you want to write and the moment when it's written. Agree 100%. Every other editor just feels like swimming in molasses to me.
- tyrmored 14y agoThe time you can save with Vim can be significant, depending on the task. However what I think is far more valuable is that Vim doesn't get in the way; it doesn't impede the all-important "flow", and perhaps most importantly it stops you getting bored. When your muscle memory develops to a certain point, using Vim becomes a subconscious thing. You don't have to think about how to copy all the text in between two quotes and paste it at the end of the document; there are already words in Vim's vocabulary for doing that, so you just do it. You don't need to build mental steps because it becomes completely natural, as easy as typing natural English; and just like in natural language, the more words you know well, the more likely you are to be able to use the right word at the right time, using language effectively. Equally valuable: Vim takes the repetition out of everything. A technically versed creative mind is wasted on any repetitive task. You should never, ever have to do anything more than twice in development. You should be able to repeat and automate tasks and scarcely think about it. In Vim, this need is met by skilful use of . to repeat actions and q to record macros. When you edit text optimally, you can concentrate on the task at hand, and the editor stays out of your way and does exactly what you need it to. You don't need to build the "subtask" of making your editor do what you want; you can just do it. I think that people who focus on the time Vim does or doesn't save you are missing the point.
- jamesbritt 14y agoA technically versed creative mind is wasted on any repetitive task. I find that certain repetitive tasks help free my mind up to wander around, think more abstractly about my code. What's important to me is that my tools give me a choice about this.
- evoxed 14y agoSadly every minute gained with vim/emacs/anything is another 10 minutes wasted arguing about it... Disclaimer: I use vim because I just like it. The key to becoming more efficient in my opinion? Learning to type faster. Saves you all kinda trouble when you're posting to HN as well ;)
- Derbasti 14y agoVery true. I think the key to efficiency is alway happiness. When you're happy with your environment, you most likely can work without worries or disturbances and are thus efficient. So, use the tools that make you happy. Personally, I use Emacs and I love it. But I don't think that Emacs inherently makes me more efficient than, say Vim or Sublime Text. That said, you should use a tool with sufficient power so you are not limited by it. So no Notepad, sorry.
- npsimons 14y agoIt's more than just time savings; remember in "Peopleware" how they said even a one minute interruption really meant 15+ minutes of getting back into flow? If your dev environment gets in your way every time you use it, it will be like trying to drive a stickshift if you don't know how. As was said in "Pragmatic Programmer", your editor should be an extension of your hand; if you're always having to reach for the mouse to do something, it's like a cache miss (another great analogy, from Steve Yegge's "Effective Emacs"). While this doesn't have a whole lot to do with a specific editor, I have to say that most "modern" IDE's I've ever seen suffer from too much mousing, and you can recreate their useful features in Emacs. I still love vi (and use it for quick sysadmin tasks), but there's a reason I have the Firemacs addon installed in Firefox.
- henrik_w 14y agoGood references from Peopleware and Steve Yegge! As for IDEs and mousing: I hate when I have to reach for the mouse - I try to do as much as I can with keyboard short-cuts. I'm currently using Intellij IDEA for Java coding, and it is definitely possible to do a lot without the mouse. The big advantage is navigation. Most of the time for me is spent navigating the existing code, and there Intellij IDEA really shines compared to just a text editor. I've written this up in more detail here: http://henrikwarne.com/2012/06/17/programmer-productivity-emacs-versus-intellij-idea/ http://henrikwarne.com/2012/06/17/programmer-productivity-em...
- gizmo686 14y agoThe reason I like vim isn't so much about editing speed as reading speed. I spend a large amount of time in source code for projects where I only want to check or change some very minor things. Always being a keystroke away from jumping to anywhere in the code turns this from a boring, hellish ordeal, into an quick, exciting exploration of code. Vim also has the perk of being terminal, so it integrates seemlessly with my flow when want to use cmdline tools (also often). Being able to refactor large amounts of code quickly, and with minimal repatition is also fun. Interestingly, despite my strong prefence for vim, and the fact that I spend most of my time in it, when I am actually writing new code, the only time I hit ESC (caps-lock) is to save.
- Evbn 14y agoGet better coworkers. I have some, and we are hiring.
- prawks 14y agoWhat I love most about vim: Whenever I read an article like this I find solutions to problems I didn't even know I had. The abbr trick is awesome!
- aerique 14y agoI've always prefered to retrain myself instead of using abbreviations because I was afraid I would need increasingly more of them because of the abbr crutch. However I have never heard of this happening to anyone. Does anyone have any experience with this?
- lordlarm 14y agoA great resource in order to learn new key bindings and be more efficient in Vim: https://www.shortcutfoo.com/ https://www.shortcutfoo.com/ Great article by the way. I enabled "hlsearch" and added "map <CR> :noh<cr>" in order to exit the highlighting by pressing return.
- alwillis 14y agoshortcutFoo is pretty slick. Bookmarked.
- crazydiamond 14y agoVim lovers would love Steve Losh's Coming Home to Vim: http://stevelosh.com/blog/2010/09/coming-home-to-vim/ http://stevelosh.com/blog/2010/09/coming-home-to-vim/ This was on HN a couple years back. http://news.ycombinator.com/item?id=1710702 http://news.ycombinator.com/item?id=1710702
- blahedo 14y agoThe great thing about vi[m] is that even after twenty years of using it, as my primary editor for everything (paired with LaTeX for document generation, mutt for email, etc), and much of that time spent teaching students how to effectively use it, I still sometimes learn about useful commands that I didn't know about. (Today: asterisk to jump to next occurrence of current word.)
- ColinWright 14y ago... and hash to jump backwards to previous occurrence of current word.
- gizmo686 14y agoOut of curiosity, what were some of the first things you learned? When I started Vim, the cursor movement commans (/ * ? G ETC) where the first things I learned, followed by yank, cut, paste and registers. I'm still amazed by the inline editing tricks I see.
- white_devil 14y ago.. Or you could, you know, just use whatever IDE is appropriate for your language and be a lot more productive than you ever could with Vim.
- jamesbritt 14y agoWhat's the appropriate IDE for Haskell that will make me a lot more productive than I could ever be with Vim? What's the appropriate IDE for Ruby that will make me more a lot more productive than I could ever be with Vim?
- Flow 14y agoI don't know about Haskell. For Ruby there's RubyMine at least. For Javascript/HTML there are Eclipse, Netbeans, IntelliJ and WebStorm.
- masklinn 14y ago> IntelliJ and WebStorm That's a bit redundant, since WebStorm is kind-of a cut-down IntelliJ.
- Flow 14y agoAnd yet, I own both :)
- deleted 14y ago[deleted]
- jamesbritt 14y agoFor Ruby there's RubyMine I've tried RubyMine, and I'm much more productive in vim. If it comes down to having to spend a lot of time mastering this or that IDE, I still think I'd come out ahead with vim. The bar here is that the IDE has to make me more a lot more productive than I could ever be with Vim.
- bediger4000 14y ago
- eta_carinae 14y ago> A few developers I've known have made the case that they just don't see text editing speed as the bottleneck in their day-to-day work. Right, it's only a bottleneck if you use the wrong tool for the job. As much as I love vi for text editing, it is the wrong tool for HTML editing and for a growing number of other file types for which more specialized editors exist (e.g. Eclipse for Java). I know that vi experts think they are very fast with vi but they are wrong: if you are using vi for anything but simple text files, you are not being as productive as you could be and you should really consider being more mentally flexible and use the right tool for the job instead of vi for every job.
- mcantor 14y agoMost command-line junkie types actually use vim, not vi. vim is quite practical for editing an enormous variety of file types at breakneck speed, and this is coming from someone who used to exclusively use environments such as Eclipse.
- VeejayRampay 14y agoThe best programmers use either Emacs or vim. vim goes way beyond "simple text editing" you don't seem to know what you're talking about.
- mcantor 14y agoNo! No, no, no, no, no. The best programmers use whatever they use. You are making the same mistake as the guy you're replying to. There is no one best way. We need to get over this mentality as a community. I don't mean to pick on you, as this was clearly just an off-the-cuff comment, but this kind of dialogue is simply worthless. I agree that the grandparent poster seems pretty clueless about vim and its ilk, but an equal and opposite reaction that's just as subjective and baseless will get us nowhere.
- Stratoscope 14y ago> The best programmers use either Emacs or vim. Do you really think that? I can assure you that you're wrong: many world-class programmers use editors other than Emacs or vim. There are great programmers who use Microsoft Visual Studio, Komodo IDE, Sublime Text 2, and many dozens of different editors.
- mcantor 14y agoTrivia: This is written by Bram Moolenaar, maintainer of Vim (the trivia part is that he maintains Vim; hopefully it's quite clear that it was written by a guy named Moolenaar).
- Evbn 14y agoAnd original author.
- jodrellblank 14y agoHow much of this is because we still can't have a button which "puts the cursor where I'm looking". (Or that we can't touch where the cursor should be). "Go to the next instance of this word, wherever that is" is helpful; having to proxy a leap to somewhere you are looking at, through a vim command, still seems suboptimal.
- Evbn 14y ago> Bram Moolenaar is the main author of Vim. Note that this article was written in 2000. 12 (!) years later, we have amazing plugins that make :make rather quaint. Most important vim command? :help uganda