*usr_22.txt* Nvim
VIM USER MANUAL - by Bram Moolenaar
Finding the file to edit
Files can be found everywhere. So how do you find them? Vim offers various
ways to browse the directory tree. There are commands to jump to a file that
is mentioned in another. And Vim remembers which files have been edited
before.
|22.1| The file browser
|22.2| The current directory
|22.3| Finding a file
|22.4| The buffer list
Next chapter: |usr_23.txt| Editing other files
Previous chapter: |usr_21.txt| Go away and come back
Table of contents: |usr_toc.txt|
==============================================================================
*22.1* The file browser
Vim has a plugin that makes it possible to edit a directory. Try this: >
:edit .
Through the magic of autocommands and Vim scripts, the window will be filled
with the contents of the directory. It looks like this (slightly cleaned up
so that it fits within 80 chars): >
" ===========================================================================
" Netrw Directory Listing (netrw v180)
" /path/to/vim/runtime/doc
" Sorted by name
" Sort sequence: [\/]$,*,\(\.bak\|\~\|\.o\|\.h\|\.info\|\.swp\)[*@]\=$
" Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:special
" ===========================================================================
../
./
check/
Makefile
autocmd.txt
change.txt
eval.txt
filetype.txt
help.txt.info
<
You can see these items:
1. The name of the browsing tool and its version number
2. The name of the browsing directory
3. The method of sorting (may be by name, time, or size)
4. How names are to be sorted (directories first, then `*.h` files,
`*.c` files, etc)
5. How to get help (use the <F1> key), and an abbreviated listing
of available commands
6. A listing of files, including "../", which allows one to list
the parent directory.
If you have syntax highlighting enabled, the different parts are highlighted
so as to make it easier to spot them.
You can use Normal mode Vim commands to move around in the text. For example,
move the cursor atop a file and press <Enter>; you will then be editing that
file. To go back to the browser use ":edit ." again, or use ":Explore".
CTRL-O also works.
Try using <Enter> while the cursor is atop a directory name. The result is
that the file browser moves into that directory and displays the items found
there. Pressing <Enter> on the first directory "../" moves you one level
higher. Pressing "-" does the same thing, without the need to move to the
"../" item first.
You can press <F1> to get help on the things you can do in the netrw file
browser. This is what you get: >
9. Directory Browsing netrw-browse netrw-dir netrw-list netrw-help
MAPS netrw-maps
<F1>.............Help.......................................|netrw-help|
<cr>.............Browsing...................................|netrw-cr|
<del>............Deleting Files or Directories..............|netrw-delete|
-................Going Up...................................|netrw--|
a................Hiding Files or Directories................|netrw-a|
mb...............Bookmarking a Directory....................|netrw-mb|
gb...............Changing to a Bookmarked Directory.........|netrw-gb|
cd...............Make Browsing Directory The Current Dir....|netrw-c|
d................Make A New Directory.......................|netrw-d|
D................Deleting Files or Directories..............|netrw-D|
<c-h>............Edit File/Directory Hiding List............|netrw-ctrl-h|
i................Change Listing Style.......................|netrw-i|
<c-l>............Refreshing the Listing.....................|netrw-ctrl-l|
o................Browsing with a Horizontal Split...........|netrw-o|
p................Use Preview Window.........................|netrw-p|
P................Edit in Previous