3 ms·
I never try to make vim keybindings work in a GUI editor. It is inevitably an uncanny valley, where it's not quite right, and I spend more time context switchin
by SwellJoe 10y ago
I never try to make vim keybindings work in a GUI editor. It is inevitably an uncanny valley, where it's not quite right, and I spend more time context switching between "real vim" and "this sort of vim" than I would just doing things the way the editor was built. I have spent enough time writing prose (and even coding) in more standard GUI editor environments that it doesn't feel unnatural to work in that way. There are some things that are a little painful (I'm really comfortable with, for example, complex substitutions in vim, but not so much in other editors), but most of the time I don't need those features often enough to have it be a major impediment. Like, I have no idea how to "change these two words, but only if it's at the end of a line, and keep the words in between them the same" in any editor other than vim. I'm sure it's possible, and maybe if I ever really switch off of vim, I'll figure it out.
So...yeah, I use Atom and VS Code mostly stock, with a few plugins. I don't ask them to act like vim. I'd just be disappointed.
- samb1729 10y ago> "change these two words, but only if it's at the end of a line, and keep the words in between them the same" How do you do this in vim? Could you give an example? I've tried a few times to love vim but emacs keeps pulling me back.
- khedoros1 10y agoI'd think something like: :%s/word1\(.*\)word2$/word3\1word4/ Over each line in the whole file, search for word 1 and word 2 (which is at the end of the file), separated by arbitrary non-newline characters, and change them to word3 and word4.
- juki 10y agoThe Emacs equivalent would be M-x replace-regexp word1\(.*\)word2$ RET word3\1word4 RET Assuming you have `replace-regexp` bound to a key, it's practically the same. Works on the whole buffer (by default), or the region (if selected).
- SwellJoe 10y agokhedoros' example is correct. vim has very sed-like search and replace, so UNIX command line skills translate back and forth. It's doubly useful, to me, that whatever tricks like that I pick up can be done from scripts with little to no changes (vim has a few differences, such as being able to specify which lines to replace either by number or visually or from beginning or end of file, but the matching/replacing logic is very similar). Also, I work in Perl a lot, which also has similar conventions for searching and replacing (though it has a more powerful regex engine with somewhat better syntax, like being able to include comments and newlines), so again, it's a skill that translates reasonably well back and forth. I don't really try to convince people that vim is better than any other thing. I get the appeal of things like Atom and VS Code and Sublime. vim was just the first really power editor I learned really well (on an Amiga, no less), and it's pretty ingrained (and I barely tap into its power...I used it pretty close to stock, and have no clue how to do tons of things without googling it), but it's very fast, for me. Heck, I don't even use hjkl cursor movement most of the time. I grew up on a keyboard with arrow keys, so that's what I reach for. I'm a sloppy vim user, but it's still more productive for me than other editors in many contexts.
- Merad 10y agoAny decent editor should have a regex find and replace mode.
- SwellJoe 10y agoAs I said, "I'm sure it's possible". I just don't know how to do complicated stuff off the top of my head in anything but vim.