Hacker News new | ask | show | jobs
by dreamer7 2049 days ago
Ya that would be really helpful. I've picked up bits and pieces of vim over the years. Recently, I even installed vimium on Chrome and the vim extension for VS Code in an attempt to get better at it.

It has been quite effortless to delete or replace words or lines but every time I've tried getting more adventurous with it - say, surround every line of text with double quotes etc, I end up finding the commands unintuitive or hard to remember.

There's also an issue with my older muscle memory of `CMD+Z` which works on a different stack than `u` and `CTRL+R` and I end up messing up my code.

1 comments

I guess I’ve got used to working with both sets of shortcuts but I miss the Vim undo system in other apps.

It’s worth noting that u and ctrl-r don’t operate on an undo stack but on an undo tree.

So if you have a series of edits and undo them all then do something else you can still get back to where you were before.

Use g+ and g- to walk the tree and the Gundo plugin is gives you a nice visual diff interface.

So having a separate shortcut and “stack” is actually a great feature of Vim IMHO.

Wow I didn't know about the undo tree! That would have definitely helped in a few scenarios
This is really cool, and I had no idea about Vim using a tree instead of a stack for undos. I'll check out Gundo.

Do you have any other similar recs that would help for learning?

Drew Neil’s vimcasts.org is a mine of useful tips.

His book Practical Vim[1] is particularly good because it teaches you the “vim way” without plugins.

Not that there’s anything wrong with plugins, I use a load of them, but there’s loads you can do without them.

1. https://pragprog.com/titles/dnvim2/practical-vim-second-edit...

vim generally doesn't need any of those fuzzy file finders that most people use. If you add

  set path+=**
to your vimrc, and open vim from the top level directory for your project :find <unique_filename_part> will just work

Setting up ctags will give vim some IntelliSense-like functionality that people tend to miss from their IDEs. More info here: https://andrewra.dev/2011/06/08/vim-and-ctags/

> vim generally doesn't need any of those fuzzy file finders that most people use. If you add > > set path+=

Be wary of this, it can end up being quite slow. Here is an excellent write up detailing the usage of the path setting.

https://gist.github.com/romainl/7e2b425a1706cd85f04a0bd8b389...