Live data from Hacker News

Vim tricks

hillelwayne.com

21–30 of 63 posts

Re: Vim tricks

#21

"Exobrains, on the other hand, stuff Vim full of plugins, functions, and homebrew mappings in a vain attempt to pretend they’re using Emacs." This is disturbingly accurate from my point of view. I keep wondering if I should finally jump ship and stop tweaking vim with questionable results. Spacemacs? Pure emacs + evil? Suggestions welcome.

I write primarily Python. Pycharm+vim bindings has been quite a pleasure in my experience. I still primarily use straight up vim with little to no mods for editing one-offs and isolated scripts.

Re: Vim tricks

#22

"Exobrains, on the other hand, stuff Vim full of plugins, functions, and homebrew mappings in a vain attempt to pretend they’re using Emacs." This is disturbingly accurate from my point of view. I keep wondering if I should finally jump ship and stop tweaking vim with questionable results. Spacemacs? Pure emacs + evil? Suggestions welcome.

I write primarily Python. Pycharm+vim bindings has been quite a pleasure in my experience. I still primarily use straight up vim with little to no mods for editing one-offs and isolated scripts.

Interesting, I don't often use Python but recent project had few 3000+ lines .py files, which make Vim _very_ unresponsive when editing. Other languages weren't so problematic but Python code is what made me look at Emacs direction at the first place.

Re: Vim tricks

#23

"Exobrains, on the other hand, stuff Vim full of plugins, functions, and homebrew mappings in a vain attempt to pretend they’re using Emacs." This is disturbingly accurate from my point of view. I keep wondering if I should finally jump ship and stop tweaking vim with questionable results. Spacemacs? Pure emacs + evil? Suggestions welcome.

Evil makes the transition from vim manageable, but once I was sufficiently far down the rabbit hole, I found I was consistently having to tweak and hack to keep evil working...eventually I bit the bullet and gave vanilla emacs bindings a shot, and haven’t looked back. YMMV, of course, and spacemacs comes highly rated.

But at the very least, they’re both good gateway drugs to get your first hit of the hard stuff

Re: Vim tricks

#24
post #11

> U is the same as u except it does the undo as a new change, which is functionally useless. Unless I’m mistaken, this is the default undo behavior for emacs...What horror to only have vim’s forward and backward undo history! Said the emacser on the vimmer’s post.

Maybe misunderstood what you meant, but vim's undo is not linear but rather tree-like. You can undo, make a change, and still get back to the initial state. https://vim.fandom.com/wiki/Using_undo_branches Edit: this also seems to be in the original post

You are definitely right, and I still find the emacs undo confusing...but I did think it was funny that one dev’s trash is another’s treasure—now that I know what to expect, I even kind of like the emacs way, but when I first switched I hated it.

Re: Vim tricks

#25

One I learned recently transferring some LaTeX over to rST is visual highlight => "gq". This breaks up long lines to multiple lines based on your stored text width. It can also be coupled with motions, e.g., "gq}".

Yeah. That's a really nice one. I use 'gqip' a lot when writing prose in latex, md, etc. One really cool thing is that it respects comments, so it will split long comment lines into multiline comments as necessary.

Re: Vim tricks

#26

"Exobrains, on the other hand, stuff Vim full of plugins, functions, and homebrew mappings in a vain attempt to pretend they’re using Emacs." This is disturbingly accurate from my point of view. I keep wondering if I should finally jump ship and stop tweaking vim with questionable results. Spacemacs? Pure emacs + evil? Suggestions welcome.

I particularly prefer doom-emacs [1]. I migrated from Vim to Spacemacs, however doom-emacs is leaner, faster and has better evil integration. For example, Spacemacs has no mapping for evil-numbers, however doom-emacs maps it to Ctrl+A (increase number) and Ctrl+Shift+A (decrease number) [2].

However, you will probably need to do some customizations in doom-emacs. Spacemacs works mostly only using its internal layers, however when you try to do something that isn't included already... Well, it is less than optimal. doom-emacs assumes that you will want to customize things.

