If you find yourself doing l repeatedly, look for a motion that will take you forward faster. To improve your navigation skill, here are my suggestions: Repeat them sufficiantly until you can use them without thinking. I recommend starting out with these 10 motions: h, j, k, l, w, b, G, /, ?, n. I think the best way to get started is to memorize a few essential motions. It takes time before you can execute them without thinking. I do not expect anyone to remember everything immediately. If you are new to Vim, this is a lot to learn. You can jump across different files, which I will discuss more in the next part. Why are jumps useful? Because you can navigate the jump list with Ctrl-O to move up the jump list and Ctrl-I to move down the jump list. Vim keeps track of where you've been when you move around and you can see this list inside :jumps. A good rule of thumb is, any motion that moves farther than a word and current line navigation is probably a jump. The syntax to use count with your motion is: I mentioned above that you can go down 12 lines with 12j. Vim motions accept a preceding numerical argument. Experiment with relativenumber / norelativenumber, number / nonumber and use whatever you find most useful! Count Your Move The less I have to think about where I need to go, the better. Doing math while editing takes too much mental resources. Otherwise, if I'm on line 69 and my target is on line 81, I have to do mental calculation (81 - 69 = 12). With this, I can easily spot that my target text is 12 lines below me so I can do d12j to delete them. Having a relative number allows me to quickly see how many lines apart my cursor is from the target text. It is easy why having a number on the left column is useful, but some of you may ask how having relative numbers on the left column may be useful. This displays my current line number and relative line numbers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |