5 ms·
Learning to use Vim! I've tried three times before in the past 10 years. This is the first time it actually clicked. It's the first time I've tried Neovim. It's
by SwiftyBug 3y ago
Learning to use Vim! I've tried three times before in the past 10 years. This is the first time it actually clicked. It's the first time I've tried Neovim. It's awesome and I feel like I'm playing a game with myself while working. I thought it would take much longer to get to the speed I'm at now. I've been using Vim exclusively for a month.
- champoradopapi 3y agoSame here! What keys/combinations are you usually using right now?
- SwiftyBug 3y agoI try to not stray too far from the default key binding as I think it would be good to be able to use Vim on servers that don't have all my config. But, hey, what's the point of using Vim if you're not having fun ricing it? These are some indispensable key maps to me: In visual mode, move a line up or down: vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv") vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv") In normal mode, replace all occurences of the word under the cursor: vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]]) In normal or visual mode, Yank to the OS's pasteboard: vim.keymap.set({"n", "v"}, "<leader>y", [["+y]]) And there are plenty more that are related to specific plugins. Also, I've remapped caps lock to esc in the OS. This makes it way easier to leave insert mode without leaving the home row.
- november84 3y agoAny resources you can share or did you jump into the docs?
- theossuary 3y agoTbh the best bit of advice I ever got for learning vim is to keep a sticky note on your monitor with 5-10 motions you want to learn, and replace it once you've started using them consistently. Start with h, j, k, l, w, b, a, i, o, esc And go from there
- jodrellblank 3y agoYears ago I learned the basics from this IRC chat log of someone introducing someone else to Vim basics: https://www.vi-improved.org/irc-style-tutorial/ https://www.vi-improved.org/irc-style-tutorial/ There's a popular stackoverflow answer as a Vim (Vi) introduction, which I haven't read through but will link anyway: https://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim#1220118 https://stackoverflow.com/questions/1218390/what-is-your-mos... http://vimcasts.org/episodes/ http://vimcasts.org/episodes/ screencasts are high quality short videos, go back to the early ones for introductions to buffers and windows and things (more recent ones tend to be too many niche scripts and plugins for me).
- sovietswag 3y ago(Not the person you asked) but it helps to realize that vim in "insert" mode is just like any other text editor you know, you can use your arrow keys and the delete button to edit your document. You will get annoyed pretty quickly navigating with arrow keys and no mouse cursor, so you might search up "how do I jump the end of this damned line!" (hint: it's the $ sign). As you edit documents you will get more and more annoyed and search up more shortcuts which you will be happy to incorporate into your life. This is what worked for me, anyways.
- SwiftyBug 3y agoSure! The first thing I did was follow this video: https://www.youtube.com/watch?v=w7i4amO_zaE https://www.youtube.com/watch?v=w7i4amO_zaE This is ThePrimeagen's 0 to LSP, Neovim RC from Scratch. In this video he performs a clean installation of Neovim and goes step by step adding the things he considers essential. This was very important for me to acquaint myself with how things work, how to install plugins, how to define custom key maps. I remember the first times I tried using Vim, I couldn't figure out how to get Nerdtree to work. This video made me realize I just lacked the knowledge of how Vim config works. This video was such a good start because It provided me with the tools to continue my exploration of Vim autonomously. In a week I was already able to install new plugins and tweak them using Lua config files the way I specifically wanted. It's such a cool experience! Keep in mind that both the author of this video and I use Neovim, which is a fork of Vim. As a text editor they both function essentially the same. The difference lies on the config files and in broader UI capabilities by Neovim. While Vim uses Vimscript, Neovim prefers Lua, although Neovim is fully backwards compatible, so you can choose to use Vimscript for your configuration if you want as well. This also means that Vim plugins just work with Neovim! The docs are also a huge source of knowledge for me. In the beginning I resorted to :help key-codes a lot when defining key mappings. To learn the Vim motions, which is the most challenging part of using Vim, I suggest you find a cheatsheet online and refer to it all the time. One very cool plugin that will help you get comfortable with Vim motions is ThePrimeagen's VimBeGod: https://github.com/ThePrimeagen/vim-be-good https://github.com/ThePrimeagen/vim-be-good. It's a set of game-like exercises to practice the motions. This is also pretty cool and helped a lot: https://vimsnake.com/ https://vimsnake.com/. It's a classic snake game where instead of using arrow keys, you use HJKL. And speaking of arrow keys, one thing I did very early on was disabling them (or, in reality, remapping them to noop) in normal mode so I was forced to move around the text using Vim Motions. At first you will get frustrated because your brain will need some time to rewire in a way to absorb all the new abstractions Vim presents. It's a whole new logic of editing text. The most important thing is to stick to it and you will be surprised with how fast you end up picking things up. Of course, don't expect to be crazy fast in a few weeks. But right now, after a little over a month, I no longer feel that discomfort using Vim anymore. I suppose I'd still be faster on VS Code, but I really want to master Vim, so I'm sticking with it and I feel a constant improvement.
- enasterosophes 3y agoCongratulations :) The same thing happened to me about 12 years ago. I'd tried Vim a few times and it didn't grab me, but then suddenly it clicked and I haven't looked back. Not sure if you've seen this, but worth working through, sooner or later (no rush): https://learnvimscriptthehardway.stevelosh.com/ https://learnvimscriptthehardway.stevelosh.com/ A discipline I wished I'd learned earlier was don't let your vimrc grow too big. Instead, keep carving parts of it off into plugins. Track everything in Git.
- worksonmine 3y agoCongratulations, you're in for ride. If you're not on Windows add these 2 lines to your ~/.inputrc to get vim keybindings pretty much everywhere in the terminal (readline based programs): ``` set editing-mode vi Control-l clear-screen ``` Also install vimium[0][1] to get vim movements and some useful keybindings in your browsers. [0]: https://addons.mozilla.org/en-US/firefox/addon/vimium-ff/ https://addons.mozilla.org/en-US/firefox/addon/vimium-ff/ [1]: https://chrome.google.com/webstore/detail/vimium/dbepggeogbaibhgnhhndojpepiihcmeb?hl=en https://chrome.google.com/webstore/detail/vimium/dbepggeogba...
- loughnane 3y agoWhen I dove into vin about a year ago I shortly after added Vimium-ff to Firefox to get him-like keybindings there. Feels great.
- SwiftyBug 3y agoYeah, me too! I also created my own firefox add-on, Hacker News Navigator: https://addons.mozilla.org/en-US/firefox/addon/hacker-news-navigator/ https://addons.mozilla.org/en-US/firefox/addon/hacker-news-n... It allows you to jump parent comments in a Hacker News comment page using either left/right arrow keys or, in Vim mode, h and l. j and k will move the page up and down.