How do I open a file in Netrw in a vertical split instead of the current window?
Answer
v (netrw)
Explanation
When browsing files in Vim's built-in file manager (Netrw), pressing v on any file opens it in a vertical split to the right. Netrw offers a full set of single-key shortcuts for controlling how files are opened — knowing them eliminates the need to manually type :vs {filename} after navigating to a file.
How it works
With the cursor on a file or directory entry in Netrw:
<CR>orl— open in the current windowo— open in a horizontal splitv— open in a vertical splitt— open in a new tabp— open in the preview window (:pedit)
These shortcuts work in all Netrw views (:Explore, :Vexplore, :Sexplore, :Texplore).
Example
You open Netrw with :Explore and see:
" ============================================================
" Netrw Directory Listing
" ============================================================
../
src/
README.md
main.go
Navigate to main.go and press v. The layout becomes:
[Netrw] │ main.go
│
│
Tips
- Set
let g:netrw_altv = 1in your vimrc to makevopen splits on the right side (default is left) - Set
let g:netrw_preview = 1to makepopen previews vertically instead of horizontally - Combine with
:Lexplore(left-side explorer) andvto create a two-panel layout without any plugins - See
:help netrw-vfor the full reference