C.W.K.
Stream
Lesson 02 of 04 · published

File Explorer and Built-in Completion

~11 min · vim, netrw, completion

Level 0Trapped
0 XP0/35 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete

Vim has a built-in file explorer

You don't need NerdTree or neo-tree to browse files. Vim ships with netrw, a directory editor where each line is a file or folder. :Explore (or :e .) opens the current directory; navigate with normal motions; press Enter to open.

Netrw commands inside the explorer

  • Enter — open file or descend into directory.
  • - — go up one directory.
  • % — create a new file (you'll be prompted for the name).
  • d — create a new directory.
  • D — delete the file/directory under the cursor.
  • R — rename.
  • i — cycle list styles (thin, long, wide, tree).

Letting Vim suggest completions

You don't need a plugin to get useful completion. Inside Insert mode, Ctrl-n scans every open buffer for words that match what you've typed and offers them. Ctrl-p does the same in reverse. It's the surprise tool — limited compared to a full LSP, but free, instant, and works on any server.

The Ctrl-x sub-menu

Ctrl-x in Insert mode opens a smaller completion menu where each follow-up key picks a different source. The ones to know:

  • Ctrl-x Ctrl-f — filename completion. Type a partial path and Vim completes it from the filesystem.
  • Ctrl-x Ctrl-l — whole-line completion. Type the start of a line, Vim suggests entire matching lines from open buffers.
  • Ctrl-x Ctrl-o — omni-completion (language-aware, when configured).
  • Ctrl-x Ctrl-n — keywords from the current file only.
  • Ctrl-x Ctrl-k — dictionary words (set dictionary=/usr/share/dict/words first).
The free fuzzy match: on emergency-mode boxes with no plugins installed, Ctrl-x Ctrl-l is shockingly useful for duplicating long lines or function-call patterns. It's not LSP, but it's enough to keep you productive on a fresh server.

Code

Open and navigate netrw·vim
:Explore           " netrw in current window
:Sexplore          " horizontal split + netrw
:Vexplore          " vertical split + netrw
:Lexplore          " left sidebar (toggle)
:e .               " same as :Explore

" Inside netrw:
<Enter>            " open file / cd into dir
-                  " go up one dir
%                  " new file
d                  " new directory
D                  " delete
R                  " rename
i                  " cycle list styles
Insert-mode completion — no plugins required·vim
Ctrl-n             " next match (keywords from open buffers)
Ctrl-p             " previous match
Ctrl-x Ctrl-f      " filename completion
Ctrl-x Ctrl-l      " whole-line completion
Ctrl-x Ctrl-o      " omni-completion (language-aware)
Ctrl-x Ctrl-n      " keywords from current file only
Ctrl-x Ctrl-k      " dictionary completion

External links

Exercise

Open Vim with no plugins (vim -u NONE if you want a purist run). Use :Explore to browse to any directory, create a new file with %, type a few lines, save, then go back to netrw with :e .. In Insert mode in any file, trigger filename completion by typing part of a path and pressing Ctrl-x Ctrl-f. The point: Vim is more capable bare than people remember.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.