
Vim Can Save You Hours Of Work DistroTube
video description
Date: 2022-03-30
Related videos
Comments and reviews: 10
DaveCraft
Even though there are Editors out there without these features, they are rarely used. I use VSCode and it features quite similar workflows, but using a series of hotkeys, instead of short commands. I think it might interest some, how to achieve these things in VSCode, so I gathered a bit.
Everything shown in the video with standard features in VS Code and also just using the keyboard:
Most important hotkey: Open Command Palette: Ctrl + Shift + P (or Ctrl + P, >)
Cutting current line: Ctrl + X (without selection)
Pasting current line: Ctrl + V
Moving line (selected lines) up and down: Alt + - / -
Go to line # (column #): Ctrl + G, insert line (and column, separated by a comma or colon)
Go to the last line: Ctrl + END
To move the line containing a word, we would first select the word using some of the following commands (I wanted to show them all):
Finding something: Ctrl + F (single File), Ctrl + Shift + F (multiple Files)
Find and Replace: Ctrl + H (single File), Ctrl + Shift + H (multiple Files)
Toggle find in selection-: Alt + L
Select occurrences of current highlight/selection: Ctrl + Shift + L
We would start by selecting an occurrence: Ctrl + F, -Ultimately-, (navigate through occurrences using Enter and Shift + Enter), Esc (you now have the occurrence selected);
or by selecting all occurrences: Ctrl + F, -Ultimately-, Ctrl + Shift + L, Esc (now all occurrences are selected)
You can now move the line using Alt + - / - or using Ctrl + X and Ctrl + V after collapsing the selection(s) using - and navigating freely in-between.
If you want to move an offset line, just move the cursors using - or - after selecting the occurrences.
Previous cursor position: Ctrl + U
(I don't know a default way of selecting lines given a range of line numbers in VSCode)
Add cursor above/underneath: Ctrl + Alt + - / -
Select region: hold Shift while Navigating (for bigger regions, use Ctrl + End to jump to the end of the document, or PageDown to jump to the end of the current screen).
Indent lines: Ctrl + L (selecting the line) + Tab
Unindent lines: Ctrl + Shift + /
Deleting the double quotes 1: Using 'Ctrl + Alt + - / -' to place cursors at all the opening quotes (just like he did) and then remove the quotes, the linebreak (now everything is in one line and the cursors are placed after each former element), and the closing quotes, and add the linebreaks back again.
Deleting the double quotes 2: Making a selection of the whole list but the first and last double quotes holding down shift and navigating from one end to the other, and then: Ctrl + H (Find and Replace), Alt + L (toggle 'find in selection'), [Alt + R (toggle RegExp if not already active)], insert '-\n-' (Finding the doublequote pairs separated by a linebreak), Tab (now inserting the replacement), insert '\n' (only the linebreak), Ctrl + Alt + Enter (replace all)
Adding the double quotes 1: Make a selection as you did in 'Deleting the double quotes 2' except for the last line and then: Alt + Shift + I (adds a cursor to the end of the selection in every line and removes the selection), End (goto end of line in every line), - (adding the closing quotes to every line end), - (going to the beginning of the next line), - (adding the opening quotes to every start of every line)
Adding the double quotes 2: Make a selection as you did in 'Deleting the double quotes 2' and then: Ctrl + H, Alt + L, [Alt + R], insert '\n', Tab, insert '-\n-', Ctrl + Alt + Enter.
Note: You don't need RegExp to add the linebreak via \n, but you can also add a linebreak using Shift + Enter or Ctrl + Enter.
I only know of snippets for vim abbreviations, but they are not created that quickly, but it's not hard either. There are also extensions helping with that. If you are writing a long word multiple times, VSCode should suggest it to you anyways, as you start writing it the second time.
Note: if VS Code (or other Microsoft Applications) autocomplete/autoformat something for you and you didn't want that to happen, press Ctrl + Z right after that to undo only that and continue.
Focus the Terminal to run shell commands: Ctrl + Shift + P (Command Palette), insert 'Focus Terminal', Enter.
(You might assign a hotkey to that)
If you try to save a file and don't have the permissions, VSCode will ask you if it should retry as admin or 'safe as'.
Features using the mouse: You can add arbitrary cursors and selections anywhere using Alt + LeftClick. You can make a rectangular selection everywhere using Shift + Alt + LeftDrag or using Ctrl + Shift + Alt + Navigate.
- while Searching via Ctrl + F or Ctrl + H
reply
Even though there are Editors out there without these features, they are rarely used. I use VSCode and it features quite similar workflows, but using a series of hotkeys, instead of short commands. I think it might interest some, how to achieve these things in VSCode, so I gathered a bit.
Everything shown in the video with standard features in VS Code and also just using the keyboard:
Most important hotkey: Open Command Palette: Ctrl + Shift + P (or Ctrl + P, >)
Cutting current line: Ctrl + X (without selection)
Pasting current line: Ctrl + V
Moving line (selected lines) up and down: Alt + - / -
Go to line # (column #): Ctrl + G, insert line (and column, separated by a comma or colon)
Go to the last line: Ctrl + END
To move the line containing a word, we would first select the word using some of the following commands (I wanted to show them all):
Finding something: Ctrl + F (single File), Ctrl + Shift + F (multiple Files)
Find and Replace: Ctrl + H (single File), Ctrl + Shift + H (multiple Files)
Toggle find in selection-: Alt + L
Select occurrences of current highlight/selection: Ctrl + Shift + L
We would start by selecting an occurrence: Ctrl + F, -Ultimately-, (navigate through occurrences using Enter and Shift + Enter), Esc (you now have the occurrence selected);
or by selecting all occurrences: Ctrl + F, -Ultimately-, Ctrl + Shift + L, Esc (now all occurrences are selected)
You can now move the line using Alt + - / - or using Ctrl + X and Ctrl + V after collapsing the selection(s) using - and navigating freely in-between.
If you want to move an offset line, just move the cursors using - or - after selecting the occurrences.
Previous cursor position: Ctrl + U
(I don't know a default way of selecting lines given a range of line numbers in VSCode)
Add cursor above/underneath: Ctrl + Alt + - / -
Select region: hold Shift while Navigating (for bigger regions, use Ctrl + End to jump to the end of the document, or PageDown to jump to the end of the current screen).
Indent lines: Ctrl + L (selecting the line) + Tab
Unindent lines: Ctrl + Shift + /
Deleting the double quotes 1: Using 'Ctrl + Alt + - / -' to place cursors at all the opening quotes (just like he did) and then remove the quotes, the linebreak (now everything is in one line and the cursors are placed after each former element), and the closing quotes, and add the linebreaks back again.
Deleting the double quotes 2: Making a selection of the whole list but the first and last double quotes holding down shift and navigating from one end to the other, and then: Ctrl + H (Find and Replace), Alt + L (toggle 'find in selection'), [Alt + R (toggle RegExp if not already active)], insert '-\n-' (Finding the doublequote pairs separated by a linebreak), Tab (now inserting the replacement), insert '\n' (only the linebreak), Ctrl + Alt + Enter (replace all)
Adding the double quotes 1: Make a selection as you did in 'Deleting the double quotes 2' except for the last line and then: Alt + Shift + I (adds a cursor to the end of the selection in every line and removes the selection), End (goto end of line in every line), - (adding the closing quotes to every line end), - (going to the beginning of the next line), - (adding the opening quotes to every start of every line)
Adding the double quotes 2: Make a selection as you did in 'Deleting the double quotes 2' and then: Ctrl + H, Alt + L, [Alt + R], insert '\n', Tab, insert '-\n-', Ctrl + Alt + Enter.
Note: You don't need RegExp to add the linebreak via \n, but you can also add a linebreak using Shift + Enter or Ctrl + Enter.
I only know of snippets for vim abbreviations, but they are not created that quickly, but it's not hard either. There are also extensions helping with that. If you are writing a long word multiple times, VSCode should suggest it to you anyways, as you start writing it the second time.
Note: if VS Code (or other Microsoft Applications) autocomplete/autoformat something for you and you didn't want that to happen, press Ctrl + Z right after that to undo only that and continue.
Focus the Terminal to run shell commands: Ctrl + Shift + P (Command Palette), insert 'Focus Terminal', Enter.
(You might assign a hotkey to that)
If you try to save a file and don't have the permissions, VSCode will ask you if it should retry as admin or 'safe as'.
Features using the mouse: You can add arbitrary cursors and selections anywhere using Alt + LeftClick. You can make a rectangular selection everywhere using Shift + Alt + LeftDrag or using Ctrl + Shift + Alt + Navigate.
- while Searching via Ctrl + F or Ctrl + H
reply
No
Most of the people commenting learning VIM is useless, a waste of time or hard. They didn't understand really the power of it. It's not just looking like a wizard or wining hours of work. Even tho that's what this title says. It's reliability, interopability and comfort for someone who pass alot of it's time on a computer.
You don't need to use VIM or clones to profit. VIM shortcuts are a standard in the computer world since 50 years. You can be sure almost every serious computer programs (especially for development) got them integrated or via an extension. And once you know them you can use them everywhere or almost.
I switched to Android development recently, in like 2 mins I was like at home after installing one extension in Android Studio. Even to navigate in a web browser.
And for those who didn't understand what a modal editor like vim is. It does mean you don't have to learn thousands of commands. But just how the letters interact with each others.
You learn a new keycharacter you can mix it with everything you already know. If you have learned that the keyword -c- stands for change, -i- for inside and -w- for word... Then -ciw- is to replace what is in a word, and if 2 mins later you understand that the keycharacter -d- stands for delete then you already know that -diw- will delete what is inside the word. -C- to change a whole line ? then -you know -D- will delete it. Intuitive and not hard like almost every non users says. And to be really honest what you will learn in the vim tutorial which is finished in 30 mins is already way more than enough to use it correctly. And once in a while you will discover a knew keycharacter.
To finish almost all the sorcery you have seen there, could have been done way faster way simpler...
reply
Most of the people commenting learning VIM is useless, a waste of time or hard. They didn't understand really the power of it. It's not just looking like a wizard or wining hours of work. Even tho that's what this title says. It's reliability, interopability and comfort for someone who pass alot of it's time on a computer.
You don't need to use VIM or clones to profit. VIM shortcuts are a standard in the computer world since 50 years. You can be sure almost every serious computer programs (especially for development) got them integrated or via an extension. And once you know them you can use them everywhere or almost.
I switched to Android development recently, in like 2 mins I was like at home after installing one extension in Android Studio. Even to navigate in a web browser.
And for those who didn't understand what a modal editor like vim is. It does mean you don't have to learn thousands of commands. But just how the letters interact with each others.
You learn a new keycharacter you can mix it with everything you already know. If you have learned that the keyword -c- stands for change, -i- for inside and -w- for word... Then -ciw- is to replace what is in a word, and if 2 mins later you understand that the keycharacter -d- stands for delete then you already know that -diw- will delete what is inside the word. -C- to change a whole line ? then -you know -D- will delete it. Intuitive and not hard like almost every non users says. And to be really honest what you will learn in the vim tutorial which is finished in 30 mins is already way more than enough to use it correctly. And once in a while you will discover a knew keycharacter.
To finish almost all the sorcery you have seen there, could have been done way faster way simpler...
reply
Kaerith
-can your editor compete-
I don't care about competition, and I like gui and easy to use stuff without having to read shitton of documentation to learn how to use it each time I want to try something new in it.
I just click, and it appears, it's magic, it's efficient, that's what a tool is for, you use it directly.
But when you have to work on your tool first instead of your work there's a serious problem.
I understand that ton of people want to do things in the most hardest way possible just so later they can say 'eh I use vim lol, so elite, it just took multiple months of hard work to learn how to make a thing I could have done in 10 seconds in a gui but I dooooon't regret haha, so efficient haha, ha...'
What a meme, that and emacs, it's even worst than -install gentoo-
But if you -would like to interject-, do it I don't mind, but do it the hard way, do it with lynx please.
lol
reply
-can your editor compete-
I don't care about competition, and I like gui and easy to use stuff without having to read shitton of documentation to learn how to use it each time I want to try something new in it.
I just click, and it appears, it's magic, it's efficient, that's what a tool is for, you use it directly.
But when you have to work on your tool first instead of your work there's a serious problem.
I understand that ton of people want to do things in the most hardest way possible just so later they can say 'eh I use vim lol, so elite, it just took multiple months of hard work to learn how to make a thing I could have done in 10 seconds in a gui but I dooooon't regret haha, so efficient haha, ha...'
What a meme, that and emacs, it's even worst than -install gentoo-
But if you -would like to interject-, do it I don't mind, but do it the hard way, do it with lynx please.
lol
reply
GK
I love the self-righteous Vim neckbeards thinking Vim is the only editor with functions and macros. Find and replace? How about find within a project? Find within a directory tree matching X extensions? Pycharm can do it, but I doubt Vim can. What about autocompletes? Even basic text editors like Atom and Sublime do it, but not Vim. Code linting? Integrated VC? The things Vim is unique with are so niche that it's ridiculous to consider it an option in the modern world :)
Not to mention the -time saved- is offset by a large margin of -time wasted- learning it. Imagine you spend a month learning Vim (which is an understatement)... Think of what you can do with that time in that month. And you'd learn Vim so you can get 5 mins of extra work done per day, if that
reply
I love the self-righteous Vim neckbeards thinking Vim is the only editor with functions and macros. Find and replace? How about find within a project? Find within a directory tree matching X extensions? Pycharm can do it, but I doubt Vim can. What about autocompletes? Even basic text editors like Atom and Sublime do it, but not Vim. Code linting? Integrated VC? The things Vim is unique with are so niche that it's ridiculous to consider it an option in the modern world :)
Not to mention the -time saved- is offset by a large margin of -time wasted- learning it. Imagine you spend a month learning Vim (which is an understatement)... Think of what you can do with that time in that month. And you'd learn Vim so you can get 5 mins of extra work done per day, if that
reply
Ono
You can search in YT for examples an comparations with a normal usage, and you can find nothing. Because vim is just a new little gimmick, a new trend of the boys of silicon valley. If you make a direct comparisson, it will show that vim is not that useful or -fast-.-
-Take minutes to remove what I've done in 5s-, give me a break, hit replace in keyboard, -, click and hold the replace until the end. Speedier than vim. I stopped the video on that one.
Oh, normal editors can have macros too, vertical selection too, oh god...
reply
You can search in YT for examples an comparations with a normal usage, and you can find nothing. Because vim is just a new little gimmick, a new trend of the boys of silicon valley. If you make a direct comparisson, it will show that vim is not that useful or -fast-.-
-Take minutes to remove what I've done in 5s-, give me a break, hit replace in keyboard, -, click and hold the replace until the end. Speedier than vim. I stopped the video on that one.
Oh, normal editors can have macros too, vertical selection too, oh god...
reply
Cero
I will probably end up learning vim anyway, but I find it a bit discoursging how almost everytime someone comes telling how vim is so superior to other programs and it will save you thousands of hours they end up giving some examples that could essily be done in typical programs just as fast, like the example about deleting the double quotes, I could do that in a couple seconds in any editor with multicursor, faster than using a macro.
They are just as ignorant about standard editors as we are about Vim.
reply
I will probably end up learning vim anyway, but I find it a bit discoursging how almost everytime someone comes telling how vim is so superior to other programs and it will save you thousands of hours they end up giving some examples that could essily be done in typical programs just as fast, like the example about deleting the double quotes, I could do that in a couple seconds in any editor with multicursor, faster than using a macro.
They are just as ignorant about standard editors as we are about Vim.
reply
Super
I know I need to use VIM to fix something on Mars using a terminal,
But I'm not going to fixing something on Mars anytime soon.
No thanks and I'll save myself 10x times of hours of work using VSCode.
Stop being stubborn and proceed with something modern and much more automation instead.
Remembering useless hotkeys with nonsense bindings which has absolutely NO use in any other programs? Just WOW.
reply
I know I need to use VIM to fix something on Mars using a terminal,
But I'm not going to fixing something on Mars anytime soon.
No thanks and I'll save myself 10x times of hours of work using VSCode.
Stop being stubborn and proceed with something modern and much more automation instead.
Remembering useless hotkeys with nonsense bindings which has absolutely NO use in any other programs? Just WOW.
reply
ChupoCro
Vim really is powerful for editing files in terminal when connected through SSH but it can't compare with e.g. Visual Studio Code + Platformio when developing firmwares for embedded devices or with just Visual Studio Code when writing code in any programming language.
reply
Vim really is powerful for editing files in terminal when connected through SSH but it can't compare with e.g. Visual Studio Code + Platformio when developing firmwares for embedded devices or with just Visual Studio Code when writing code in any programming language.
reply
Ye
I think vim people are tunnelvisioned. They underestimate the power of arrow keys with combination of alt, shift and ctrl keys (also it works literally everywhere). More simplicity operating a text editor = more time actually focusing on a task.
reply
I think vim people are tunnelvisioned. They underestimate the power of arrow keys with combination of alt, shift and ctrl keys (also it works literally everywhere). More simplicity operating a text editor = more time actually focusing on a task.
reply
JustSlingingThings
Anyone used vimium add on for firefox? It's basically vim bindings for web browsing, you can hit links by using easymotion like search, just hit f(two letter pattern). It's absolutely fantastic, super fast and no mouse needed.
reply
Anyone used vimium add on for firefox? It's basically vim bindings for web browsing, you can hit links by using easymotion like search, just hit f(two letter pattern). It's absolutely fantastic, super fast and no mouse needed.
reply
Add a review, comment
Other channel videos















