10 Advanced Vim Features (You Probably Didn't Know)

preview_player
Показать описание
In this video, I'm showing 10 advanced Vim features that you likely didn't know yet.

Рекомендации по теме
Комментарии
Автор

A note on recordings (or macros): if you save the macro in the a register, and after using it you realized that you need to correct (or add) one aspect of the commands that you recorded, you can print the a reg in the current file typing "app then you make the changes and to replace the new version of the macro, you can type "ayy. Amazing stuff.

sociologie
Автор

You don't need to use echo to do maths operations in Vim. In insert mode if you type <ctrl-r> = 1+200/4 <cr> you will get the same answer 51 appear in your doc.

For the other example you can store 1 + 2 +...+13 in a register in normal mode:
"lyy (this stores the line in a register called l, l can be any letter)
then in insert mode:
<ctrl-r> = <ctrl-r> l <cr>

Basically <ctrl-r> = in insert mode is how to do maths in vim

To quickly write a list of numbers on separate lines you can (in normal mode) :put(range(1, 10))

not_ever
Автор

It's refreshing to watch someone achieve so much with vanilla vim. It seems to me that today a lot of vim users including me look for plugins to do things instead of combing built in features. The Unix way is infinitely more powerful and adaptable. I learned a few new tricks today, Danke dir!

ThePhiliposophy
Автор

Great video.
You can also use the last technique to increment a whole list, suppose you have:
1.
1.
1.
1.
1.

Then in visual mode you can select from the second 1. to the end and type `g Ctrl-A` and it will increment the list.

pratikmahamuni
Автор

As a daily driver of vanilla vim for years (relatively recent neovim convert), i as not aware that during selection you could run commands (IN VISUAL MODE) with the "!". I've definitely used "command mode" before with the 'bang', but i was not aware of THAT REALLY NEAT TRICK!! Thank you, subbed!

nkodoko
Автор

I'd like to recommend the vim-speeddating plugin. It extends the <c-a> and <c-x> keys to operate on dates, ordinal numbers, and other similar patterns (customizable), and to operate on multiple visually-selected lines at once (creating incrementing lists).

davidh.
Автор

Ctrl-p/Ctrl-n isn't autocompletion. It's completion. The prefix "auto" usually refers to the popup showing up automatically on each keystroke.

Your can use @@ to repeat your latest macro.

While ! is very useful, Vim actually has :sort built in.

You can also use g<C-A> in visual mode to increment numbers in multiple lines linearly

Mawkler
Автор

vim seems like a tool that is always giving features. I have been using vim for years but I always learn something new like in your video here.

MilMike
Автор

These commands work when you're in insert mode:

Type Ctrl-r, then press the = key. Then type in a formula, like 3*3 and hit return. It will insert 9.

Type the beginning of a line that is the same as some other line, for example, if you type "import", then type Ctrl-x Ctrl-l and it will present a pop-up menu with lines already in the file that begin with the same characters as what you've typed. Use Ctrl-p and Ctrl-n to navigate up and down that list, and hit return to insert the desired line.

Ctrl-x Ctrl-f and it will display all the filenames in the current directory. Use Ctrl-p and Ctrl-n to navigate up and down that list, and hit return to insert the desired filename. If you select a path, you can type Ctrl-x Ctrl-f again to navigate one level down in that path.

Ctrl-r % inserts the current filename.

When not in insert mode:

Ctrl-w f will open the file whose filename is under the cursor.

: Ctrl-f will allow you to open and edit the command history, and re-execute a command (or a modified command if you modify it) by pressing return on it.

:r !<command>, and it will insert the results of that command. For example, :r !date will insert the current date, assuming you have the Unix date command in your path.

lylez
Автор

Great video, this is the only place where I could find a great example for the norm command.

Skatox
Автор

I’ve been using vi / vim for 25+ years. Usually when I watch these sorts of videos they are either pretty basic, rely on plugins, or are very niche to one person’s workflow. This one was pretty good and well above the average. gf / gx and being able to handle file encryption are things I didn’t know about that I can certainly see being very useful.

ivanheffner
Автор

The gx command really got me. Thank you.

blessdarah
Автор

I n remapped my arrow keys to navigate between panes and SHIFT left and right arrow keys to scroll through buffers in vim. Super useful. Also considering SHIFT up and down for navigating local marks.

devlinbowman
Автор

What an exceptional video! I have hours of watch time on the topic, but this is gold! Thank you for teaching me things that will improve my life. You are a true professional and you inspire me

avnerduchovni
Автор

Great stuff! Followed along. Some stuff is new; some I'd forgotten. Will have to do it every day for a while to retain the info.

bicycleninja
Автор

The feature of writing to the end of line was all what I was looking for, many many thanks. keep these amazing tips and tricks posted always,

Ghasakable
Автор

You can apply-repeat your macro from the cursor until EOF via:

VG:normal @x

Where x is your chosen macro ('a', in this video)


You Visually select until the End Of the File (G), then apply the "normal @x" command.

NostraDavid
Автор

not just nice to know but incredibly productive when built in muscle memory, esp sending vim buffer in and out the unix cli pipelines

dankrukov
Автор

First, great video. I love your presentation. It's high quality. Thank you. I liked and subscribed with notifications. Would you mind making a video showing what tools you use to make your tutorial videos? I imagine you're using OBS Studio? It would be nice to see your setup and process.

I do think it would be helpful if you would index your content in the comments of you post. I'm providing it for this video below:

0:28 - Auto-complete
1:50 - Buffers
4:02 - Recordings
6:32 - : normal
9:07 - : ! command
11:18 - Open files /URLs with gf / gx
12:36 - Encrypting files with :X
0:28 - Auto-complete
13:55 - AutoSource
16:00 - Spell Checking
18:10 - Arithmetics

elliothuntington
Автор

you can check surround commands to (y)add, (d)remove or (c)change brackets around a text object and it is repeatable too

anuragbisht