I find "gi" a particular powerful command: it starts insert mode in the last place where you have inserted text before, so you can write something, exit insert mode, navigate around the text, and then press "gi" and continue writing in the same place
Another cool trick is to use which takes you to normal insert mode. You can make one change in normal mode and after that you are back on to the cursor were you previously were.
I liked how the speaker (Daniel) got everyone involved. I wish he reasserted what they were saying. It's hard to hear sometimes. Awesome video! Thanks!
I love this - most talks have one or two awkward questions at the end, this one has 5 minutes vim users sharing their favourite vim navigation commands.
Nice talk. I've been using Vim as my main programming editor for a couple of years, but didn't know about the commands for screen shifting. That's gonna come in really handy. Just a little tip: you can also use the D command to delete to the end of a line; it's just a little bit quicker than d$. The same also applies for C and c$, for deleting to the end of the line but putting you in insert mode.
@@wliaputs Even the neovim `:help Y` says: "If you like "Y" to work from the cursor to the end of line (which is more logical, but not Vi-compatible) use ":map Y y$"." Now that I think about it - why doesn't it say ":nnoremap Y y$"? - At least that is what I have in my vimrc. EDIT: To answer my question: Because e.g. `D` also works like this in visual (block) mode
12:10 you meant to say # will search backwards. Tip : If you do "g*" or "g#", it does not require a whole word matches in the results. Difference between doing "/TEST" and "/\" Thanks for the great talk!
Very nice video, after using extensively and solely on vim, I still want to be faster in navigation, this video helps. I add mine here O -> start inserting at the current line but add a new line below o -> start inserting in the new line dd -> remove a whole line cc -> remove the whole line then start inserting C -> remove everything after starting from cursor to the end of the line then start inserting % -> place your cursor at the pair of parenthesis or brace then hit % it will take you back and forth to its pair move cursor to multiple line at the same location, then then insert something, then finally hit -> this will insert the same text in multiple lines at the same time gg=G -> this will fix indentations of the whole file to what you've set in .vimrc or current session accordingly and properly (you can do the same by highlighting text in visual mode then hit =) ]] or [[ -> move forward or backward to function defined in c or c++ extra :reg -> to see contents saved in registers in vim :reg m -> to see content saved in register m :marks -> to see current marked location q: -> to see history of vim commands we've executed (exit via normal :q) q/ or q? -> to see history of search texts (exit via normal :q)
Use brackets ( ) to jump between sentences and curlies { } to jump paragraphs. The latter is more useful for programming, however, the former I use a lot because I write a lot of plain text in VIM.
Linewise Navigation: hjkl left, down, up, right G bottom of file gg top of file L last/low line of the screen M middle of screen H top/high line of screen 4:36 jumping lines summary Shifting Around on Screen: zz center line on screen zt bring line to top of screen zb bring line to bottom of screen ctrl+e shift screen DOWN - e for end ctrl+y shift screen UP - y for yUP ctrl+d move DOWN a half-screen ctrl+u move UP a half-screen ctrl+f move DOWN a full-screen ctrl-b move UP a full-screen - b for back 8:07 shifting screen summary 10:11 Within a Line summary: 0 beginning of line $ end of a line ^ first char of a line g_ last char of a line 15:26 Cheatsheet summary
At around 5:54, ctrl + e -> scroll screen down ctrl + y -> scroll screen up. I think the reason for that is, in the keyboard, 'e' is above 'd' for down, and 'y' is to the left of 'u' for up.
Ctrl + O will take you back to the point you where working or you jump last, I use this all the time, also when editing multiple files it will navigate you to the last edited file.
Vim has many ways to move around files. Usually when I don't know the line I'm looking for, I'd move around using the /command (search). I'd lock onto a fairly unique word(s) that I know are close what I'm looking for, for example if I want to jump to a function called foo, I'd search for "/def foo(". Makes it easier to just jump where you want to be, rather than trying to find where things are. The movement commands and screen movements are usually useful for browsing around, when you don't even know what you're looking for.
I wish they produce more vim videos. 😢 I think they all moved to emacs by now. There are a lot of navigation commands missed in this video eg: (like ctrl-], [-ctrl-d, :ij, :dj, ctrl+w d), most of these commands take you from fast, to lightning speed 😁
[{, ]} is to jump to opening / closing bracket in { } block. [(, ]) - same for ( ) block [#, ]# - jump to prev / next #ifdef, #else, #endif [* or [/, ]* or ]/ - jump to beginning / end of a C-style comment /* */ [m, ]m, [M, ]M - jump to begining / end of a next / previous C++/Java... method
After using Vim for for years and constantly searching for commands and expanding my abilities these obscure ones help me the most and I’ve not yet seen a Vim video tutorial mention them. Thanks so much 🙏
The one things that I constantly do and others constantly do that I’ve not yet found a sequence of commands for is deleting/cutting a string literally in single or double-quotes WITh the quotes rather than within or inside of them
@@wulymammoth Is that what you're looking for? da" - delete around ", including " df" - delete forward till ", includes " " could be replaced with other bracket types ',(,),,#, etc.
Using f, F, t, or T are not that useful because they're not efficient. Imagine if you want to delete all the characters forward until a certain word that begins with an 's' character. If you use t for the direction, chances are before the word that begins with the 's' character, there are other 's' characters along the way and so you're forced to either count the number of 's' characters which is totally inefficient or you have to repeat the same motion, which is again not ideal. The best thing to do is to use the search commands / or ? to specify the direction instead of f, F, t, or T. By using / or ?, you just have to type a few characters of the word that you want to use to limit your command, and your command will act until that word. This way, it is very intuitive as you are 100% sure where the command ends its action (i.e. no ambiguity whatsoever). The downside is that, there is a side-effect of highlighting words that begin with the characters that you specified, but this can be fixed by mapping :noh to in normal mode to quickly switch off the highlighting.
I would guess `g` was originally short for "go". As in 'go to line 72' (72gg), 'go to the method definition (gd)', 'go to the next tab' (gt), etc. It's a common pattern for the single capital letter to relate to the end ('D' deletes until the end of the line, 'C' changes until the end of the line) and double-letter to relate to the bigger object ('dd' deletes the entire line, 'yy' yanks the entire line). G for the end of the file, gg for the start. Just speculation. Or at least a way to remember :)
Creators? You mean creator. As I understand it, vim is basically a pet project by Bram Molenaar, although it is open source so others have contributed. You can thank Google for its continued development too, as they hired Bram but allowed him to use his 20% time to maintain and develop vim.
Okay, 4 moths later... In gVim type the command: :set guifont=* A menu pops out, choose the font you want (it will only show monospaced installed fonts i think). That will last only for the current session, so after that do: :set guifont? That will show you the way Vim calls that specific font+settings (it varies depending on OS). Copy that value to your .vimrc, something like: set guifont=Source_Code_Pro:h11 To edit your .vimrc quickly you can do: :e $MYVIMRC Just type :e $M and it will autocomplete
Around 15:14 he says 'if you want to set a mark V in your vimrc'. Has anyone got that working? What's the syntax for running a normal mode command in vimrc>?
If you know that you open your vimrc a lot, you can set a global mark at the top of the file. Open ~/.vimrc and type mV at top of the file. (m for mark, V to use the V register. Any uppercase letter can be used instead of V.) Later, you can hit `V to jump to the mark. By default, uppercase marks are persisted between sessions. More details are available here: vim.wikia.com/wiki/Using_marks
I find "gi" a particular powerful command: it starts insert mode in the last place where you have inserted text before, so you can write something, exit insert mode, navigate around the text, and then press "gi" and continue writing in the same place
I used to use undo-redo for that. Many thanks.
Another cool trick is to use which takes you to normal insert mode. You can make one change in normal mode and after that you are back on to the cursor were you previously were.
@@exwhyzd and navigates the same list does but in reverse
@@skyeplus Always thought Vim is too thoughtful.
@@90hijacked what does this kind of notation mean?
I know it’s kinda dumb, but half the reason I use vim is the movements are actually fun. Vim is fun toy, and it’s always cool to learn new tricks.
Agreed.
I'm 5 years late but this video blew my mind. Feeling a lot more confident now about navigation and macros was a bonus too. Thank you!
Are you from the future?
@@jerboas86 nope, I'm from future
@@soham7510 take me w you
@@Sk8erMorris believe me, its dark out here in future
@@soham7510 oh my fucking god you actually called it
I liked how the speaker (Daniel) got everyone involved. I wish he reasserted what they were saying. It's hard to hear sometimes. Awesome video! Thanks!
I love this - most talks have one or two awkward questions at the end, this one has 5 minutes vim users sharing their favourite vim navigation commands.
Nice talk. I've been using Vim as my main programming editor for a couple of years, but didn't know about the commands for screen shifting. That's gonna come in really handy. Just a little tip: you can also use the D command to delete to the end of a line; it's just a little bit quicker than d$. The same also applies for C and c$, for deleting to the end of the line but putting you in insert mode.
And for reasons unknown to me, Y yanks the entire line, instead of doing the same thing as y$
@@ryanevius yeah that breaks D and C. I made that mistake so many times thinking Y would copy till end of line.
@@ryanevius that’s why I remap “Y” as “y$” lol
@@wliaputs Even the neovim `:help Y` says: "If you like "Y" to work from the cursor to the end of line (which is more logical, but not Vi-compatible) use ":map Y y$"."
Now that I think about it - why doesn't it say ":nnoremap Y y$"? - At least that is what I have in my vimrc. EDIT: To answer my question: Because e.g. `D` also works like this in visual (block) mode
12:10 you meant to say # will search backwards.
Tip : If you do "g*" or "g#", it does not require a whole word matches in the results.
Difference between doing "/TEST" and "/\"
Thanks for the great talk!
Very nice video, after using extensively and solely on vim, I still want to be faster in navigation, this video helps.
I add mine here
O -> start inserting at the current line but add a new line below
o -> start inserting in the new line
dd -> remove a whole line
cc -> remove the whole line then start inserting
C -> remove everything after starting from cursor to the end of the line then start inserting
% -> place your cursor at the pair of parenthesis or brace then hit % it will take you back and forth to its pair
move cursor to multiple line at the same location, then then insert something, then finally hit -> this will insert the same text in multiple lines at the same time
gg=G -> this will fix indentations of the whole file to what you've set in .vimrc or current session accordingly and properly (you can do the same by highlighting text in visual mode then hit =)
]] or [[ -> move forward or backward to function defined in c or c++
extra
:reg -> to see contents saved in registers in vim
:reg m -> to see content saved in register m
:marks -> to see current marked location
q: -> to see history of vim commands we've executed (exit via normal :q)
q/ or q? -> to see history of search texts (exit via normal :q)
thanks for those extra section
FYI, you can use underscore "_" instead of caret " ^ ". I think it's a better mnemonic to do the opposite of "g _". See slides at 10:28.
Makes me wonder why people risk their lives looking for Gold in white water rapids when it's right here on UA-cam.
Use brackets ( ) to jump between sentences and curlies { } to jump paragraphs. The latter is more useful for programming, however, the former I use a lot because I write a lot of plain text in VIM.
Yeah, i use {} heavily when skimming through code up & down in chunks
jumping between sentences is awesome. thanks for that
Learning `vim` is so pleasant that I learn something new (and useful) everywhere I go, as this video.
Linewise Navigation:
hjkl left, down, up, right
G bottom of file
gg top of file
L last/low line of the screen
M middle of screen
H top/high line of screen
4:36 jumping lines summary
Shifting Around on Screen:
zz center line on screen
zt bring line to top of screen
zb bring line to bottom of screen
ctrl+e shift screen DOWN - e for end
ctrl+y shift screen UP - y for yUP
ctrl+d move DOWN a half-screen
ctrl+u move UP a half-screen
ctrl+f move DOWN a full-screen
ctrl-b move UP a full-screen - b for back
8:07 shifting screen summary
10:11 Within a Line summary:
0 beginning of line
$ end of a line
^ first char of a line
g_ last char of a line
15:26 Cheatsheet summary
At around 5:54,
ctrl + e -> scroll screen down
ctrl + y -> scroll screen up.
I think the reason for that is, in the keyboard, 'e' is above 'd' for down,
and 'y' is to the left of 'u' for up.
I think about them as
e - elder numbers
y - younger numbers
gd - go to definition of word (function, class etc) under cursor
gf - go to file under cursor
Ctrl + O will take you back to the point you where working or you jump last, I use this all the time, also when editing multiple files it will navigate you to the last edited file.
that percentile command... really appreciate it. Don't always know the line I'm looking for so this is helpful.
Gladwin Mohlamonyane Agreed. I didn't know that one either and it seems so obvious now that I've heard it. Very useful
Vim has many ways to move around files.
Usually when I don't know the line I'm looking for, I'd move around using the /command (search). I'd lock onto a fairly unique word(s) that I know are close what I'm looking for, for example if I want to jump to a function called foo, I'd search for "/def foo(". Makes it easier to just jump where you want to be, rather than trying to find where things are.
The movement commands and screen movements are usually useful for browsing around, when you don't even know what you're looking for.
It also works with #ifdef blocks.
set scrolloff=99 " Keeps current line in the middle so your searched words will be centered.
14:43 what is a "back-tick" ?
is that the button next to the number 1?
like this:
`
the one that share a button with:
~
idk
Im here because I feel chided by "You Have No Excuse Not to Know!" haha
I wish they produce more vim videos. 😢 I think they all moved to emacs by now. There are a lot of navigation commands missed in this video eg: (like ctrl-], [-ctrl-d, :ij, :dj, ctrl+w d), most of these commands take you from fast, to lightning speed 😁
Great talk and I did learn a couple more tricks! Keep the vim info coming!
Go to matching bracket is % ... can't live without that.
Great job thought i knew everything about navigiation. You always learn something new in Vim
[{, ]} is to jump to opening / closing bracket in { } block.
[(, ]) - same for ( ) block
[#, ]# - jump to prev / next #ifdef, #else, #endif
[* or [/, ]* or ]/ - jump to beginning / end of a C-style comment /* */
[m, ]m, [M, ]M - jump to begining / end of a next / previous C++/Java... method
Thank you that's going to help me a lot!
After using Vim for for years and constantly searching for commands and expanding my abilities these obscure ones help me the most and I’ve not yet seen a Vim video tutorial mention them. Thanks so much 🙏
The one things that I constantly do and others constantly do that I’ve not yet found a sequence of commands for is deleting/cutting a string literally in single or double-quotes WITh the quotes rather than within or inside of them
@@wulymammoth Is that what you're looking for?
da" - delete around ", including "
df" - delete forward till ", includes "
" could be replaced with other bracket types ',(,),,#, etc.
@@skyeplus thanks I literally found the answer last night by Googling and going through enough links, but thank you so much for these :D
To clear whitespace, :s/ *$ is pretty convenient and a little easier than recording a macro.
I think it's better to use '\s' for any whitespace including TAB: :%s/\s\+$ (or :%s/\s*$, but that will gonna match and replace every line).
Thank you so much.
It was very helpful and useful.
thanks for sharing, I found the scrolling commands really handy.
Very useful, love the format. Thanks!
It is a pity that slides have not been made available: I would have loved that the guy could have spent more time on each slide.
Slides are available here: docs.google.com/presentation/d/1v1pTy_WLSDx1krxDIPD379YyZJoMEsubcYOaqcwEj-8/
Oh. You are the guy in the talk. Amazing talk. Have you done any more of these? Do you have any good suggestions for a beginner like me?
Aewsome!!! Now i know the usecases too.
Using f, F, t, or T are not that useful because they're not efficient. Imagine if you want to delete all the characters forward until a certain word that begins with an 's' character. If you use t for the direction, chances are before the word that begins with the 's' character, there are other 's' characters along the way and so you're forced to either count the number of 's' characters which is totally inefficient or you have to repeat the same motion, which is again not ideal.
The best thing to do is to use the search commands / or ? to specify the direction instead of f, F, t, or T. By using / or ?, you just have to type a few characters of the word that you want to use to limit your command, and your command will act until that word. This way, it is very intuitive as you are 100% sure where the command ends its action (i.e. no ambiguity whatsoever). The downside is that, there is a side-effect of highlighting words that begin with the characters that you specified, but this can be fixed by mapping :noh to in normal mode to quickly switch off the highlighting.
Another thing you can do is to press . (Dot) to repeat the last action.
you can try easymotion or quickscope plugin. not sure how useful these are since I am still new to vim.
SUPER helpful. Thanks!!!
08:10 | 10:12 within A line navigation15:22 summary
May the force be with you.
my vim foo has increased by watching this video...tq
Super, super helpful...thanks man!
Use D instead of d$
Any acronyms or ideas why the creators would make gg the top and G the bottom of all possible letter combos?
Now H M L makes sense!
I would guess `g` was originally short for "go". As in 'go to line 72' (72gg), 'go to the method definition (gd)', 'go to the next tab' (gt), etc.
It's a common pattern for the single capital letter to relate to the end ('D' deletes until the end of the line, 'C' changes until the end of the line) and double-letter to relate to the bigger object ('dd' deletes the entire line, 'yy' yanks the entire line). G for the end of the file, gg for the start.
Just speculation. Or at least a way to remember :)
Daniel Deutsch , I like it, thanks!
Creators? You mean creator. As I understand it, vim is basically a pet project by Bram Molenaar, although it is open source so others have contributed. You can thank Google for its continued development too, as they hired Bram but allowed him to use his 20% time to maintain and develop vim.
nice vid, vry helpful - thx
The table for the pc/laptop was too low.
j and l skip 10 sec forward and backward in youtube player
k pauses
15:27 Summary
Cool video dude :) tnx Tom
how can I change my gvim font to be like th one used in the video? thanks.
Okay, 4 moths later...
In gVim type the command:
:set guifont=*
A menu pops out, choose the font you want (it will only show monospaced installed fonts i think).
That will last only for the current session, so after that do:
:set guifont?
That will show you the way Vim calls that specific font+settings (it varies depending on OS).
Copy that value to your .vimrc, something like:
set guifont=Source_Code_Pro:h11
To edit your .vimrc quickly you can do:
:e $MYVIMRC
Just type :e $M and it will autocomplete
[[ and ]] jump between C functions.
I always do 1G to go to the top (1st line), and 8G to go to the 8th line.
z. to move current line to middle of the screen - I notice it is different to zz since it moves to the start of the line
less keypresses to just do gg
Around 15:14 he says 'if you want to set a mark V in your vimrc'. Has anyone got that working? What's the syntax for running a normal mode command in vimrc>?
If you know that you open your vimrc a lot, you can set a global mark at the top of the file. Open ~/.vimrc and type mV at top of the file. (m for mark, V to use the V register. Any uppercase letter can be used instead of V.) Later, you can hit `V to jump to the mark. By default, uppercase marks are persisted between sessions.
More details are available here: vim.wikia.com/wiki/Using_marks
ah that makes a lot of sense. Thanks for the reply!
Folding is another good option.
Oh and tabs too.
": number Enter" is the same as "number gg"
It's so cool!!!
none of the Z or z commands worked for me in either vim or gvim 8.
Want to move up left down & right
Gamers: w a s d
Seems like everyone almost always assumes knowledge... great video but which he would have specified when specific commands needed to be upper case.
I was confused between z with g!
I almost never use zz because when I search for something Its automatically centering my screen, I set it up like that.
Nothing interesting in this video for me personally!
What blow off covering very much basic of VIM there are lot other videos more advance