Hacker News new | ask | show | jobs
by yesimahuman 4685 days ago
Though I'm a long-time vim user, I've never even used cf" nor do I know what it means. However, I find most vi emulators work very well with the standard movement, yanking and inserting commands, and some basic visual modes.

I used ViEmu quite successfully a few years ago when I was doing C#, and I use vi mode on bash every day without many problems. If you keep it simple, you should be able to work across emulators pretty well.

3 comments

ViEmu does support cf" (I would know, since I wrote it). It means "change up to and including the next double quote", which is indeed classic vi, and supported by any non-trivial vi/vim emulator. I would guess the author of the author of the article meant ci" (change the text inside double quotes), which is vim-specific rather than vi (even a recent vim version, not an old one). ViEmu also supports that, but I'd guess many other emulators won't.

Indeed supporting a large part of the vim commands most people use is no walk in the park. I started writing ViEmu in 2005 and I'm far from running out of oft-demanded commands and motions to implement.

If you do not know what cf" does, you've been using Vim like you would use a normal text editor. Which is fine. But you're missing out a lot.

Do yourself a favor and go figure out what's the difference between: cf" cF" ct" ci" ca"

Note: you can substitute c for any "verb" (d, y, ~, etc) and " for many delimeters.

  :help text-objects
Thanks for the pointers, will do. One strange thing about vim is everyone seems to have a core set of commands they use. An interesting tool.
The thing with Vim is that even though you can use it like a regular text editor, it isn't too good at that. But when you grok the Vim philosophy, enter one command, verb + noun, then do your edit and press esc, you'll feel like flying.
I think cf" is pretty standard. I think it is even a original vi command and not a vim extension. Change the text from the cursor position up to the first instance of the " char.
I normally use ct" which is pretty much the same but excludes the character which I find is normally more useful - if I'm changing something in quotes, then ct" makes more sense. ci" is the best one of those though (change inside ")

I also have the same problem as the op, I can't use vim plugins.

Thanks, my vim problem is I'm always missing out on faster commands :)
In that case, a couple of extensions of that which I use constantly:

cf" is change find "

But, since this is a grammar, there are other things than c we can use like d (delete find ") or y (yank find "). More than this we can swap out f. Instead of f, try i, which I think of as "inside".

So ci" deletes the text inside quotes and leaves you in insert mode. ci) deletes the text inside parentheses and leaves you in insert mode.

For example

    foobar[somekeyvar] = "wooyay"

    move to somekeyvar and ci] then type "anotherkey"

    foobar[anotherkey] = "wooyay"
I use this constantly while programming.
Oh I know that feeling, even when I learn a faster command, it only takes a day once I forget about using it. It is really difficult adding unknown commands to the list of muscle memory commands. I recently switched to caps-lock+G for escape (from jj) and that was a tough ride because my muscle memory would always hit jj.