4 ms·
Well, as someone who's in the middle of writing his own blogging platform specifically so I can use Vim to write my posts... The important thing that Vim does
by oneandoneis2 14y ago
Well, as someone who's in the middle of writing his own blogging platform specifically so I can use Vim to write my posts...
The important thing that Vim does for me is to reduce to an absolute minimum the amount of keypresses it takes to write the code I want.
Simple example: It's a common practice when people are putting in blocks of comments to put in an eighty-character line of hashes to delineate it - something I'm sure every coder has seen. And it's not hard to just hold down the hash key until it's reached the end of the line. But it's far quicker and more reliable in vim:
80i#<ESC>
Say I'm editing code near the bottom of a screenful of text. I want to see a couple of lines that are just off the top of the screen. In most editors you'd hold down the "up" key until your cursor reached the top of the page, keep going until the lines you wanted were on show, then hold "down" until you got back to where you started.
In vim, Ctrl-Y a couple of times and you're done, without losing your place - your cursor stays in the current position, on the current line.
The regex-capable search + find&replace is invaluable - Earlier today I had to generate >100 tests based on information spread through multiple spreadsheet tabs. This would have been hours of work doing point&click copy-pasting, it was done in a few minutes courtesy of a couple of regexes.
Moving blocks of code around when refactoring is effortless: di} to delete all the code in the current JS function and copy it to the buffer, move to where you want the code to be, 'p' to put it in its new home.
The "snippets" plugin giving TextMate-style functionality is very useful, a big plus for vim's ability to be programmed, which I also use extensively. For example, we often need to look at information stored by our web application in a database. We used to have to either access it via the DB or use the web app itself to display a poorly-formatted static text output. I created a Vim command that retrieves the data, orders it, formats it, syntax hilights it, and makes it far easier to navigate & search.
I've used IDEs, I've used other editors, and Vim is simply better than all of them. IDEs in particular spend more time getting in the way than they do being useful. Vim is the closest thing there is to being able to take the code I have in my head and dump it straight into a computer.
And given the number of studies that show that a single interruption to a coder can result in a half-hour delay whilst he rebuilds his mental stack, that makes Vim a tool that can save you hours of productive time every single week.
- robomartin 14y agoOne of the seemingly common threads I am seeing is that having vim available across platforms is an advantage to some. That certainly has value. I can't really comment on the rest of your excellent post until I try some of these things out. I intend to spend some time with vim this weekend, try out some of the ideas presented in this thread and see what I can learn. I can comment on this: "And given the number of studies that show that a single interruption to a coder can result in a half-hour delay whilst he rebuilds his mental stack, that makes Vim a tool that can save you hours of productive time every single week." I've been programming since I was ten years old. I have well over twenty years of experience in the field, across multiple platforms, tools and languages. I started out with machine language. Not assembler, actually typing in hex instruction codes into a keypad. Back then, I used that approach a number of times to bootstrap a Forth system onto a newly built computer board (something like a 6502 board). One of the first things you do after that is write an editor (in Forth) so you can start moving faster. I have to say that in all of this time I have never had an editor get in the way of the programming task to such an extent that it can be considered an interruption. Interruptions that disrupt the mental stack you refer to are very real and they suck, but, in my experience, the text editor is never the issue. Again, thanks for your valuable input. I'll spend some time absorbing it over the weekend. I need to get a project out first. Damn priorities!