[1]: https://github.com/hlissner/doom-emacs/

[2]: And as for why it isn't Ctrl+X to decrease number like in Vim, it is because Ctrl+X is probably the most important keymapping in Emacs itself. However I find Ctrl+Shift+A quite good because it follows the Vim convention of the reverse of some operation is on Shift.

Re: Vim tricks

#27

"Exobrains, on the other hand, stuff Vim full of plugins, functions, and homebrew mappings in a vain attempt to pretend they’re using Emacs." This is disturbingly accurate from my point of view. I keep wondering if I should finally jump ship and stop tweaking vim with questionable results. Spacemacs? Pure emacs + evil? Suggestions welcome.

I've made this request before but I would pretty interested in learning emacs the emacs way (rather than trying to emulate vim in emacs). Maybe leveraging my experience with vim in the sense that I don't need to learn what an editor is or shall basics.

Something that starts from bare(ish) emacs, includes emacs lisp, and gradually adds in plugins sort of like how this post does it but maybe more comprehensive and less individual tricks oriented.

Re: Vim tricks

#28
post #16

Earlier quoted context omitted.

can you give more examples of in code editing? I have tested that out in vim and its cool but i cant think of times I want to repeat a series in another part of the document, perhaps I'm just very uncreative right now Thanks

Totally. But I will tell you, is a habit built around the other options too. So I just use on any completion (which I frequently use ). Here's a dumb example (dumb because there's other ways to do it that are better) Let's say I'm overloading a function. void foo(int a, int b) {} I could do v until I fill in the b, then type ", int c)". Now it'd be totally easier to do "v backspace , int c)", but that's a different p…

Dude! That is awesome... it makes sense now. I totally didn't even know bout either!

Do you rebind your caps to control as well? That was another thing I did which is 10/10

Re: Vim tricks

#29
post #17
post #15

The problem is, how do you remember all of this stuff? Tabdo/bufdo is as advanced as it ever gets for me.

You have to make a deliberate attempt to learn it. What i would do is when coding I would focus on a single command and do it 5 or 6 times until it was engrained, then I would go to the next one. I spent about 15 days straight fairly intensively learning vim .. taht was 8 years ago. Best decision I have ever made in my entire programmign career. Now I pick up new vim commands like I am multilingual in 20 languages. A…

At my billing rate "15 days straight" is approximately equal to a low end BMW. So I think tabdo/bufdo will have to do for now. At least until I get a salaried job and can learn the rest at my employer's expense.

I do think there's Pareto principle at play with all this obscure stuff. Knowing 20% gets you 80% of the benefit, every additional percent gets you exponentially smaller fraction of the remaining 20%. That's how I play it anyway. I don't feel like I'm any less productive with my 20%.

Re: Vim tricks

#30

"Exobrains, on the other hand, stuff Vim full of plugins, functions, and homebrew mappings in a vain attempt to pretend they’re using Emacs." This is disturbingly accurate from my point of view. I keep wondering if I should finally jump ship and stop tweaking vim with questionable results. Spacemacs? Pure emacs + evil? Suggestions welcome.

Evil makes the transition from vim manageable, but once I was sufficiently far down the rabbit hole, I found I was consistently having to tweak and hack to keep evil working...eventually I bit the bullet and gave vanilla emacs bindings a shot, and haven’t looked back. YMMV, of course, and spacemacs comes highly rated. But at the very least, they’re both good gateway drugs to get your first hit of the hard stuff

A different data point:

After using vim for about 20 years, I switched to emacs+evil about 10 to 15 years ago.. and spent a lot of time in the first 5 years or so tweaking stuff. Things have mostly stabilized in the last 5 years, and I still use evil.

One thing that helped me a ton was using hydra. Whenever I install a new mode or package, I bind all of its useful functions to hydras. Hydra and evil allow me to keep all virtually all my bindings vim-like.

Post reply on HN