DEV Community

Cover image for On Learning Vim
Sindbad_X
Sindbad_X

Posted on • Edited on

On Learning Vim

A year ago (I still do), I would get so amazed and overwhelmed watching ThePrimeagen navigate the Vim editor. I wanted to do it as well. But I was too afraid to try it out and thought I wasn’t that smart, and it was too much work to learn something that wasn’t directly adding any value to my programming knowledge. But at the same time, I wasn’t happy with my current VS Code experience, which kept crashing on my machine since I switched to Linux from Windows 11. A few months ago, I said, eff that to my fear. At least I’ll try and see what is this crap that allows Prime’s cursor to move with lightning speed.

Jumping straight into Vim felt notoriously dangerous, so I installed the Vim emulator extension in VS Code.The first two weeks were frustrating and negatively affected the task I was working on. So, after 10-15 minutes of stupidly trying to mimic the daddy Prime, I’d disable the extension and code the old way. Every day for the next two to three weeks, I’d go through this initial ritual where I felt like a total moron for a straight 15 minutes, and then continue my day-to-day programming voyage with Ctrl, arrows, and mouse.

By the end of the third week—I don’t know when or how—but I suddenly found myself being "ONE" with Vim keybindings. The 15-minute ritual expanded a bit longer, and only when I hit a roadblock (for instance, not knowing how to search and replace text) would I find myself needing to revert. But otherwise, I could place my cursor exactly where my eyes wanted it to be with Vim keybindings without thinking or calculating. It felt like this was the right way to navigate the text. I wanted to use it everywhere.

I found this particular written series to be very helpful in explaining all the terminology I needed to know. There are also a few interesting talks from Vim cult members to make you believe that Vim is a real thing, and it’s worth beating your head around.

It’s been more than a month since I started learning Vim. I don’t feel fully confident yet doing development work there, which unfortunately still is React Frontend JS/TS Node. But I’ve set up Neovim (obviously), and I use it for a personal project(Go cli tool) I’m working on these days (I’m unemployed, by the way—so full time on a personal project, so full time on Neovim these days). And I guess configuring Frontend with NeoVim will be an awful experience, so I’ll avoid it totally.

I made a big mistake by blindly installing something called nvchad. It felt like I was back in VSCode, but with a broken experience. The fonts were off, spacing and icons weren’t aligned properly, and overall, it was glitchy. It also felt like magic, which is exactly what I want to avoid.

I’m not interested in ricing Neovim by adding cute icons, customizing fonts, or turning it into a full IDE. My goal is to keep things simple and lightweight, avoid unnecessary configuration, and stick to the core of Vim.

I came across this minimal configuration: kickstart.nvim from Neovim cult member TJ, who’s one of the most referenced figures for setting up Neovim—so it’s worth checking out his work.

