Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Your example falls flat. Any text editor with regular expression support can do that...

Do you have another example?



vim:

step 1: type ci(. step 2: type what you want to replace with. step 3: press ESC.

notepad++:

step 1: press Ctrl-H. step 2: type \([^)]*\). step 3: press tab. step 4: press (. step 5: type what you want to replace with. step 6: press ). step 7: move hand to mouse. step 8: move cursor to and click on "Regular expression". step 9: press enter.

Do you have another example?


Not implying that the vim way isn't faster but on any regular text editor you can:

ctrl+right arrow once or twice, right arrow to skip the (, shift+end, shift+left arrow, then type.


And of course, \([^)]*\) breaks if you have foo(bar(), x / (y + 1))


I think you are missing the elegance. The example isn't change foo to bar in f1(foo); f2(foo); f3(foo). The example is the series of steps and physical mode changes to change f(foo) to f(bar).

To do this one must select the letters foo somehow and then cause bar to be typed in their place. This can be done a number of ways in a "normal" text editor. For example, the person might double-click foo with the mouse to select the word and then type in bar. This does four things: 1. places the cursor in the location of foo; 2. select foo; 3. remove foo; 4. insert bar. In this example, there is one or two physical input context changes: from keyboard to mouse and back or maybe just from mouse to keyboard.

In vim, the physical input context never changes. The keyboard remains your context throughout. The person would 1. Position the cursor somewhere by foo (i.e. by typing a search expression like /foo<enter>); 2. type ci(<enter> which selects everything in the parenthesis, deletes and changes the context to input; 3. type bar (and probably 4. press the <esc> key).

I suspect that some people aren't bugged very much by the physical context switch and so the point of this is lost. Other people are bugged by it and struggle along until they find vi, emacs or the like.


Pepole don't use vim because it does things that are simply impossible in other editors - they use it because they find it lets them do that thing better. In this case, I guess the main point is about vim's modal editing in which the command is simple, easy to type and obeys a meaningful grammar.


The reason why it's interesting is it is basically a grammer for editing text. It's simple enough that you can easily create new strings of grammar which do what you want but powerful enough that the skill ceiling is practically infinite. Once you have a grammar for editing text a lot of interesting features fall into place quite naturally like having 'undo trees' instead of just linear undo, being able to write complex macros in the same language you edit text in, etc...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: