Nikhil Pujari
Nikhil Pujari

Reputation: 163

Find file in vim, switch to next file without saving current file

Vim newbie here. I use :find command to open a file and make some changes. Suppose I want to open another file without saving the current changes, then how should I do it. What is the best way to list all open files and quickly open them again for editing. Thanks in advance.

Upvotes: 0

Views: 1649

Answers (1)

Brian Agnew
Brian Agnew

Reputation: 272237

:e! filename

will allow you to open a named file in a new buffer (note the exclamation mark overrides the warning re. an unsaved file).

CTRL-W + cursor 

will move between visible buffers and does not enforce the saving of your file as you navigate.

:buffers

will list your open buffers and allow you to navigate to each one (albeit with some cryptic flags indicating which buffers are visible/hidden/amended etc.)

:help buffers

will tell you about all the buffer-related features.

:help :wincmd

will tell you all about windows navigations

See also the VIM buffer FAQ

Upvotes: 1

Related Questions