vab - selects content within parenthesis () along with it vib - selects only the content within parenthesis vaB - for {} vib - for {} % will help to jump between matching brackets, tags for that matter anything D - deletes from cursor position to the end of the line Y - copys till the end of the line xp - really helpful to swaps letter like , bnigo --> bingo gj - normally vim skips the line if its wrapped. gj helps to go down for that gv - selects the previously selected part in visual mode. gf - jumps to the file when on the file path. For Web developers cit will jump into the tag. vit will juno into the tag in visual mode
Long time vim user here, here are some commands I can't live without that weren't mentioned: 1. Use A key to goto the end of line and I key to go to the start of the line. 2. The f key and t key to navigate in normal mode and to manipulate text in inset mode(paired with the c and d key). 3. Use "ciw" instead of "diw" to delete and go to insert mode. 4. Bind "jk" and "kj" to so you can save your pinky. 5. The C key, D key and "cc". After 20 years of using vim, my advice is to try to stay in normal mode as much as possible, and you'll find yourself blazing fast.
New vim user here! I use neo vim with auto completion especially for C. My biggest frustration is that I make a lot of errors in insert mode. And I always feel and tend to using the the Arrow Keys to fixing these errors which could be typos. Secondly neo vim auto completes parenthesis and and makes my cursor inside it! How do I get outside those parenthesis or any blocks without using arrow keys without escape (I tried ctrl+o but that's also bit hard). Any tips on how u proceed in these situations? What do u use for auto completion (tab/enter or ctrl+y)?
Wow I didn’t know about capital i that is a life saver. I remapped caps lock to esc on tap and control on hold, do you think my pinky will still hurt in the long run compared to using the actual escape key(most top left key on keyboard) to escape. Been using vim for 3 months and I love it. I already feel like I move way faster than with keyboard and mouse.
in vim there is actually a lot of things you can do diw - delete inside word (delete a word) daw - delete around word(deletes a word including the whitespace) you can also use 'W' it will also do the same but it will consider a word as a collection of characters surrounded by whitespace di{ - delete the content inside {} di( - delete the content inside () da{ - delete inside {} including the {} like this there are more (di", di'..etc) instead of i (inside) or a (around) you can also use s ( surrounding ) it will delete the surrounding characters you are mentioning most of these is useful for programmers instead of d you can use c ( c stands for change ) it will go to insert mode after the operation is done, but d will stay in normal mode use y instead of d and c, then you are doing yanking (copy) all the other are same also you can use v (it is for visual mode - for selecting text) for line search you can use f and F, it will find a purticular character in a line and then you can use ; and , to move forward and backword through that search character if there is more, f is for searching after and F is for searching behind also there is t and T - f stands for find, and t stands for till it will also find but wont go to that character, instead a character behind the actuat character you are mentioning, it will make sense when you do operations like delete, for example you can do dta ( it will delete the characters from where you are till the character 'a' or delete till character 'a') if you use f then the character a will also be deleted. instead of line you can search in entire document using /searchword and ?searchword (/ is for searching forward and ? is for backword) then you can use n to move throught that search forward and N for backword next time if you want to search the same keyword or searchword just press / and enter for the basic movement you can use j (down), k (up), l (right), h (left), all the keys are available in home row then moving faster using w - word -> word -> word e - end of each word b - move word backword or beginning you can also use numbers, it can be considers as a multiplication, if you do 2j it will jumb two words down (nj , where n is a number) this is not only possible with j k l h , but also with almost every command i have told earlier for example i need to delete two word then i can do d2w..etc there is also combination of commands like dd, yy, cc...etc dd will delete a line yy will yank(copy) a line cc will delete a line then go to insert mode ( while d stay in normal mode) this can also be combined with number like 2dd ( delete two line or d2d...etc) for doing number combined operations it is better to do set the numbering to relative rather than normal numbering, don't get what i said, right? just look at the video, he is using relative numbering rather that continueous, for that just do :set relativenumber ( we are now using ex commands, ex commands starts with a : ) you can use :edit or :e for creating or editing file eg. :edit newFile.js will create a file if not exist in the current path or will go to edit the purticular file if exist you can do :w for writing the file :q for quiting the file or just :wq for write and quit also you can do global replacement in the document by using :%s/textThatShouldBeReplaced/newText now how can we move from normal to insert mode, most of the people will do ( i ) but there are more i - insert mode ( it will put the cursor before the character you are in) a - around ( it will put the cursor after the character you are in) I (capital i ) for insertig at the start of line A - insert at the end of line these are used to go from normal mode to insert mode, where you can type like you do in a normal text editor... use % for going to end of line and ^ for going to start of line (where first character starts) 0 for going to actual starting position or 0th column esc, control + c, control + [ --- can be used to go to normal mode from insert mode there is a lot like this... some tips from me : you can remap the key binding as you want, but if you are a programmer and you are using different text editrors then it is not recommended.... the reason is, i am using vs code as my main text editor for all my works, i often use ide's.... so when i am using other editors or using the computer of someone else, it is really hard because in first i have remapped my keys in different way because some of them are not acceptable for me, like the esc key, are you kidding me, i can't even reach the esc key, so i remapped it into jj, so i just need to type jj to go to normal mode, now it is pretty much easy, but the problem will really happen when changing editor or computer because the remapping json file is in my computer or in the vs code and it is a bit time comsuming to set up or just add all those keybinding to other editors or ide's and it may be easy for vs code configuring but not for other ide's, it is sure that vim extension is available at almost everywhere, but the remapping is done in different ways in different application, this problem happended to me when i have used the android studio, vim is available there in the name of ideavim, but i dont know how to configure or remap the keys or else you need understand it in the way of vim, because i guess vim offerese key remapping commands so you just need to use some ex commands to do that, but on that time learning any of this is time comsuming, also when i use others computer i use jj all the time to go to normal mode, and then it will print to screen because vim is not installed on there computer and even if it is installed, i need to remap it, if the remapping is not needed, then i could have been installed vim and used on there computer. do you know how harder it is to use the arrow keys to move around if you are a vim user, so all of the things above mentioned can be avoided by simply using default configuration. and i am now using default configuration. using touch typing + vim + some practice you can become god in handling file and text. nobody will even get understand what you are doing, they will be amazed of yours speed. im on the way to become that god, just need to have some practive because i have changed on the default configuration in the last week, also vim is really good for touch typers.... because they don't like to leave from there home row like me....☺
Indenting python scripts with = is difficult because the indentations define the ends of blocks. In bash you have keywords to define both ends of a block, and in C-family syntax it's curly braces. So the indentation itself carries non-superfluous meaning in Python, while in many other languages it can be unambiguously determined by the code in the immediate surrounding. Using c (for "change") instead of d (for "delete") puts you right into insert mode after the deletion, no matter what kind of deletion you do. And when deleting a word, note that dw and cw only delete from the cursor and out. daw and caw take the entire word. Finally, da" includes the quotation marks, as opposed to di".
One thing I like a lot is pressing f and then a character to find the next instance of the character in that line, and F to find the previous one. This also works with delete: df( will delete everything from your cursor to the first opening parenthesis it finds (including it). And t can do the same, but stopping before reaching the character: dt( will delete from the cursor to the character before the next parenthesis and dT( will delete from the cursor to the character after the previous parenthesis. Edit: Forgot to mention, you can use I (capital i) to enter insert mode at the beginning of the line (technically, before the first non-blank character) and A to enter insert mode at the end of the line.
Hi derek! Linux user from spain here, sorry if my english is a little basic. I started learning vim (and awesome wm) with your videos (i've thought on learning it many times before and ended up not bothering) and i am loving how versatile it is, i never understood why it was so 'famous' until now. Thanks for sharing your knowledge on this, i am enjoying like a child with your content. And also thanks for sharing the keystrokes on this video, it was so helpful
f and F (t and T) to find characters in line. Then repeat with ; or ,. Can also combine with visual/delete/replace commands. g; and g, to move among the recent changes. ctrl+v for visual block. ctrl+a and ctrl+x for advancing and decreasing a number (including dates with the speeddating plugin!) . to repeat the last action. Macros. An additional level of zen power. Programmed hot keys with space being the leader. Can add signatures, insert timestamps, open file read-only in new tab, call a function, a compiler or a script on the file (LaTeX it, calculate math expressions from within Vim, search for certain patterns).
Ctrl + c serves the exact same function as the ESC key but you don't have to move your hands to execute. Similarly, Ctrl + i performs an indention. Really handy when the tab key is just bouncing you around or if you want to keep your hands on the main keys
not exactly, if you have something bound to work on switching to normal mode, or just escaping, it will not trigger when pressing ctrl + c. ctrl + [ on the other hand works exactly the same as ESC key
Gotta spread that Vim love! I'm shocked by how many people have at least heard of vim because of the "how to exit vim" meme even if they don't understand why it's funny.
A handy delete command that DT missed or forgot. Say you want to delete lines 6 through 14 in a document. In normal mode, type :6, 14d and enter. The lines will be deleted "in place" without having to use dd on each line.
Or put the cursor on line 6 and press either 9dd (delete the current line 9 times successively) or d8j (move the cursor 8 lines down and delete every line you come across, including starting and ending line). This is a lot easier with relative line numbers.
I've been using vim since around 2000, still learning things now and then. Didn't know Ctrl+w in insert mode for instance. Thanks for that! :) I'll give back this: In insert mode, start writing a few characters of a word that exists within the file (or another file opened in this session), hit Ctrl+n and it will autocomplete it.
One feature I use regularly is ":s" this runs search and replace in the file like the sed command. You need to specify a range to use it, but there are a couple shortcuts built into command mode that make it easy: If you select lines with visual mode and then start command mode with :, vim automatically adds "" meaning run the command on the selected lines. You can manually select the lines with :[START],[STOP] so for example ":3,5" will run the command on lines 3 through 5. Entering a percent sign (%) in command mode runs the command on the whole document. Back to the s command, I use it to replace multiple instances of a variable or keyword. For instance, I named a variable "big_name" and I want to make it "common_name" in the whole file that's easily done with: :%s/big_name/common_name/g Just like the command line sed application, the "s" command understands regex queries: :%s/^#\s*// Will remove all "hash" markings at the beginning of lines, so it will uncomment any line in the file that starts with "#" and any number (including 0) of white space characters after it.
I learned a lot of new things. Not all useful, because my fingers are encoded with alternatives that I know and like, but many are new to me. Nice work! When MS Word appeared, few people around me speculated that it will never be as useful as vim already is. Different times, different needs.
I'm learning Vim and I find it useful and fun, like the copy or delete inside quotes, but some of these commands are also simple in vscode. Uncomment line (can be anywhere in the line not just in the comment character): *cmd+?* Move line down or up once or many times: *Option + up or down arrow* Delete whole file (Similar in almost all OS): *cmd+a then backspace* Delete previous word: *option + backspace* Delete everything before cursor: *cmd+backspace* The indentation vscode can do automatically on save and also code formatting, deleting white space etc This is not a knock on vim as I already stated I like vim. The only command I saw that to my knowledge is not as simple in vscode is the editing inside of quotes or brackets etc. That's pretty useful and I'm adding that to my workflow
Hey DT, thanks for this video. Even though it's not mindblowing, I realized over the years that very few people know that ":x" (think 'exit') does the same as ":wq" Part of the vim-way is using the shortest command and in this case, you reduce the number of keystrokes by a whooping 33%! Been following you for years, I love your content! Greetings from Paris, France
yip/yap was god damn awesome to learn. I learned ci{ instead of di{, didn't consider they're basically the same in this context. But also ce and cE were quite nice. And using f or F in combination of other motions. And finding out that if you start the motion with alt, it'll put you back to the normal mode without escaping. And the number modifiers are obviously must, very basic but convenient. A must be my favourite though, nothing like adding that ; right where it belongs. Or = to indent the line automatically in the correct place! Ctrl+u or d are also really nice to quickly browse the document. Nvim has just made life so nice, especially when programming on a laptop where I definitely don't want to use the mouse. Shift+v as well, getting the whole line is so practical. Like Vy for repeating code lines that need only minor variation. And jumping paragraphs to empty line with { and }. Almost forgot but finding the start of the codeblock and then jumping back and forth with % is also so handy many times. Not only to find the other end but for editing too. You know it's a great video if all the motions that are your favourites are mentioned. When I started learning, I wrote all the motions I wanted to use on a note file, ended up roughly 100 lines long. Then tried to start using them even if it would take me longer to think about it and how the combination goes than to manually walk there. It's initially slowing you down but feels rather satisfactory to remember the neat motions and start getting faster on them, and have them come from the backbone more often. Honestly I found everything about vim mind blowing after I learned how to quit vim. I actually was for real the guy who got stuck in vim back when I was on the introduction class inside unix and accidentally opened a file in vim. I'm so glad I got turned and decided to try and dive in, because even after a week it felt impossible to go back. Vscode felt so slow and mouse heavy.
Most of vim's functions appear to be possible in the IDE using keys such as home, end, ctrl, alt, and shift. Are there any use cases that would never be possible in an IDE, but would be very useful?
Yeah, like praising the possibility of deleting everything in the document as if this is unique to vim when you can do just ctrl+a+del in every other editor... kind of tells me that vim of overrated. Don't get me wrong, it may be the best editor ever... but if this is the kind of things people say that makes if better, then I might not believe them anymore... I don't know, swapping lines with alt+up/down, commenting lines with ctrl+;, deleting a line from a specific character is usually just shift+end+del... pretty easy to me, specially because shift, ctrl and alt are right at your little finger's reach, so you don't even have to go out of your way to reach them.
To highlight and insert hash symbols to the beginning of consecutive lines (or the hash can be any word/letter) Ctrl + v , j , j, j, j, I, #, Esc Likewise to delete Ctrl + v , j, j, j, j, x
I like to use tabs and line numbers in vim, so in my ~/.vimrc I've got: set number relativenumber set showtabline=2 " tabe for opening a file in a tab, just hit enter to make it unnamed nmap \t :tabe nmap :tabn nmap :tabp
Hey DT! Was wondering why you use fish over zsh especially when you talk about window managers and write all these config files to make a custom experience. I feel like you should try zsh.
Very nice! Vim is my favorite editor! Question: When you are typing the commands, at the bottom it appears some vim tips/options in red color, how do you do that? Is It some config you did in the vimrc? I am not talking about the screenkey app, but the red text that shows some vim options when typing the commands. Again,very good video!
Heyyyyyyyyyyy DT😂😂😂😂😅 Is there a program in arch linux for screen annotation and magnifying at the same time? Unfortunately gromit-mpx does screen annotation only but not zooming!!!! ???
*.* repeats the last commands. you can use it like a macro. so for example. go to end of line shift A and add ; Now to repeat this action in the next line just do *j.*
I switched from Emacs to Vim about 15 or more years ago. I love the search commands: * search for word under cursor # reverse search for word under cursor g, go to last change n go to next match / ? change search direction I love the powerful multi-line regular expressions. I like being able to format and indent paragraphs. The ability to record key sequences and then play them back multiple times saves me tons of work. I like having a bunch of buffers I can save boilerplate text in. I'm sure other editors can do all these things but Vim makes it so easy (for me). Edit: I love rectangular copy and paste! Bonus tip: command line calculator: x2 () {awk "BEGIN{ printf \"%4.2f \", $(echo "$@" | tr '[]x' '()*' ); }" ;} You can use "x" for multiplication (to avoid globbing) and use square brackets for parens.
@@anon_y_mousse "$(( ... ))" is very primitive, for example no fractions. I often work in stripped down busybox environments where bc is not available but awk is. The tr command lets me avoid using glob characters in my input which is very convenient. The fixed precision is also convenient for me. O/C I have an x4 version. Most of the characters in my function are for these convenience features that don't exist in the alternatives you suggest. Use whatever you are most comfortable with. Amazon built their first web sites with C. It's a terrible language for web work but the devs were comfortable with it. I've found that sticking with a smaller set of tools that I am very familiar with is better for me that always switching to the best tool for the job. BTW: the dc calculator has a built-in function for doing RSA encryption/decryption which is kind of cool.
Actually, everything i showed in this video works in Doom Emacs. But I didn't want to demonstrate "Vim stuff" inside "Emacs". That would have been against the rules. ;)
Actually, it is broken for me as well. I suspect I need to rebuild qtile-extras in the DTOS repo due to the recent Python update on Arch. I'll rebuild that and push it out.
...”Vim is great, you can just go to any character and push x and it deletes that character... wow...”And on the other stupid editors you have to to to the character and push "delete" button, how ridiculous that is... (Highly sarcastic)
For me definitely macros, and the fact that you can make 'em recursive. E.g. to move all the lines containing something to another split I usually go with smth like `/something`, and then `ggqanddhpjl@a`. When there are no more search results, it terminates (same works with other errors).
Also it can be achieved in a different way with :g and :norm. The former is like substitution, but instead executes some command, and the latter executes a normal mode command. With that the aforementioned thingy turns into more readable `:g/something/norm ddhpj`, if I typed that correctly.
This was an awesome video. It brings me back to when I didn't know what bashrc is but it sounded so cool that I wanted Linux. I should spend some time ricing my OS sometime. Here's something I've been up to in vim lately: :e /tmp/a insert mode: grep something -n -r . | sed 's/:\([^:]*\):/ \1G /' normal mode: !!sh This gives results that look like: src/file1 21G And there is something here file2 1G var something = 32; Then I record 2 macros. One macro goes to the file and line under cursor. The other macro goes back to /tmp/a and one line below and calls the first macro. qt0W"gye0gf@gq qn (control shift 6) j@tq This way, I can do some neat tricks. I needed it a whole bunch and I'll need it plenty more, so I better find a way to automate it more or less. Would you be interested to try it out? You do seem to be into that sort of thing.
vab - selects content within parenthesis () along with it
vib - selects only the content within parenthesis
vaB - for {}
vib - for {}
% will help to jump between matching brackets, tags for that matter anything
D - deletes from cursor position to the end of the line
Y - copys till the end of the line
xp - really helpful to swaps letter like , bnigo --> bingo
gj - normally vim skips the line if its wrapped. gj helps to go down for that
gv - selects the previously selected part in visual mode.
gf - jumps to the file when on the file path.
For Web developers
cit will jump into the tag.
vit will juno into the tag in visual mode
Long time vim user here, here are some commands I can't live without that weren't mentioned:
1. Use A key to goto the end of line and I key to go to the start of the line.
2. The f key and t key to navigate in normal mode and to manipulate text in inset mode(paired with the c and d key).
3. Use "ciw" instead of "diw" to delete and go to insert mode.
4. Bind "jk" and "kj" to so you can save your pinky.
5. The C key, D key and "cc".
After 20 years of using vim, my advice is to try to stay in normal mode as much as possible, and you'll find yourself blazing fast.
New vim user here!
I use neo vim with auto completion especially for C. My biggest frustration is that I make a lot of errors in insert mode. And I always feel and tend to using the the Arrow Keys to fixing these errors which could be typos. Secondly neo vim auto completes parenthesis and and makes my cursor inside it! How do I get outside those parenthesis or any blocks without using arrow keys without escape (I tried ctrl+o but that's also bit hard). Any tips on how u proceed in these situations?
What do u use for auto completion (tab/enter or ctrl+y)?
@@VortexFlickens You might wanna find out with ":help insert-mode" which BTW contains ":help compl-autocomplete". Peace & Prosper 🤝🖖
Wow I didn’t know about capital i that is a life saver. I remapped caps lock to esc on tap and control on hold, do you think my pinky will still hurt in the long run compared to using the actual escape key(most top left key on keyboard) to escape. Been using vim for 3 months and I love it. I already feel like I move way faster than with keyboard and mouse.
“I love vim!”
Sets EDITOR to eMacs 😂
in vim there is actually a lot of things you can do
diw - delete inside word (delete a word)
daw - delete around word(deletes a word including the whitespace)
you can also use 'W' it will also do the same but it will consider a word as a collection of characters surrounded by whitespace
di{ - delete the content inside {}
di( - delete the content inside ()
da{ - delete inside {} including the {}
like this there are more (di", di'..etc)
instead of i (inside) or a (around) you can also use s ( surrounding )
it will delete the surrounding characters you are mentioning
most of these is useful for programmers
instead of d you can use c ( c stands for change )
it will go to insert mode after the operation is done, but d will stay in normal mode
use y instead of d and c, then you are doing yanking (copy) all the other are same
also you can use v (it is for visual mode - for selecting text)
for line search you can use f and F, it will find a purticular character in a line and then you can use ; and , to move forward and backword through that search character if there is more, f is for searching after and F is for searching behind
also there is t and T - f stands for find, and t stands for till it will also find but wont go to that character, instead a character behind the actuat character you are mentioning, it will make sense when you do operations like delete, for example you can do dta ( it will delete the characters from where you are till the character 'a' or delete till character 'a') if you use f then the character a will also be deleted.
instead of line you can search in entire document using /searchword and ?searchword (/ is for searching forward and ? is for backword)
then you can use n to move throught that search forward and N for backword
next time if you want to search the same keyword or searchword just press / and enter
for the basic movement you can use j (down), k (up), l (right), h (left), all the keys are available in home row
then moving faster using
w - word -> word -> word
e - end of each word
b - move word backword or beginning
you can also use numbers, it can be considers as a multiplication,
if you do 2j it will jumb two words down (nj , where n is a number)
this is not only possible with j k l h , but also with almost every command i have told earlier
for example i need to delete two word then i can do d2w..etc
there is also combination of commands like dd, yy, cc...etc
dd will delete a line
yy will yank(copy) a line
cc will delete a line then go to insert mode ( while d stay in normal mode)
this can also be combined with number like 2dd ( delete two line or d2d...etc)
for doing number combined operations it is better to do set the numbering to relative rather than normal numbering,
don't get what i said, right? just look at the video, he is using relative numbering rather that continueous,
for that just do :set relativenumber ( we are now using ex commands, ex commands starts with a : )
you can use :edit or :e for creating or editing file
eg. :edit newFile.js will create a file if not exist in the current path or will go to edit the purticular file if exist
you can do :w for writing the file :q for quiting the file or just :wq for write and quit
also you can do global replacement in the document by using :%s/textThatShouldBeReplaced/newText
now how can we move from normal to insert mode, most of the people will do ( i )
but there are more
i - insert mode ( it will put the cursor before the character you are in)
a - around ( it will put the cursor after the character you are in)
I (capital i ) for insertig at the start of line
A - insert at the end of line
these are used to go from normal mode to insert mode, where you can type like you do in a normal text editor...
use % for going to end of line and ^ for going to start of line (where first character starts)
0 for going to actual starting position or 0th column
esc, control + c, control + [ --- can be used to go to normal mode from insert mode
there is a lot like this...
some tips from me :
you can remap the key binding as you want, but if you are a programmer and you are using different text editrors then it is not recommended....
the reason is, i am using vs code as my main text editor for all my works, i often use ide's....
so when i am using other editors or using the computer of someone else, it is really hard because in first
i have remapped my keys in different way because some of them are not acceptable for me, like the esc key,
are you kidding me, i can't even reach the esc key, so i remapped it into jj, so i just need to type jj to go to normal mode,
now it is pretty much easy, but the problem will really happen when changing editor or computer because the remapping json file is in my computer or in the vs code and it is a bit time comsuming to set up or just add all those keybinding to other editors or ide's and it may be easy for vs code configuring but not for other ide's,
it is sure that vim extension is available at almost everywhere, but the remapping is done in different ways in different application, this problem happended to me when i have used the android studio, vim is available there in the name of ideavim,
but i dont know how to configure or remap the keys or else you need understand it in the way of vim, because i guess vim offerese key remapping commands so you just need to use some ex commands to do that, but on that time learning any of this is time comsuming,
also when i use others computer i use jj all the time to go to normal mode, and then it will print to screen because vim is not installed on there computer and even if it is installed, i need to remap it, if the remapping is not needed, then i could have been installed vim and used on there computer.
do you know how harder it is to use the arrow keys to move around if you are a vim user,
so all of the things above mentioned can be avoided by simply using default configuration. and i am now using default configuration.
using touch typing + vim + some practice you can become god in handling file and text.
nobody will even get understand what you are doing, they will be amazed of yours speed.
im on the way to become that god, just need to have some practive because i have changed on the default configuration in the last week,
also vim is really good for touch typers.... because they don't like to leave from there home row like me....☺
From vim tips and tricks video to the full vimtutor paraphrasing starting from the first chapter.
Insanely useful comment.
@@daveqr Thanks ....❤️
is there a way to save comments??
Indenting python scripts with = is difficult because the indentations define the ends of blocks. In bash you have keywords to define both ends of a block, and in C-family syntax it's curly braces. So the indentation itself carries non-superfluous meaning in Python, while in many other languages it can be unambiguously determined by the code in the immediate surrounding.
Using c (for "change") instead of d (for "delete") puts you right into insert mode after the deletion, no matter what kind of deletion you do. And when deleting a word, note that dw and cw only delete from the cursor and out. daw and caw take the entire word.
Finally, da" includes the quotation marks, as opposed to di".
One thing I like a lot is pressing f and then a character to find the next instance of the character in that line, and F to find the previous one. This also works with delete: df( will delete everything from your cursor to the first opening parenthesis it finds (including it).
And t can do the same, but stopping before reaching the character: dt( will delete from the cursor to the character before the next parenthesis and dT( will delete from the cursor to the character after the previous parenthesis.
Edit: Forgot to mention, you can use I (capital i) to enter insert mode at the beginning of the line (technically, before the first non-blank character) and A to enter insert mode at the end of the line.
and also, at the very beginning, you could use alt+j instead of ddp
@@fincali197 Is that really standard vim behavior? I use a plugin for that.
@@IreizD yeah sorry, I was using LazyVim at the time. I think it's possible without a plugin though.
Hi derek! Linux user from spain here, sorry if my english is a little basic. I started learning vim (and awesome wm) with your videos (i've thought on learning it many times before and ended up not bothering) and i am loving how versatile it is, i never understood why it was so 'famous' until now. Thanks for sharing your knowledge on this, i am enjoying like a child with your content. And also thanks for sharing the keystrokes on this video, it was so helpful
Life changing commands that blew my mind
dap to delete a paragraph
O to open insert mode on the line above
And o for below
f and F (t and T) to find characters in line. Then repeat with ; or ,. Can also combine with visual/delete/replace commands.
g; and g, to move among the recent changes.
ctrl+v for visual block.
ctrl+a and ctrl+x for advancing and decreasing a number (including dates with the speeddating plugin!)
. to repeat the last action.
Macros. An additional level of zen power.
Programmed hot keys with space being the leader. Can add signatures, insert timestamps, open file read-only in new tab, call a function, a compiler or a script on the file (LaTeX it, calculate math expressions from within Vim, search for certain patterns).
i did not know about g; and g,, thats so cool
Ctrl + c serves the exact same function as the ESC key but you don't have to move your hands to execute. Similarly, Ctrl + i performs an indention. Really handy when the tab key is just bouncing you around or if you want to keep your hands on the main keys
not exactly, if you have something bound to work on switching to normal mode, or just escaping, it will not trigger when pressing ctrl + c. ctrl + [ on the other hand works exactly the same as ESC key
lunarvim maps 'jk' to go to normal mode and in english that makes some sense imo. that way you don't have to move to the escape key either
Every OS allows changing CapsLock to work like Esc now, so that's the best option IMO.
Ctrl [ is sec not ctrl c as someone else has said
@@gnuemacs1166 Holy molly is that the GNU/Emacs the best operating system?
Commenting out every line of current file, in normal mode: ggGi# and to reverse it, ggGx (where means Ctrl+v).
2:16 to swap lines you can use M-, what's interesting is how you can swap parts of text in visual mode with just selecting text
Gotta spread that Vim love!
I'm shocked by how many people have at least heard of vim because of the "how to exit vim" meme even if they don't understand why it's funny.
I've used Vim every day, for the last 20 years, I'm still learning new tricks.. it's the cats meow..
Thanks for this, I've learned a few new ones.
A handy delete command that DT missed or forgot. Say you want to delete lines 6 through 14 in a document. In normal mode, type :6, 14d and enter. The lines will be deleted "in place" without having to use dd on each line.
Or put the cursor on line 6 and press either 9dd (delete the current line 9 times successively) or d8j (move the cursor 8 lines down and delete every line you come across, including starting and ending line).
This is a lot easier with relative line numbers.
@@MasterHigure Cool, I didn't know that trick. Vim is more of a journey than a destination.
Personally to delete a bunch of line, I go to visual line mode (Shift V) then a select my lines with up or down (j ou k) and I just press delete (d).
@@ringo8410 that is the truth, my friend, vim IS a journey
I've been using vim since around 2000, still learning things now and then. Didn't know Ctrl+w in insert mode for instance. Thanks for that! :) I'll give back this: In insert mode, start writing a few characters of a word that exists within the file (or another file opened in this session), hit Ctrl+n and it will autocomplete it.
As a new vim user this could'nt not come at a better time 😅 slowly getting into it , there's so much keybinds 😆
One feature I use regularly is ":s" this runs search and replace in the file like the sed command. You need to specify a range to use it, but there are a couple shortcuts built into command mode that make it easy:
If you select lines with visual mode and then start command mode with :, vim automatically adds "" meaning run the command on the selected lines.
You can manually select the lines with :[START],[STOP] so for example ":3,5" will run the command on lines 3 through 5.
Entering a percent sign (%) in command mode runs the command on the whole document.
Back to the s command, I use it to replace multiple instances of a variable or keyword. For instance, I named a variable "big_name" and I want to make it "common_name" in the whole file that's easily done with:
:%s/big_name/common_name/g
Just like the command line sed application, the "s" command understands regex queries:
:%s/^#\s*//
Will remove all "hash" markings at the beginning of lines, so it will uncomment any line in the file that starts with "#" and any number (including 0) of white space characters after it.
And if you add c to the end of the line with :%s it will ask about each replacement so you can reject it selectively.
can you do a video where you explain that please
I have never even thought to compare vim with simple text editors. I do often compare it with IDEs like vscode or eclipse. And usually wins for me
Great tips!
Here's another useful one: colon x enter - save and exit, replaces colon wq enter. One keypress saved 🙂
I was a fan of :x until I discovered ZZ.
I learned a lot of new things. Not all useful, because my fingers are encoded with alternatives that I know and like, but many are new to me. Nice work! When MS Word appeared, few people around me speculated that it will never be as useful as vim already is. Different times, different needs.
I'm learning Vim and I find it useful and fun, like the copy or delete inside quotes, but some of these commands are also simple in vscode.
Uncomment line (can be anywhere in the line not just in the comment character): *cmd+?*
Move line down or up once or many times: *Option + up or down arrow*
Delete whole file (Similar in almost all OS): *cmd+a then backspace*
Delete previous word: *option + backspace*
Delete everything before cursor: *cmd+backspace*
The indentation vscode can do automatically on save and also code formatting, deleting white space etc
This is not a knock on vim as I already stated I like vim. The only command I saw that to my knowledge is not as simple in vscode is the editing inside of quotes or brackets etc. That's pretty useful and I'm adding that to my workflow
To close the help buffer, actually you can close it like any other buffer, so :q (to me easier and faster than Ctrl+W c)
Excellent tips and short cuts on vim. appreciate posting this,
Mathew from Colorado
in escape mode , gq will split a long line into multiple lines
Control O in insert mode is a game changer. Thanks!
My two favorite commands are ZZ instead of :wq and binding jj to exit insert mode
Now I've known all these commands for a couple of years I miss the good time when I would watch these videos and be mind blown by vim...
Hey DT, thanks for this video. Even though it's not mindblowing, I realized over the years that very few people know that ":x" (think 'exit') does the same as ":wq"
Part of the vim-way is using the shortest command and in this case, you reduce the number of keystrokes by a whooping 33%!
Been following you for years, I love your content!
Greetings from Paris, France
I use "ZZ" for this which is very convenient on a US keyboard because "z" is next to the shift key. It's less convenient on a French keyboard.
I always use ZZ even though it requires both hands on my keyboard layout.
@@BitJam Thanks, good tip! And works for me too, I've been using US keyboards for years
ZZ has the advantage of not modifying file date if no modifications was done.
Thing that really helped me is you can pipe output into vim which is nice for some syntax highlight
echo "whatever" | vim -
You can execute a command and paste it inside vim also
:r!
Example
:r!ls -l
yip/yap was god damn awesome to learn. I learned ci{ instead of di{, didn't consider they're basically the same in this context. But also ce and cE were quite nice. And using f or F in combination of other motions. And finding out that if you start the motion with alt, it'll put you back to the normal mode without escaping. And the number modifiers are obviously must, very basic but convenient. A must be my favourite though, nothing like adding that ; right where it belongs. Or = to indent the line automatically in the correct place! Ctrl+u or d are also really nice to quickly browse the document. Nvim has just made life so nice, especially when programming on a laptop where I definitely don't want to use the mouse. Shift+v as well, getting the whole line is so practical. Like Vy for repeating code lines that need only minor variation. And jumping paragraphs to empty line with { and }.
Almost forgot but finding the start of the codeblock and then jumping back and forth with % is also so handy many times. Not only to find the other end but for editing too.
You know it's a great video if all the motions that are your favourites are mentioned. When I started learning, I wrote all the motions I wanted to use on a note file, ended up roughly 100 lines long. Then tried to start using them even if it would take me longer to think about it and how the combination goes than to manually walk there. It's initially slowing you down but feels rather satisfactory to remember the neat motions and start getting faster on them, and have them come from the backbone more often. Honestly I found everything about vim mind blowing after I learned how to quit vim. I actually was for real the guy who got stuck in vim back when I was on the introduction class inside unix and accidentally opened a file in vim. I'm so glad I got turned and decided to try and dive in, because even after a week it felt impossible to go back. Vscode felt so slow and mouse heavy.
Always learning something new with DT.
Learning vim is the best thing that happened to me as a linux user !
I always confuse they VIM commands with the BSD commands.
Thanks for the visuals along the cheatsheet. I like reading and listening at the same time.
I've been using vim somewhat regularly for several months now and I didn't know most of this stuff
Most of vim's functions appear to be possible in the IDE using keys such as home, end, ctrl, alt, and shift. Are there any use cases that would never be possible in an IDE, but would be very useful?
Yeah, like praising the possibility of deleting everything in the document as if this is unique to vim when you can do just ctrl+a+del in every other editor... kind of tells me that vim of overrated. Don't get me wrong, it may be the best editor ever... but if this is the kind of things people say that makes if better, then I might not believe them anymore...
I don't know, swapping lines with alt+up/down, commenting lines with ctrl+;, deleting a line from a specific character is usually just shift+end+del... pretty easy to me, specially because shift, ctrl and alt are right at your little finger's reach, so you don't even have to go out of your way to reach them.
VIM IS THE GREATEST EDITOR OF ALL TIME
Love this, more of this would be nice
Excellent video. Thanks very much
My favorite and easiest ways to quit from vim are pressing ZZ (quit and save) or ZQ (quit without saving)
Like most things in life; I picked my editor of choice based on the memes online. Gentoo btw
To highlight and insert hash symbols to the beginning of consecutive lines (or the hash can be any word/letter)
Ctrl + v , j , j, j, j, I, #, Esc
Likewise to delete
Ctrl + v , j, j, j, j, x
this is awesome! what tool do you use to show the key presses?
'screenkey' It's in everybody's repos.
I like to use tabs and line numbers in vim, so in my ~/.vimrc I've got:
set number relativenumber
set showtabline=2
" tabe for opening a file in a tab, just hit enter to make it unnamed
nmap \t :tabe
nmap :tabn
nmap :tabp
Insert mode: C-e and C-y copy text from lines above and below
I strongly suggest adding "map ; :" in vimrc, and of course not the other way around :)
Hey DT! Was wondering why you use fish over zsh especially when you talk about window managers and write all these config files to make a custom experience. I feel like you should try zsh.
Thanks for the video! It's really useful.
Your ex() function is a brilliant idea, thanks :)
Very nice!
Vim is my favorite editor!
Question: When you are typing the commands, at the bottom it appears some vim tips/options in red color, how do you do that? Is It some config you did in the vimrc?
I am not talking about the screenkey app, but the red text that shows some vim options when typing the commands.
Again,very good video!
@3:57 notepad++ has that feature without forcing you to learn new typing mode and programming language to run a text application.
Geeks don't do different things they do things differently..
I use ci to change stuff in between quotation marks & parenthesis, cw to directly change a word under cursor.
You need to do ciw if you want to change the whole word if cursor is not at begining
I like using gcc to toggle a line comment or number gcc for multiple lines.
Heyyyyyyyyyyy DT😂😂😂😂😅
Is there a program in arch linux for screen annotation and magnifying at the same time?
Unfortunately gromit-mpx does screen annotation only but not zooming!!!! ???
You should make a video about Lunarvim, it's amazing
*.* repeats the last commands. you can use it like a macro. so for example. go to end of line shift A and add ; Now to repeat this action in the next line just do *j.*
I switched from Emacs to Vim about 15 or more years ago. I love the search commands:
* search for word under cursor
# reverse search for word under cursor
g, go to last change
n go to next match
/ ? change search direction
I love the powerful multi-line regular expressions. I like being able to format and indent paragraphs. The ability to record key sequences and then play them back multiple times saves me tons of work. I like having a bunch of buffers I can save boilerplate text in. I'm sure other editors can do all these things but Vim makes it so easy (for me).
Edit: I love rectangular copy and paste!
Bonus tip: command line calculator:
x2 () {awk "BEGIN{ printf \"%4.2f
\", $(echo "$@" | tr '[]x' '()*' ); }" ;}
You can use "x" for multiplication (to avoid globbing) and use square brackets for parens.
I'm curious why you'd calculate that way as opposed to just echo $(( ... )) or echo '...' | bc -ql ?
@@anon_y_mousse "$(( ... ))" is very primitive, for example no fractions. I often work in stripped down busybox environments where bc is not available but awk is. The tr command lets me avoid using glob characters in my input which is very convenient. The fixed precision is also convenient for me. O/C I have an x4 version.
Most of the characters in my function are for these convenience features that don't exist in the alternatives you suggest.
Use whatever you are most comfortable with. Amazon built their first web sites with C. It's a terrible language for web work but the devs were comfortable with it.
I've found that sticking with a smaller set of tools that I am very familiar with is better for me that always switching to the best tool for the job.
BTW: the dc calculator has a built-in function for doing RSA encryption/decryption which is kind of cool.
I always feel like Walter white is teaching me vim😂
Always loved your content, very useful. Thank you :)
Amazing tips!
q to register key pressed for example qa to register keys then @a to redo all keys pressed!
And
:normal @a
To run it on all line of a visual block
Which program is this which is used for keycasting?
Hi can you pls do different ways to delete a line..
S for indent, Ctr-o mode, all others I know🎉
Hey DT. Great video (as always). Was wondering if these key bindings also work in neovim (nvim). Or was this just vanilla VIM? Thanks.
NeoVim is just vim with some extra features. Everything you'd do in Vim should be the same in NeoVim.
Keybindings certainly are the same.
Yes everything will work. Neovim was created with main intention to support vast amount of plugins.
10:26 when pasting from the Linux buffer using the mouse , I do a '':set noai '' so during the paste vim does not auto indent and doesn't add the tabs
Maybe a review on AstroVim?
Bro please make a video on how to install Hyprland on Arch using archinstall the minimal way.
Hey DTPlease do vidéos for emacs using vim utilities also
How does Vim clear all tags?
thank you
also check "g;", "g,", "[]", "[[" etc movement keys
ZQ quit without saving (normal mode)
My 2 cents: I use :x instead of :wq to write and quit vim
ZZ is good too, if file not modified it will not rewrite it (and change modifications date of the file)
How do you display a cheat sheet after you hit "di"?
Does anyone know to fix the audio issue that im having while running Zorin. That is the only issue im having
16:59 lmaooooooooooooooooooooo
ZZ = exit vim
Great video my friend! Thank you much!
Back to vim from Doom Emacs? 😆
You can use both.
Actually, everything i showed in this video works in Doom Emacs. But I didn't want to demonstrate "Vim stuff" inside "Emacs". That would have been against the rules. ;)
Watching this on a smartphone totally rots. I cannot see anything.
Hey dt rebuild qtile . It crashed
Actually, it is broken for me as well. I suspect I need to rebuild qtile-extras in the DTOS repo due to the recent Python update on Arch. I'll rebuild that and push it out.
Fixed. Read this issue on GitLab for the commands. gitlab.com/dtos/dtos/-/issues/180
yoooo :D
Sublime Text can most likely do most of this. It's really good, but kinda costly if you want to avoid the nag.
I put the 666 like just now
I can't take you seriously if you are editing your bashrc and your editor is set to emacsclient
2:30 cursor movement was so unvimlike 🙃
...”Vim is great, you can just go to any character and push x and it deletes that character... wow...”And on the other stupid editors you have to to to the character and push "delete" button, how ridiculous that is... (Highly sarcastic)
For me definitely macros, and the fact that you can make 'em recursive. E.g. to move all the lines containing something to another split I usually go with smth like `/something`, and then `ggqanddhpjl@a`. When there are no more search results, it terminates (same works with other errors).
Also it can be achieved in a different way with :g and :norm. The former is like substitution, but instead executes some command, and the latter executes a normal mode command.
With that the aforementioned thingy turns into more readable `:g/something/norm ddhpj`, if I typed that correctly.
basic but useful, to replace some text in the entire document:
:%s/before/after/g
Add a c at the end to have it ask about each substitution as well.
Search and replace example from line 1 to 5:
:1,5s/word/replacement/g
1 = first line
5 = fifth line
s = search
g = global
:wq! should be ZZ
I use .= to spell check the word I am on.
Dot equals? I've heard of some old Vim functionality for spell checking, but there's no way it's the dot key right?
@@theodorealenas3171 pardon me- z= is what I was looking for. "." Repeats the last action, iirc
:redir >> nmap.txt
:silent nmap
:silent imap
:silent vmap
:redir END
This was an awesome video. It brings me back to when I didn't know what bashrc is but it sounded so cool that I wanted Linux. I should spend some time ricing my OS sometime.
Here's something I've been up to in vim lately:
:e /tmp/a
insert mode:
grep something -n -r . | sed 's/:\([^:]*\):/ \1G /'
normal mode:
!!sh
This gives results that look like:
src/file1 21G And there is something here
file2 1G var something = 32;
Then I record 2 macros. One macro goes to the file and line under cursor. The other macro goes back to /tmp/a and one line below and calls the first macro.
qt0W"gye0gf@gq
qn (control shift 6) j@tq
This way, I can do some neat tricks. I needed it a whole bunch and I'll need it plenty more, so I better find a way to automate it more or less.
Would you be interested to try it out? You do seem to be into that sort of thing.
Search And Replace from Normal Mode do: `:%s/oldworrd/newword/g`