The Kickstart config has just enough complexity for me. The config file (init.lua) is well-documented, so I know exactly what each setting does. Great! It also came with a plugin called Telescope, which makes it easier to jump between buffers, search files, change color schemes, and more. (Using Telescope does mean straying a bit from my default-Vim philosophy, but the plugin is so intuitive it feels like a built-in feature, so I'll keep it.)

For file navigation, the builtin explorer, Netrw is good enough. Here's nice cheat-sheet I found. My eyes are too used to the one dark theme from working in VSCode, so I added that for familiarity's sake. For now, my goal is to get efficient with the defaults and avoid extra bloat as much as possible.

From what I understand, learning Vim involves two parts: 1. Vim motions and 2. Configuration, which in itself can take some time. Most people and resources, as I've seen, spend too much time configuring things rather than using the actual editor and trying to get better at it. So, right now, my focus is on Vim motions, because this skill is portable (heck! Even note-taking apps like Obsidian have Vim keybindings). It’s editor-agnostic and makes editing much more enjoyable.


So, where I'm after a month of learning vim?:

  • I know how to quit Vim.
  • Moved past hjkl basics: I now intuitively use commands like $, 0, ^, gg, G, f(x), F(x), Ctrl + e, and Ctrl + u.
  • Switching modes: I switch back to insert mode with i, a, o, and O.
  • Text editing commands: Edit, replace, and change the case of text with gu, gU, r[x], and ciw.
  • Visual mode: Using visual mode to mark text (e.g., vap, vG, v{).
  • Basic search and replace: Searching and replacing patterns (/pattern, %s/old/new/g).
  • Copy, paste, delete: Commands like yy, dd, p, yaw, yap, and daw.
  • Using registers: Copying to and pasting from specific registers (e.g., "ayy, "ap).
  • File management with Netrw: Creating and navigating files.

My fingers have learned these 30-40 keybindings, so now I don't spend an ounce of energy thinking about moving around while writing code, compared to a month ago. What's more amazing is that I didn't try to memorize any of the keybindings (only 5-10), and the rest came intuitively. Now that I'm already comfortable, these days I randomly scan through this cheat sheet and find myself saying, "Oh! That's how you do it."

Overall, learning Vim has been a good experience so far. It’s a pain in the a**s at first—I even dreamed about typing the wrong Vim motion once and woke up with the most violent cramp in my lower leg. I guess it will get better.

Top comments (41)

Collapse
 
tsolan profile image
Eugene

Once upon a time, I’ve decided to learn vim, mostly because of generic key binds which I wanted to apply to vscode via vim plugin (years of using vscode with my own custom ones left me unhappy each time I encountered different environments) and, additionally, some utilities also uses vi by default. I started with vim plugin in vscode, but quickly found myself confused due to muscle memory associated with vscode. Thought to switch to nvim for the time of learning. Having installed nvim, I picked up some tutorials on youtube that carried me through basic setup and explained basics of lua and nvim apis, so I was able to begin practicing. Days were passing by, more and more I was getting used to it as well as bringing more modifications to the interface to fit my needs. Finally, it ended up with almost perfect setup, a great command over the functionality, and a strong desire never ever again to return to vscode at all.

Collapse
 
sindbad_x profile image
Sindbad_X

@tsolan yeah, i couldn't and still find it hard to switch to nvim because the environment is so different out of sudden. I put the one dark theme, and now i feel a little bit less foreign in this new environment. i haven't made the switch entirely to nvim but i can see myself, as you have to reach a perfect setup where i may not want to leave to vs code at all.

Collapse
 
tsolan profile image
Eugene

By now, I have been using nvim for more than a year and since then never launched vscode…

Thread Thread
 
sindbad_x profile image
Sindbad_X

@tsolan go daawg!!!

Collapse
 
rc2168st profile image
rc2168st

Now start using emacs.

Collapse
 
sindbad_x profile image
Sindbad_X

@rc2168st what's that? sound devilish 😈😈😈

Collapse
 
diso profile image
Wayne Rockett

💡Is the reason people in Vim Club always talk about Vim, because they don't know how to quit Vim Club?
Image description

Collapse
 
sindbad_x profile image
Sindbad_X

@diso are you also part of the vim club?

Collapse
 
isaiahhtml profile image
Isaiah

Damn... Then is Vim Club an SCP?

Collapse
 
pengeszikra profile image
Peter Vivo • Edited

Increase your productivity by use VIM motions in shell with this command:

set -o vi
Enter fullscreen mode Exit fullscreen mode

Great to add ~/.bashrc or ~/.zshrc

Need press to ESC to turn normal mode.

Usable moves: 0 jump to first, A jump to end and insert mode. dd delete line, yy copy line, p paste.

Detailed information:
How to use vim motions in shell

Collapse
 
sindbad_x profile image
Sindbad_X

@pengeszikra added it, thanks for the recommendation.

Collapse
 
acudworth3 profile image
acudworth3

Don't be afraid to use a distribution like Astro, lazy or Chad neovim. It's a bit of a short cut but will keep you using neovim quicker. After a while you'll want to do the configs yourself to get it just right (in my experience).

Configuring for front end won't be much trouble if you go that route .

Collapse
 
sindbad_x profile image
Sindbad_X

@acuwebservices so i did started with nvchad, but i felt too much of the overkill and i didn't understand lot of underneath thing. currently, i'm using kickstart.nvim, which uses lazy.

Collapse
 
ddebajyati profile image
Debajyati Dey

I remember more than 1.5 year ago I was stumbled upon the videos of NVChad by Dreams of code(Elliott Minns) on YouTube. I was fascinated by how a terminal emulated text editor be so beautifully elegant, aesthetic yet incredibly efficient, powerful and customizable. I used to use VSCode and Pycharm before that and they had a huge start up time which was annoying. I felt I really need to try Neovim, though I never used vanilla vim before that. I was enrolled in a UG CS degree program and was new to the programming world. I felt it really exciting that a text editor has its own programming language, and the scriptable configurations serve as the settings for it.
Also, git installation wizard tempted me to try Vim by prompting, Vim though very powerful, can be hard to use for beginners something like that. That was the first time I heard about vim. I started with Neovim with NVChad but didn't learn lua even a little bit (at that time) which made it impossible for me to debug the config, when something crashed. After then switched to several preconfigured distributions out there, Astronvim, Lunarvim, Lazyvim, nyoom.nvim, spacevim. Every Config had a different learning curve and at some point, there were different bugs (like error at opening Telescope or opening a file with attached LSP installed) which were not getting fixed for a long time.

I started learning how to be productive in vanilla vim without any plugins, (like opening tabs with :tabnew or :tabe, Texplore and navigating with Ctrl+PageUp Ctrl+PageDown etc. Don't need plugin for managing buffers). Learned the vim motions by keep checking out the cheat sheets sometimes. Still learning. Slowly started configuring it step by step from built-in options to extending with plugins, (setting up LSP with Coc.nvim) and had fun along the way. If you want, I can show my vim config in a comment.

But there was something missing. In the vim plugin ecosystem, there was no terminal plugin like we have toggleterm in Neovim plugin ecosystem. So, I had dived deep in vimscript and wrote my first vim plugin - turboterm.vim. Very minimal but works as per my needs. And I think I need to implement some more features. Will try when I will have time.

After few months I found some interesting Neovim plugins and none-ls came out in way making me really excited to try Neovim once again and build my own config from scratch (I wanted to have Neovim like a full-blown IDE while vanilla vim will be minimal editor). I was watching ThePrimeagen and TJDevries on YouTube from months. Watched two videos of ThePrimeagen from the vim playlist. Went through full the tutorial ( 0 to LSP from scratch ). He was using Packer while I was using Lazy.nvim. When I was almost satisfied with my config, I wanted to keep it as my own pre-configured distro in my GitHub. I named it Efficienvim.

Overall, I'm pretty much content and satisfied with my config.

I have a desire to learn Lua properly so that I can make some unique plugins in the future.

Collapse
 
sindbad_x profile image
Sindbad_X

@ddebajyati you are waaaaay ahead boi! i'm still a timmy. thanks for sharing your story, great read. perhaps turn this long ass comment into a full blog post with all the things you have learned and build. looking forward to it!

i too thinking of diving into Lua, but right now i'm already wrestling with Golang. anyway, learning vim and configuration is on my long term plans, so i've no rush.

Collapse
 
ddebajyati profile image
Debajyati Dey • Edited

Yoh!
Thanks, I may write posts like these in future ✌️🙌

And yes you will be tempted to write plugins in future, if not currently.

You have already done ✅ great work too, learning vim motions is a valuable skill and its universal, available everywhere.

Collapse
 
ezpieco profile image
Ezpie

I have one small tip. Configure vim by yourself, take help from youtube videos or documentation if needed, I know it can be a bit overwhelming but mind my words, you will realize just how crazy it can get, because you made it you know it, as simple as that, at first you might get problems while configuring, but once it's all done using the editor will be a blaze.

Collapse
 
sindbad_x profile image
Sindbad_X

@ezpieco yes that's the right way. i'm actually planning to do that. but before that, i'll need to look at some lua.

Collapse
 
biapy profile image
Pierre-Yves Landuré
Collapse
 
pratapkute profile image
Pratap kute

You're doing great! I'm still battling with Vim—loving the experience, though; it's like a video game, except I occasionally win!

Collapse
 
sindbad_x profile image
Sindbad_X

@pratapkute haha! awesome

Collapse
 
mannuelf profile image
Mannuel

Nice, congrats on two accounts switching to Linux and using VIM. I keep this cheatsheet nearby vim.rtorr.com/

Collapse
 
sindbad_x profile image
Sindbad_X

@mannuelf thanks man. although i haven't mentioned this cheat-sheet here, this is my default reference. i didn't list it because it will probably overwhelm newbies. but once you are past the newbie phase, this cheat-sheet is very very handy.

Collapse
 
tigga73 profile image
tigga73

Read the book practical vim: edit text at the speed of thought, 20 minutes every day during 1 month mades me more faster than the last 9 months using exclusively Neovim

Collapse
 
sindbad_x profile image
Sindbad_X

@sirbabyface thanks, found a pdf version on github. hope i get time to read it.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.