Search code examples
unixvi

How to switch between multiple files in UNIX while using VI editor?


I'm new to UNIX. I am using VI editor to code for C programming. If I open multiple files at a time using VI editor like,

vi *.c

I can edit the first file only. If I press ":wq", it shows me that there are: "6 more files to edit"

How can I switch between those files?


Solution

  • Next file: :n

    Previous file: :p, :N or :prev depending on which vi implementation you're using.

    Here's a typical cheat sheet which has a section "Files" on this topic.

    http://www.lagmonster.org/docs/vi2.html