vim open file under cursor - 03-06-20
Half my time in the editor I’m not coding, I’m just browsing the file system trying to understand how things are connected. Trying figure out what needs to change in order to complete my task. This module imports this module which imports this module… There are many ways to navigate the file system and read files. Since I primarily code in VIM there are two main ways I navigate.
One is using the file explorer from plugin, NerdTree. It is great for getting a general overview of folder structure of a project and moving, deleting, or creating new files. Also really good for finding sibling files using the :NerdTreeFind command which I have remapped to
This is where the goto file comes in. Using the following commands in conjunction with moving up and down the jump list, navigation is easy. Here is an example where I use the goto command and a few of its variations.
demo using vim's goto and jumplist commands
The most helpful ones to learn are
- <g><f> goto file, same window
- <c-w><f> goto file, new split
- <c-w><g><f> goto file, new tab
Also don’t forget to use the jump list
- <c-o> or in my case remapped to <Leader><i> to jump backwards
Resources: