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?
4 Switching Files from vi. [ctrl-^] Since switching back to the previous file is something that tends to happen a lot, you don't have to move to the ex command line to do it. The vi command ^^ (the "control" key with the caret key) will do this for you.
The another method to open multiple files at once is by using either -o or -O flags. To switch between windows, press CTRL-w w (i.e Press CTRL+w and again press w).
Explanation: When vi editor is used with multiple filenames, it loads the first file. We can switch to next file using :n command. 4.
Now, when you press Shift+3, it will input # at current cursor position.
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
For Linux Red-Hat VI version 7.2.411 use :n and :N to switch next and previous.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With