I have recently started using Vim for full time in my work(inside my IDE). Initially it was bit hard, I had to consciously decide whether to press
l. I tend to touch the mouse often, but now, after some practice, I feel very productive. I’m not a pro, but I’m documenting some of my thoughts, experience hoping it’ll help someone.
The first time I heard about Vim, I didn’t bother to learn it. My to-learn list was already filled with higher priority items. Recently I came across a screencast where Kent C. Dodds did some magical stuff, and then suddenly Vim became my the highest priority to-learn item.
If you’re into DevOps or SRE(Site Reliability Engineering) then knowing Vim will help you a lot, almost all Linux flavors have Vi/Vim baked in it.
If you’re an application developer, learning Vim is not mandatory. It’s just a syntatic sugar, most of the stuffs you can handle through your IDE keybindings and other plugins. However, learning Vim boosts the productivity and pays off in time.
Some senior developers will not accept you as a true developer if you don’t know Vim 😅.
If you are pretty comfortable with your main technology stack, already know your IDE keybinding to surround a code block or already using
acejump, then you might want to give Vim a try.
If you don’t have at least a year of coding experience, and you’re in a doubt whether you should learn Vim, you might want to visit this topic sometimes later.
If you like your IDE very much, not to worry, you don’t need to move away from your IDE. You don’t need to unlearn your favorite shortcuts as well. You can use Vim within your IDE, and get the best of both worlds. I’m also currently using Vim within my IDE.
I heavily use JetBrains products, JetBrains has
ideavim plugin. VS Code, Atom also have similar plugin. Some IDE shortcuts will conflict with Vim. In that case, we need to configure our IDE Vim plugin to pick either the IDE/Vim action. I’ll write another post to set up Vim in JetBrains, VS Code.
While using Vim inside IDE is cool, you might want to practice in the Vim editor first! IDE plugins have some limitations. Also, some IDE shortcuts might conflict with Vim. Using Vim editor will make the learning experience smooth.
Most of the time the answer is yes. However, Vim is not an IDE, while we can add Vim plugins and make it more powerful, I don’t think it’s a replacement for IDE. Things get interesting when we use Vim within our IDE.
There’s a lot to learn in Vim. People say this is the case even after years of experience 🤷♂️.
Learning Vim is a process, we need to train our muscle memory through practice, it’ll take some time, and don’t expect to get immediate results.
As I remember, in my first two weeks I felt less productive. I had to spend some time practicing Vim in personal projects before using in my office work.
Having said that, don’t let this fact stop you from acquiring a valuable skill.
Don’t know how to add multiple cursors, no problem, note it down, google it, practice a few times, you will begin to love Vim.
As we use Vim, we’ll soon realize that we frequently press
Esc to switch to
Esc key is quite away from our hand it’s a good idea to map
Esc action to
Caps Lock which we don’t frequently use.
In Windows, we can use SharpKeys.
let mapleader=","let g:EasyMotion_smartcase=1nmap s <Plug>(easymotion-s)map <Leader>j <Plug>(easymotion-j)map <Leader>k <Plug>(easymotion-k)set hls is ic surround easymotionset clipboard+=unnamedset keep-english-in-normal-and-restore-in-insert
^- move to the first non-blank character in the line
$- move to the last character in the line
[N]f[char]- move to the Nth occurrence of [char] to the right
[N]F[char]- move to the Nth occurrence of [char] to the left
[N];- repeat the last "f", "F" action N times
[N].- repeat the last "f", "F" action N times in opposite direction
:[N]- go to the first non blank character on line number N
/[text-to-search]- forward search
?[text-to-search]- backward search
n- repeat last search
N- repeat last search in reversed direction
w- move to the beginning of next word
e- move to the end of word
G- move to the end of the file
gg- move to the beginning of the file
*- move to the next occurrence
#- move to the previous occurrence
diw- delete word
dd- delete line
yiw- copy word
P- paste before the cursor
ciw- change word
ctrl + v- select block
[N][h/j/k/l]- left/down/up/right by N characters