3 ms·
> Here is what I mean - if I learn the concepts "delete = d", "change = c", "copy(yank) = y", "in = i" and "around = a", I can construct "delete around (" = "da
by scottjad 15y ago
> Here is what I mean - if I learn the concepts "delete = d", "change = c", "copy(yank) = y", "in = i" and "around = a", I can construct "delete around (" = "da(", "yank block" = "yank around {" = "ya{", "change array contents" = "change inside [" = "ci[" and so on.
Vim is super cool in how it lets you combine commands. There's nothing quite like it in emacs. Emacs generally takes a more interactive approach, where each part is a separate command that can be interactively repeated. It's left to the user to combine them either by recording (and saving) a macro or by taking the function names for the commands and writing their own command. Emacs is rarely fewer keystrokes by default. For people who like vim editing commands there's viper, vimpulse, and evil.
da( = C-r ( RET C-w
My C-w is customized to cut the appropriate thing at point if there's no region. Without that you'd need a C-M-SPC before C-w
I would often do C-M-u repeatedly as it would cycle me through [, (, and {.
ya{ = C-r { RET M-w
Again I'd normally use C-M-u instead of C-r {, but if you know you want a { this is better. The difference between emacs and vim approach is clear here. Emacs separates the things and makes each step interactive, so you don't have to think before hand how many { are between cursor and where you want to start yank.
ci[ = C-M-9 C-k
C-M-9 is my custom which goes inside [, (, or {.
C-k is is paredit's kill, which goes to closing item instead of end of line.
- aufreak3 15y agoAha! I think I see the difference now. It's (in all earnestness, I swear) the difference between OOP and FP. Vim is verb-first and emacs is noun first :D My vim preference correlates with my language preference. How about yours? Do you prefer OOP languages? (this is just preference I'm talking about, not superiority of any sort. I read this somewhere - "talking about object oriented programming is like talking about pants oriented clothing". I concur.)
- nyellin 15y agoUse vim's visual mode when the noun is uncertain. Or just select the smallest possible block and . repeat.
- yoklov 15y agoThat's an interesting observation, and I'm glad I'm not the only one who has thought this. From what I've seen (as an emacs user, and a functional programmer), typically people in the FP camp tend to use emacs, and people in the imperative camp tend to use Vim. (Aside: Really, most of the people I know use IDE's these days, even if they are a vim or emacs user. The FP guys are the only ones who don't, to be honest, and that's mostly due to a lack of IDE's for functional programming languages.) Something I've thought was that Vim was for the most efficient possible editing of text data, whereas emacs was not concerned with efficiency so much as ability to edit _structured_ data. Emacs' paredit-mode is a great example of this. Should you be unfamiliar, paredit _prevents_ you from creating an unbalanced parenthetical structure in your code. For example, if you have (Harpo (|Groucho Zeppo)), where the | is the cursor, pressing delete does nothing! Instead, I should press M-s for paredit-splice-sexp (I think), which will result in (Harpo Groucho Zeppo). The structure is more important to your text editor here than your ability to edit the text. Vim, on the other hand, lets you drive unsafely. It lets you make your own speed limit (metaphorically, more than literally. emacs and vim are both quite fast methods of editing once you get used to them, I do think vim is faster though). It wouldn't ever do something like prevent you from deleting a paren just because it would cause an imbalance on the page. Object Oriented and imperative languages, C++ in particular, have always seemed the same way to me. They do what you say, and don't question the soundness behind it's logic. I have a lot respect for people who can code like that, because I can't. I like my text editor or my programming language telling me when I'm being a fool. Sorry for the long and somewhat off-topic post, it's a subject I've given a great deal of though to in the past and it sprung forth from my mind onto the page before I could stop it ;)
- gridaphobe 15y ago> Vim is verb-first and emacs is noun first :D I'm not sure I agree with this comment. I think vim and emacs are both verb-first, but they operate on different nouns. Vim focuses on manipulating text, whereas emacs focuses on manipulating code. I think both approaches are valid :)