How do I open a file under the cursor in a new split and jump directly to the line number?
Answer
<C-w>F
Explanation
<C-w>F opens the filename under the cursor in a new horizontal split, and if the filename is followed by a colon and a number (e.g. src/app.go:42), Vim jumps directly to that line. This is the split-window companion to gF, and is invaluable when reading compiler errors, grep output, or stack traces that embed file paths with line references.
How it works
<C-w>— prefix for window (split) commandsF— open the file under the cursor in a new split, with line number support (uppercaseF= with line jump)- The cursor scans forward from its position to find a filename pattern
- If
filename:Nis detected, the cursor is placed on line N in the opened file - Compare with the related family:
gf— open in same window, no line numbergF— open in same window, with line number<C-w>f— open in new split, no line number<C-w>F— open in new split, with line number
Example
Your terminal shows a compile error:
src/parser.go:87: undefined: tokenize
With the cursor on that line (e.g. after :r !go build 2>&1), pressing <C-w>F opens src/parser.go in a new split and positions the cursor on line 87, ready to fix the error.
Tips
- Use
<C-w>gFto open in a new tab (with line number) instead of a split - Combine with
<C-w>_to maximize the new split after opening - Works with paths relative to the current working directory or anywhere in
'path' - Particularly useful after
:makeor:vimgrepwhen manually inspecting output