30 Vim commands you NEED TO KNOW (in just 10 minutes)

preview_player
Показать описание

**This video was sponsored by Brilliant**

We've got a slew of shorts on Vim tricks but in this episode, we're going hard in the paint with 30 Vim commands you NEED TO KNOW. In ten minutes, your neckbeard will grow faster than ever before.

Let's get after it.

Chapters:
0:00 - intro
1:00 - search and replace
3:30 - visual higlighting yanking, registers
6:20 - special registers
8:20 - macros!
Рекомендации по теме
Комментарии
Автор

/g in sed command means global in line, not in entire file. So without /g replacement will be done for the first occurrence in each line where we have matching

luski
Автор

If you already have it already highlighted by the *, you can simply :%s//replacement/g, you don’t have to repeat what was highlighted

EdygarOliveira
Автор

Did you know you can append to a named register? “xY will yank the current line into register x. “XY will append the current line to register x. This lets you build up a register to paste later. For example: you want to grab a couple lines of code from several locations and paste them into a new function, you can gather them all into that register and then do one paste when you have them assembled.

Also, because a macro is just executing a register, you can edit a macro by pasting the contents of the register, modify it, then yank the new macro back into the register ready to run the modified macro.

One last item: a macro can call another macro or even itself. Writing recursive macros to update thousands of lines can be quite satisfying, but is most useful if making a regex substitution is just too difficult or not quite fully repeatable.

ivanheffner
Автор

🚨 I misspoke!! 🚨

Typically with Vim videos, I tend to do them from top-of-my-head knowledge. For some reason, I always think of the "substitute" command as "sed".
"s" is substitute, not "sed" sorry for any confusion, hope you like the video!!

typecraft_dev
Автор

I am a beginner, I hated VIM at first and I told myself I would never touch it again. But I kept learning things little by little. Your channel helped me a lot, it has made me fall in love with VIM. I am also following your playlist to learn to make my own Neovim config. Thanks nerd!

priyanshukatuwal
Автор

v + i + w + y (to copy the selected word) can be done with y + i + w (yank inside word)

WhiteRickRoss
Автор

<C-^> will toggle between the current and previous buffers, you can mash it to go back and forth kinda like harpoon. Also <C-o> lets you go backwards in the jump table if you wana navigate back a line or two or three etc.

holdthat
Автор

Hi! I’m a content creator in the same space, and I really appreciate the quality of your videos and the work it requires to create them. This video is a great guide for beginners and showcases the power of vim editing in such an effortless way, Keep up the good work!

mischavandenburg
Автор

this was a WICKED useful vid. getting into nvim slowly and this really helped me lvl up

amarug
Автор

Best vim learning serie in Youtube! BTW loved your Patagonia t-shirt, cheers from Argentina

sebastianalfaro
Автор

Good stuff, thank you! I’ve been waiting for a part two hoping that will cover multiline cursors tricks that I still struggle with 😊

abderrahmanesmimite
Автор

Thanks, learned some new things! You can also create an autocommand to briefly highlight whatever you're yanking. Then you don't need to go into visual mode first.

tenminuteamateurhour
Автор

Great tips!

With macros you can do @@ to replay last played macro.
Also while recording a macro, .you can also replay that macro inifonitely until vim.encounters an error.
I.e. for your example
qah //start recording into h
i"<escape>E", <eacape> // addquotes around word, then add comma
@h //.start replaying entire macro recursively, i.e. this will keep replaying the 'h' macro until error encountered.

A couple more register tips.
Add to init.vim or .vimrc
set clipboard unnamedplus
//Always yank/paste from system clipboard.

One register tip:
"_d //delete without overwriting default register
In visual mode.ypu can do P to paste without overwriting.

Here's a couple other honorable mentions.

Use the global command to delete all lines containing search.
:g/search/d
And its inverse (delete lines not containing search)
:!/search/d

jamesaffleck
Автор

This was exactly what I was looking for! I've been using vim for the last 10 years, but ive always used the basics and what I have to use to get the job done. This is going to take me to the next level. Your videos are amazing, and I thank you for them!

RuanBekker
Автор

Great video, as always! One quick note - ":s" stands for "substitute" in command mode.

afzalhussain
Автор

Thanks for the stuff about registers. Ive been heavily using vim for 3 months and hadnt come across the need for it, but i can see where it will be useful

kevinrineer
Автор

%s already targets the whole file, the /g (global) replaces every occurrence of the word, not just the first of every line
Super helpful video though! Didn’t know how to use registers, thanks a lot!

NilEoe
Автор

I’ve been using nvim for over a year and learned multiple things from this video. Thanks so much!

danks
Автор

Some of these are really a life saver, great video.

MR_Stick
Автор

bring the part 2 with more 50 commands

code-island