How do I open the file under the cursor and jump to a specific line?
Answer
gF
Explanation
The gF command opens the file under the cursor and jumps to the line number that appears after the filename. This is useful for navigating error messages and stack traces.
How it works
gFis likegfbut also parses a line number after the filename- Recognizes patterns like
file.py:42orfile.py line 42 - Opens the file and positions the cursor on that line
Example
With a stack trace line:
File: src/main.py:142 - TypeError
With the cursor on the path, gF opens src/main.py and jumps to line 142.
Tips
gfopens the file but does not handle line numbers<C-w>gFopens the file in a new tab page<C-w>Fopens it in a new split with the line number- Add directories to
:set pathto help Vim find files