Vim Navigation Commands

Поділитися
Вставка
  • Опубліковано 25 лис 2024

КОМЕНТАРІ • 110

  • @holalluis
    @holalluis 6 років тому +274

    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 6 років тому +10

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

    • @exwhyzd
      @exwhyzd 5 років тому +7

      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 5 років тому +1

      @@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
    @tyler9212 6 років тому +56

    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.

  • @creaczl
    @creaczl 4 роки тому +22

    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 4 роки тому

      Are you from the future?

    • @soham7510
      @soham7510 4 роки тому +3

      @@jerboas86 nope, I'm from future

    • @Sk8erMorris
      @Sk8erMorris 3 роки тому +2

      @@soham7510 take me w you

    • @soham7510
      @soham7510 3 роки тому +1

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

    • @ivymuncher
      @ivymuncher Рік тому

      @@soham7510 oh my fucking god you actually called it

  • @JamesSagerSC
    @JamesSagerSC 8 років тому +45

    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!

  • @BogoblinGamer
    @BogoblinGamer 3 роки тому +4

    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.

  • @jacderida
    @jacderida 9 років тому +62

    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 років тому +7

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

    • @blasttrash
      @blasttrash 4 роки тому +1

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

    • @wliaputs
      @wliaputs 4 роки тому +2

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

    • @miallo
      @miallo 3 роки тому +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

  • @ChrisCox-wv7oo
    @ChrisCox-wv7oo Рік тому +2

    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!

  • @haxpor
    @haxpor 5 років тому +20

    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

  • @marcosdiezgarcia
    @marcosdiezgarcia 3 роки тому +17

    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.

  • @sporadic3684
    @sporadic3684 5 років тому +43

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

  • @cMaXeJIJIo
    @cMaXeJIJIo 8 років тому +42

    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 7 років тому +2

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

    • @chintan357
      @chintan357 Рік тому

      jumping between sentences is awesome. thanks for that

  • @kafeltz
    @kafeltz 8 років тому +15

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

  • @ZionPerez
    @ZionPerez 10 місяців тому +2

    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

  • @TayakornRakwetpakorn
    @TayakornRakwetpakorn 6 років тому +10

    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 2 роки тому +3

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

  • @moskalenko2k24
    @moskalenko2k24 2 роки тому +4

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

  • @matobago
    @matobago 4 роки тому +4

    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.

  • @gladwinmohlamonyane4033
    @gladwinmohlamonyane4033 7 років тому +1

    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 6 років тому

      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 6 років тому

      It also works with #ifdef blocks.

  • @kuruptgt
    @kuruptgt 2 роки тому +2

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

  • @anteconfig5391
    @anteconfig5391 Рік тому +1

    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

  • @jcspaziano
    @jcspaziano 2 роки тому +1

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

  • @chris-ew9wl
    @chris-ew9wl 4 роки тому +3

    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 😁

  • @stephenstark9912
    @stephenstark9912 9 років тому +3

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

  • @m0nad539
    @m0nad539 5 років тому +1

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

  • @shokowillard
    @shokowillard 7 років тому +1

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

  • @skyeplus
    @skyeplus 6 років тому +26

    [{, ]} 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 6 років тому +1

      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 роки тому +3

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

  • @hkmix
    @hkmix 7 років тому +2

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

    • @skyeplus
      @skyeplus 6 років тому

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

  • @GevorgVardanyan
    @GevorgVardanyan 2 роки тому

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

  • @amr.sharaf
    @amr.sharaf 6 років тому

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

  •  8 років тому +1

    Very useful, love the format. Thanks!

  • @NamasenITN
    @NamasenITN 6 років тому +1

    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 років тому +9

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

    • @vnki
      @vnki 6 років тому +1

      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?

  • @reverseila4363
    @reverseila4363 4 роки тому

    Aewsome!!! Now i know the usecases too.

  • @AlqGo
    @AlqGo 5 років тому +4

    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 роки тому +1

      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.

  • @liminal27
    @liminal27 5 років тому

    SUPER helpful. Thanks!!!

  • @domaincontroller
    @domaincontroller 4 роки тому +1

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

  • @curioussravi
    @curioussravi 8 місяців тому

    May the force be with you.

  • @_slier
    @_slier 4 роки тому

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

  • @videogamesare1
    @videogamesare1 5 років тому

    Super, super helpful...thanks man!

  • @asdfkjhlk34
    @asdfkjhlk34 4 роки тому +3

    Use D instead of d$

  • @adriansrfr
    @adriansrfr 7 років тому

    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 років тому +4

      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 6 років тому

      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.

  • @rainstormr7650
    @rainstormr7650 6 років тому

    nice vid, vry helpful - thx

  • @thingsiplay
    @thingsiplay 4 роки тому

    The table for the pc/laptop was too low.

  • @hineko_
    @hineko_ 3 роки тому +2

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

  • @docteejay
    @docteejay 3 роки тому +1

    15:27 Summary

  • @Mrkindleify
    @Mrkindleify 9 років тому

    Cool video dude :) tnx Tom

  • @hassanhdach1344
    @hassanhdach1344 8 років тому

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

    • @frechjo
      @frechjo 7 років тому +4

      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

  • @preethamrangaswamy7371
    @preethamrangaswamy7371 5 років тому

    [[ and ]] jump between C functions.

  • @davidmaxwaterman
    @davidmaxwaterman 5 років тому

    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 роки тому +2

      less keypresses to just do gg

  • @sethcenterbar
    @sethcenterbar 6 років тому

    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 років тому +4

      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!

  • @randomness3235
    @randomness3235 3 роки тому

    Folding is another good option.

  • @dlinnoedlinnoe
    @dlinnoedlinnoe 2 роки тому

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

  • @oanngochoang9552
    @oanngochoang9552 5 років тому

    It's so cool!!!

  • @michaelvilain2357
    @michaelvilain2357 5 років тому

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

  • @anantgupta7916
    @anantgupta7916 3 роки тому

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

  • @Duffbeeryahoo
    @Duffbeeryahoo 3 роки тому

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

  • @rabinadk1
    @rabinadk1 5 років тому

    I was confused between z with g!

  • @frozen_tortus
    @frozen_tortus 7 років тому +1

    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
    @imrank340 3 роки тому

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