Reiterating point 3 from the article: e.g. if the cursor is at | in:
printf("Hello |World\n");
With vim, you could manipulate the text in different ways by using different motions, e.g.:`db` would give `printf("World\n");` (b for backwards),
`de` would give `printf("Hello \n");` (e for end-of-word),
`di"` would give `printf("");` (inside `"`),
`di(` would give `printf();` (inside `(`),
or instead of deleting, some actions could be useful, like changing to uppercase: e.g.
`gUi"` would give `printf("HELLO WORLD\n");`
I always at least whip through such articles about vim as there may be something I don't use daily, but could. There always is such a thing.
I love to use all the zero-configuration things that are already present in Vi/Vim at work. IDE's are cool for devs or people who do everything from a stable workstation. I rarely have such comfort, jumping from one server to another, from one image to another. And Vi or Vim are always there. Thanks for all those hints.
ctrl+backspace: `printf("World\n");`
ctrl+delete: `printf("Hello \n");`
alt+shift+right, alt+shift+right, delete: `printf();`
I switched to Vim from Sublime Text years ago, and honestly multiple cursors and the live search and replace (especially across multiple files) were both missed until I learned how to do them in Vim just as easily.
Vim is a multi-year investment, and isn't worth it for most people.
foo(aa, bb, c);
foo(d, ggg, hh);
foo(iiii, i, jjjj);
I want to do something to the 2nd argument on each line. add a fn(prevContents). So I search for "foo(" and then pick "put a cursor on every match". Then how do get to the first comma and the select to the second comma on each line? This is easy with vim, easy with keyboard macros, not easy with multiple cursors (that I know of). For example as soon as I press "find" so I can search for the comma I lose multiple cursors. Maybe there's a special "Search with multiple cursors" command but if so that just highlights the issue, you shouldn't need special commands, you should be able to combine existing commands. vim and keyboard macros make that easy. C-f, "foo\(" [open a Find dialog]
C-Enter: [foo(]XX, YY, ZZ); [Find All shortcut]
Right: foo(|XX, YY, ZZ); [move to the right side of the match]
C-Right: foo(XX|, YY, ZZ);
C-Right: foo(XX,| YY, ZZ);
C-Right: foo(XX, YY|, ZZ);
C-S-Left: foo(XX, [YY], ZZ); [select leftward]
I suppose that it's not quite as ergonomic as Vim keybindings, but it's definitely less of a departure from the usual OS text boxes.What I'd do is this: Put the cursor on one of the calls, then use ctrl-d to put a new cursor at all the matches. Then use ctrl-right-arrow to move by word until the second comma, combine that with shift to select the argument and edit all of them with visual feedback to my heart's content.
In reality, depending on the complexity of the text, after creating all the cursors, I'd probably use the vim movements to get them to where I need though.
- multiple-cursor: select non-contiguous pieces of text, then edit them all at once.
- vim macro/repeat: edit a piece of text, and repeat on similar occurrences.
The vim "way" could be, `/;$` to select the trailing semi-colon, then `cgn` to edit it (enter the curly block once in insert mode, then exit with `<Esc>`), and now you can repeat on the next trailing semi-colon simply by hitting `.` (dot).
So, instead of first looping on the occurrences to get multiple cursors, then do the editing, you first do the editing on an occurrence, and you loop on the editing. There is admittedly less of a "wow" factor, but I don't think it is any less powerful.
(edited for formatting).
I say this as a huge vim advocate, who used vim exclusively for 8 years before switching to emacs and lately to vscode.
Vim gets a lot of things right, and there's no comparison to using vim-style editing. But multiple-cursor editing is a killer feature that really does improve your workflow a lot of the time. Luckily most editors have some version of it now, though often not as good as the original and doesn't always play nicely with the various vim modes.
It implements multi cursors in vim and combines it with vim movements etc.
(I actually tried to implement my own multi-cursor plugin in vim, and got a decent amount of the way there before realizing my fundamental approach probably wouldn't work.)
But the way I use my editor is that I'm usually in it all day. Both for editing code, but also for personal notes, etc. So it's on all day and I spend most of my time in it.
This effectively means I have one tool that I mainline. I'll still use vim in the odd situation where I can't use my main editor, but it's usually just easier for me to open files in the editor I already have open.
I keep trying to get into vim
Speaking out of my 20 years experience, you probably shouldn’t. You’ll find vim a little behind sublime/vscode in some parts and will keep trying to get out of it, unsuccessfully. I came to conclusion that I wish all of the editors (vim included) separated editing from their operation and made it modular (vim-like extensions are limited to a subset of it and are really worst of all these worlds, cause only half of your habits work and none of your scripts/addons do).
Update: I guess your complaint is about a plugin ecosystem that doesn't respect vim bindings. I think you'd be impressed by what the evil community has, speaking as a former power vim user whose emacs setup is even better.
I'm on spacemacs which I believe has given me a massive head start on a great setup. If I started from something more lightweight I would have wanted to end up where I am now, but the results on my own would have been worse.
However I admit that even the supposedly beginner friendly spacemacs still has the same problem of "find the intuitively named spacemacs layer, then start googling all the package names mentioned in the docs (which are not intuitively named), and possibly read the source", which is a big set of hurdles.
Edit: please don’t downvote the parent commenter, it’s a non-obvious knowledge and it doesn’t apply to everyone.
Edit: I spent a long time trying to make Vim more IDE-like, but found it was more productive to make my various IDEs more Vim-like, but I concede that might not be suitable for everyone
I wouldn't use this as the basis of an argument for superiority of IDEs in general over vim.
And of course there are tradeoffs, rubymine users I worked with always complained about startup times and heavy indexing. (This was a few years back, maybe it's improved since)
If you can write vim macros to extract method, push up dependencies etc, then you've made vim better than most IDEs.
It's true that there are a lot of things I configured specifically in vim, however, VSCode has a pretty decent vim mode that takes care of a lot of stuff (including a bunch of pretty standard stuff that most people add to vim, like adding vim-surround for example).
In addition, it has a pretty decent way to configure new commands, so most of the other stuff I missed from vim I could actually figure out how to port over to VSCode.
Totally worth it for me - it was a few months of slowly rebuilding habits and porting commands from vim, but now I have a "best of both worlds" setup.
if I want to do something like filter things in the problems pane, I need to focus an entirely separate thing with no vi bindings so I'm forced to reach for the mouse to use that or even to just get back to a pane that supports vi bindings.
also ctrl+w closes tabs instead of being a prefix for focusing different panes
Lately I've switched to a programmable keyboard, so my actual arrow keys are int accessible via a special Layer (I hold a thumb key, and that gives me hjkl, as well as various other bindings I've created that act like vim commands).
It starts faster, everything works together better, no weird plugin-compatibility issues (mostly). If I need to find a command, it's easier to lookup in VSCode than Spacemacs (because the menus use a much better GUI, with fonts, highlights, etc).
If I want to switch between files, open a folder as a project, etc, it all works well, and out of the box. With Spacemacs, there isn't a good file-tree pane that I can put on the left - IIRC it comes with something like NERDTree from vim, but it never worked well for me. Partially this is the whole fonts/gui/etc limitations, partly it's because a lot of the shortcuts just don't work that well. Just quickly opening up a folder, seeing what files there are, and being able to rename a file by right-clicking on it and hitting rename is something that I don't do often, but happens once a week, and in Spacemacs, that once a week necessitated either looking it up, or fixing something.
(I was faster at doing these things with vim, in which I had way more time invested, but why I switched from vim to emacs is a similar story in many ways.)
Honestly, overall, VSCode and modern IDEs are just a much smoother, better overall experience in so many small and large ways, that I feel I am much more productive, and have to spend way less time tinkering with my editor. And much as I love to do that, I've been doing it for 10 years, and already have a decent set of knowledge about what I need and want. Getting it practically out of the box with VSCode, and having it work better, is a wonder.
(My biggest block in switching to a different editor in all this time was that I had to have a decent VIM mode, because being able to actually edit text at speed and comfort is more important than all the other features to me. But once I realized that Spacemacs' vim mode was decent, I switched to that, and then I played around with VSCode and realized the vim mode there was decent too. Definitely enough to satisfy 95% of standard text editing use cases, with either plugins or my personal mappings making up the gap.)
From the sounds of things you're used to discovery by context clicking and menu items, and emacs' lack of such things does hurt discovery. I find the mnemonic key mappings in spacemacs to be superior to those interactions, but I'll admit: only if you can actually find them, and it does take some time to get used to the conventions.
As a developer though, I am an expert in using my editor, so I'm happy doing e.g. ",tt" to run the test where my cursor is, ",tb" to run all tests in a buffer, etc. because that knowledge pays off hundreds of times a day.
Lastly I'm not sure the distinction "modern IDE" is helpful. Neo/vim and emacs are both under very active development. Useful variables seem to be things like: package ecosystem, UX, aesthetics, responsiveness. All of those can be divided into beginner/expert and IMO emacs wins all of the expert cases, _if you are willing to put lots of time in_. For example I'll take my beautiful full screen spacemacs with the bells and whistles turned on over the looks of my colleagues' VSCode any day.
"Willingness to put the time in" of course exists in a continuum. I know fantastic programmers who gave up on the effort of emacs, and others who tell me that I'm selling myself short by stooping to spacemacs instead of rolling my own. So everyone's MMV.
I half agree and half disagree. I also really hate having the mouse involved in my workflow.
> From the sounds of things you're used to discovery by context clicking and menu items, and emacs' lack of such things does hurt discovery.
That's part of it, but not all of it. I don't use context menus much and am also a keyboard-centric user. I rarely use menus for any common tasks.
That said, things that I do once a week, but do need to do, are often easier to do using a mouse (or rather, it's good that a better discovery mechanism exists for them).
> Lastly I'm not sure the distinction "modern IDE" is helpful. Neo/vim and emacs are both under very active development.
That's true, but that's not what most people mean. I think the 'modern' comes in in terms of UX, or at least that's at the root of things - because almost everything can be done with vim/emacs, except for fundamentally changing how they look (different fonts/colors/etc). Or changing the under-the-hood stuff (like running parallel processes).
> For example I'll take my beautiful full screen spacemacs with the bells and whistles turned on over the looks of my colleagues' VSCode any day.
I mean, obviously this is subjective. But GUIs that allow a full range of colors/sizes/etc, and are not limited to only being text buffers, do objectively allow you to do more things. And it's no coincidence that almost all IDEs/editors don't use a single font size everywhere, etc.
> "Willingness to put the time in" of course exists in a continuum. I know fantastic programmers who gave up on the effort of emacs, and others who tell me that I'm selling myself short by stooping to spacemacs instead of rolling my own. So everyone's MMV.
I mean, I used vim for about 8 years, including writing (personal use) plugins and having a very large .vimrc. I then switched to spacemacs, had a bunch of configurations there as well.
So I feel like I've definitely put in a decent amount of time getting "good" at vim (and to a much smaller extent, spacemacs).
Still, putting aside the pure text-manipulation aspects of vim productivity, just launching VSCode and opening a folder gets you way more of the way to productive coding than everything I managed to roll out using a vimrc (and does't break every time I change language/computer).
I wish there was a NeoKak that would integrate with other environments like VS Code the way NeoVim does.
(Personally, I find vim's multiselect cumbersome to use compared to sublime/vscode's.)
foo bar baz
And you need each line transformed into:
[Foo](https://example.com/foo.html)
Or something like that. Macros make short work of it.