How not to be afraid of Vim anymore

Figure out the command to make them happen!Delete the next 3 lines ( including current line)Copy current word — cursor is at beginning of wordCopy current word — it has special characters — cursor is in the middle of the wordNavigate down 10 linesDelete everything inside the curly bracketsGo up 2 paragraphsPaste the previously selected text 5 times.Edit where the cursor is present: “I can Vim now!”…Wait for it……Here are the solutions:d3jywyiW : the yank inside is to yank inside, and W is inside what to yank ( current word). This is amazingly useful, you can use all sorts of combinations with inside !10jdi} : just like #3.2{ : this was slightly more intuitive. { is to go up a para, } is to go down a para5p : remember the optional numbers from the command anatomy? They can be used almost anywherei I can Vim now! : i is to go into insert mode, then you can work like in a “normal” editorAlright, you made it! Congratulations, this is enough Vim to go about exploring on your own, adventurer. The tutorial is over. Good luck.If someone asks you about Vim, you can do better than using this meme. Explain it to them, or point them here ;)*Note: This is my model of Vim..It isn’t exactly how things work internally..If you look at the documentation ( :help user-manual ), you’ll see that d is the command, and the motion is iw, or “inside word”..There’s a deviation.Why? — because I feel this helps explain better.BonusHere are some extra commands that come in handy:Split screen:vsplit <filename>Creates a vertical splitting..Enables you to copy-paste from one screen to another.To cycle between screen-splits: <ctrl-w> <ctrl-w>Alternatively, you could use the arrow keys / hjkl like so:<ctrl-w> h to go to previous screen.You can close windows as you normally do (:q), or —:only — to close all other windowsMultiple Tabs:tabnew <filename> opens a new file in a new tab on Vim:tabn to go to next tab ( or :gt ):tabp to go to previous tab ( or :gT )Again, you can copy-paste from one tab into another.You can map this combination to a key of your choice too!I tried <Ctrl-Tab>, but that’s already reserved..What a bummer..Instead, we have:map <C-t><left> :tabp<cr>map <C-t><right> :tabn<cr>Which means <Ctrl-t> followed by the left or right arrow key would let you switch between tabs.How exactly did I come up with this mapping?.Check out this tutorial.Other stories in this series:How not to be afraid of GIT anymoreUnderstanding the machinery to whittle away the uncertaintymedium.freecodecamp.orgEnjoyed this?.Don’t miss a post again — subscribe to my mailing list!. More details

Leave a Reply