|
|
|
|
|
by chousuke
3407 days ago
|
|
It's not the shortcuts, it's how they work. The thing about vi shortcuts is that they form a composable "language" of sorts, so instead of having to memorize a set of shortcuts for doing specific things, you memorize motions and actions and the rules to compose these. For example, in another editor you might have ctrl-K to delete a line (dd in vim) , but what about deleting 4 lines? in vim, it's 4dd. Or you might want to delete from the start of a block to the end... The motion for block in vim is %, so to delete a block, you'd do "d%". Similarly, deletion to the end of the line is d$ In visual block mode (ctrl-v) you can select a bunch of text and apply an action (eg. a simple replace, which would be :s/foo/bar) on only that text. Even if you just learn a bit at the surface, the free composability of motions with actions makes even classic vi (which doesn't even support arrow keys for moving around) extremely comfortable to use, and most of the time you don't need to twist your hands into uncomfortable chords involving multiple modifier keys. |
|
In Emacs, deleting four lines is Alt-4 Ctrl-K, usually written M-4 C-K.
One way to delete a whole block (meaning a paragraph?) is M-h Backspace. Deletion to the end of the link is C-K.
Selecting a region is done with C-Space, running a simple replace is then M-% foo bar !
I'm not an expert with Emacs. The most useful function I use is the macros, which saves me learning many other functions. F3 starts macro recording, F4 ends it, then F4 again runs the macro. It's easy to script changes and run them in this way.