Vim Navigation Commands

Ғылым және технология

Vim Navigation Commands: Sequences You Have No Excuse Not to Know!
Learn more from the developers at thoughtbot ⌨️
Head over to tbot.io/dev-blog to read more great articles on our blog.

Пікірлер: 110

  • @holalluis
    @holalluis6 жыл бұрын

    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

  • @skyeplus

    @skyeplus

    5 жыл бұрын

    I used to use undo-redo for that. Many thanks.

  • @exwhyzd

    @exwhyzd

    5 жыл бұрын

    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.

  • @90hijacked

    @90hijacked

    4 жыл бұрын

    @@exwhyzd and navigates the same list does but in reverse

  • @333peacher4

    @333peacher4

    4 жыл бұрын

    @@skyeplus Always thought Vim is too thoughtful.

  • @coffeedude

    @coffeedude

    4 жыл бұрын

    @@90hijacked what does this kind of notation mean?

  • @tyler9212
    @tyler92126 жыл бұрын

    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.

  • @lonnybulldozer8426

    @lonnybulldozer8426

    2 жыл бұрын

    Agreed.

  • @BogoblinGamer
    @BogoblinGamer3 жыл бұрын

    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.

  • @speakthetruth3684
    @speakthetruth36845 жыл бұрын

    Makes me wonder why people risk their lives looking for Gold in white water rapids when it's right here on KZread.

  • @ChrisCox-wv7oo
    @ChrisCox-wv7oo Жыл бұрын

    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!

  • @creaczl
    @creaczl4 жыл бұрын

    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!

  • @jerboas86

    @jerboas86

    3 жыл бұрын

    Are you from the future?

  • @soham7510

    @soham7510

    3 жыл бұрын

    @@jerboas86 nope, I'm from future

  • @Sk8erMorris

    @Sk8erMorris

    3 жыл бұрын

    @@soham7510 take me w you

  • @soham7510

    @soham7510

    3 жыл бұрын

    @@Sk8erMorris believe me, its dark out here in future

  • @ivymuncher

    @ivymuncher

    Жыл бұрын

    @@soham7510 oh my fucking god you actually called it

  • @marcosdiezgarcia
    @marcosdiezgarcia3 жыл бұрын

    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.

  • @JamesSagerSC
    @JamesSagerSC8 жыл бұрын

    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!

  • @kafeltz
    @kafeltz7 жыл бұрын

    Learning `vim` is so pleasant that I learn something new (and useful) everywhere I go, as this video.

  • @jacderida
    @jacderida8 жыл бұрын

    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.

  • @ryanevius

    @ryanevius

    5 жыл бұрын

    And for reasons unknown to me, Y yanks the entire line, instead of doing the same thing as y$

  • @blasttrash

    @blasttrash

    4 жыл бұрын

    @@ryanevius yeah that breaks D and C. I made that mistake so many times thinking Y would copy till end of line.

  • @wliaputs

    @wliaputs

    3 жыл бұрын

    @@ryanevius that’s why I remap “Y” as “y$” lol

  • @miallo

    @miallo

    3 жыл бұрын

    @@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

  • @haxpor
    @haxpor4 жыл бұрын

    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)

  • @chintan357

    @chintan357

    Жыл бұрын

    thanks for those extra section

  • @cMaXeJIJIo
    @cMaXeJIJIo7 жыл бұрын

    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.

  • @monugupta32

    @monugupta32

    6 жыл бұрын

    Yeah, i use {} heavily when skimming through code up & down in chunks

  • @chintan357

    @chintan357

    Жыл бұрын

    jumping between sentences is awesome. thanks for that

  • @shokowillard
    @shokowillard6 жыл бұрын

    Great job thought i knew everything about navigiation. You always learn something new in Vim

  • @multithread_cat
    @multithread_cat2 жыл бұрын

    gd - go to definition of word (function, class etc) under cursor gf - go to file under cursor

  • @stephenstark9912
    @stephenstark99128 жыл бұрын

    Great talk and I did learn a couple more tricks! Keep the vim info coming!

  • 7 жыл бұрын

    Very useful, love the format. Thanks!

  • @amr.sharaf
    @amr.sharaf5 жыл бұрын

    thanks for sharing, I found the scrolling commands really handy.

  • @TayakornRakwetpakorn
    @TayakornRakwetpakorn6 жыл бұрын

    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.

  • @adrianklamut8533

    @adrianklamut8533

    Жыл бұрын

    I think about them as e - elder numbers y - younger numbers

  • @matobago
    @matobago4 жыл бұрын

    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.

  • @liminal6823
    @liminal68235 жыл бұрын

    SUPER helpful. Thanks!!!

  • @kuruptgt
    @kuruptgt2 жыл бұрын

    set scrolloff=99 " Keeps current line in the middle so your searched words will be centered.

  • @GevorgVardanyan
    @GevorgVardanyan Жыл бұрын

    Thank you so much. It was very helpful and useful.

  • @gladwinmohlamonyane4033
    @gladwinmohlamonyane40336 жыл бұрын

    that percentile command... really appreciate it. Don't always know the line I'm looking for so this is helpful.

  • @hlf_coder6272

    @hlf_coder6272

    6 жыл бұрын

    Gladwin Mohlamonyane Agreed. I didn't know that one either and it seems so obvious now that I've heard it. Very useful

  • @yvrelna

    @yvrelna

    5 жыл бұрын

    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.

  • @skyeplus

    @skyeplus

    5 жыл бұрын

    It also works with #ifdef blocks.

  • @reverseila4363
    @reverseila43634 жыл бұрын

    Aewsome!!! Now i know the usecases too.

  • @anteconfig5391
    @anteconfig5391 Жыл бұрын

    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

  • @chris-ew9wl
    @chris-ew9wl3 жыл бұрын

    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 😁

  • @Mrkindleify
    @Mrkindleify8 жыл бұрын

    Cool video dude :) tnx Tom

  • @rainstormr7650
    @rainstormr76506 жыл бұрын

    nice vid, vry helpful - thx

  • @hkmix
    @hkmix7 жыл бұрын

    To clear whitespace, :s/ *$ is pretty convenient and a little easier than recording a macro.

  • @skyeplus

    @skyeplus

    5 жыл бұрын

    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).

  • @m0nad539
    @m0nad5394 жыл бұрын

    Go to matching bracket is % ... can't live without that.

  • @jcspaziano
    @jcspaziano2 жыл бұрын

    Im here because I feel chided by "You Have No Excuse Not to Know!" haha

  • @oanngochoang9552
    @oanngochoang95525 жыл бұрын

    It's so cool!!!

  • @hassanhdach1344
    @hassanhdach13447 жыл бұрын

    how can I change my gvim font to be like th one used in the video? thanks.

  • @frechjo

    @frechjo

    7 жыл бұрын

    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

  • @curioussravi
    @curioussravi3 ай бұрын

    May the force be with you.

  • @_slier
    @_slier4 жыл бұрын

    my vim foo has increased by watching this video...tq

  • @adriansrfr
    @adriansrfr7 жыл бұрын

    Any acronyms or ideas why the creators would make gg the top and G the bottom of all possible letter combos?

  • @adriansrfr

    @adriansrfr

    7 жыл бұрын

    Now H M L makes sense!

  • @danieldeutsch1595

    @danieldeutsch1595

    7 жыл бұрын

    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 :)

  • @adriansrfr

    @adriansrfr

    7 жыл бұрын

    Daniel Deutsch , I like it, thanks!

  • @CaptainAardvaark

    @CaptainAardvaark

    5 жыл бұрын

    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.

  • @michaelvilain2357
    @michaelvilain23574 жыл бұрын

    none of the Z or z commands worked for me in either vim or gvim 8.

  • @sethcenterbar
    @sethcenterbar6 жыл бұрын

    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>?

  • @danieldeutsch1595

    @danieldeutsch1595

    6 жыл бұрын

    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

  • @sethcenterbar

    @sethcenterbar

    6 жыл бұрын

    ah that makes a lot of sense. Thanks for the reply!

  • @ZionPerez
    @ZionPerez6 ай бұрын

    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

  • @NamasenITN
    @NamasenITN6 жыл бұрын

    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.

  • @danieldeutsch1595

    @danieldeutsch1595

    6 жыл бұрын

    Slides are available here: docs.google.com/presentation/d/1v1pTy_WLSDx1krxDIPD379YyZJoMEsubcYOaqcwEj-8/

  • @vnki

    @vnki

    6 жыл бұрын

    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?

  • @AlqGo
    @AlqGo5 жыл бұрын

    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.

  • @andresorrego6778

    @andresorrego6778

    4 жыл бұрын

    Another thing you can do is to press . (Dot) to repeat the last action.

  • @blasttrash

    @blasttrash

    4 жыл бұрын

    you can try easymotion or quickscope plugin. not sure how useful these are since I am still new to vim.

  • @skyeplus
    @skyeplus5 жыл бұрын

    [{, ]} 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

  • @mamandroid

    @mamandroid

    5 жыл бұрын

    Thank you that's going to help me a lot!

  • @wulymammoth

    @wulymammoth

    4 жыл бұрын

    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 🙏

  • @wulymammoth

    @wulymammoth

    4 жыл бұрын

    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

  • @skyeplus

    @skyeplus

    4 жыл бұрын

    @@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.

  • @wulymammoth

    @wulymammoth

    4 жыл бұрын

    @@skyeplus thanks I literally found the answer last night by Googling and going through enough links, but thank you so much for these :D

  • @hineko_
    @hineko_3 жыл бұрын

    j and l skip 10 sec forward and backward in youtube player k pauses

  • @thingsiplay
    @thingsiplay3 жыл бұрын

    The table for the pc/laptop was too low.

  • @domaincontroller
    @domaincontroller4 жыл бұрын

    08:10 | 10:12 within A line navigation15:22 summary

  • @preethamrangaswamy7371
    @preethamrangaswamy73714 жыл бұрын

    [[ and ]] jump between C functions.

  • @docteejay
    @docteejay3 жыл бұрын

    15:27 Summary

  • @rabinadk1
    @rabinadk14 жыл бұрын

    I was confused between z with g!

  • @asdfkjhlk34
    @asdfkjhlk343 жыл бұрын

    Use D instead of d$

  • @randomness3235
    @randomness32353 жыл бұрын

    Folding is another good option.

  • @randomness3235

    @randomness3235

    3 жыл бұрын

    Oh and tabs too.

  • @davidmaxwaterman
    @davidmaxwaterman5 жыл бұрын

    I always do 1G to go to the top (1st line), and 8G to go to the 8th line.

  • @davidmaxwaterman

    @davidmaxwaterman

    5 жыл бұрын

    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

  • @jacobscrackers98

    @jacobscrackers98

    4 жыл бұрын

    less keypresses to just do gg

  • @dlinnoedlinnoe
    @dlinnoedlinnoe Жыл бұрын

    ": number Enter" is the same as "number gg"

  • @Duffbeeryahoo
    @Duffbeeryahoo3 жыл бұрын

    Seems like everyone almost always assumes knowledge... great video but which he would have specified when specific commands needed to be upper case.

  • @anantgupta7916
    @anantgupta79163 жыл бұрын

    Want to move up left down & right Gamers: w a s d

  • @frozen_tortus
    @frozen_tortus7 жыл бұрын

    I almost never use zz because when I search for something Its automatically centering my screen, I set it up like that.

  • @frozen_tortus

    @frozen_tortus

    7 жыл бұрын

    Nothing interesting in this video for me personally!

  • @imrank340
    @imrank3403 жыл бұрын

    What blow off covering very much basic of VIM there are lot other videos more advance

  • @videogamesare1
    @videogamesare15 жыл бұрын

    Super, super helpful...thanks man!

Келесі