Settings

Theme

Search and Replace in Vim

vimregex.com

1 points by kirurik 4 months ago · 5 comments

Reader

kirurikOP 4 months ago

I'm currently learning vim and usign neovim, coming from VScode, wondering how y'all learned it if you made a similar switch, how long it took to learn and your opinions on purely text based editors vs smth like VScode that has a ton of features and plugins.

  • johncoltrane 4 months ago

    Vim comes with everything you need.

    The journey starts by running the following command:

        $ vimutor
    
    in your shell to learn the absolute basics in about 20 minutes, which is largely enough to be able to perform quick edits on config files. If it didn't stick the first time, then try again. If it didn't stick the second time, then don't bother: Vim is not for you and that's 100% OK.

    At the end of vimtutor there is a strong hint that there is a lot more to learn. If you are still interested at this point, then run the following command in a Vim session to access the user manual:

        :help user-manual
    
    An _active_ reading of chapters 1-12 and 20-32 is pretty much required if you really want Vim to disappear. Skipping this step will make everything worse down the line. It may take something like a month or two if you only do that, and probably a couple more if you do that on the side.

    Now, a few recommendations…

    Yes, you _need_ to read a lot and experiment a lot if you ever hope to become proficient with Vim. Just like with any "pro" app. It takes time and practice to become a pro at anything. That's life. Luckily, no one is expecting you to be a "pro" vimmer, now or ever, so you can do the learning at your leisure and even drop out if you have to. It's just a weird text editor after all and you still have VSCode.

    Each chapter of the user manual builds up on the previous ones so you actually get a very gentle and progression curve. The wording is also very approachable so you don't have to be a CS major to understand it.

    Don't go in with the project of replacing your current editor. This would be an absolute waste of time as it would give you false expectations AND a strong incentive to cut corners. Just… look at it. Poke at it. See if you like it and, eventually, dive in. Maybe you will end up replacing VSCode with it. Maybe not. Who cares?

    ---

    As a programer, I have been using Vim as main text editor since 2010. I love it and I'm pretty good at it, active in the community and all, but I also use other editors and IDEs when doing so makes more sense and I'm not here to evangelize the masses. Vim is old and weird and powerful but a) that power comes at a (rather low, IMO) price and b) it won't solve all your problems so don't invest too much, emotionally, into that learning.

    • kirurikOP 4 months ago

      I did the neovim tutorial which I accessed via :Tutor, I see now that vimtutor has some divergences, I will do that tutorial also, to improve my muscle memory and knowledge.

      Thanks for your other tips as well. I'll try and approach it that way, just doing it little by little, I don't always need VSCode and for simple edits its already way better than nano, although tbf I didn't take the time to learn all of nanos functionality.

      It probably is best to take it slow and not cut corners. Play some vimgolf and take it slow, try to get the base stuff like regex search and replace down. Learning regex well can be applied to other things as well, so it is worth it to practice it in the context of vim.

      • johncoltrane 4 months ago

        I would stay away from vimgolf if I were you because it focuses too heavily on a useless metric, number of keystrokes. The so-called "Vim language" is about expressiveness, intuitiveness, composability, etc., so performing a task in 20 keystrokes is meaningless if it took two minutes to figure out each of them. 40 or 50 keystrokes that flowed without thinking are always better.

        Also I must say that my regex-fu improved dramatically after I picked Vim.

        • kirurikOP 4 months ago

          True, it is meaningless how good one is at vimgolf if it doesn't flow naturally

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection