Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vi

unix

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?

like image 537
Dinesh Avatar asked Nov 30 '11 10:11

Dinesh


People also ask

How do I switch between files in vi?

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.

How do I quickly switch between files in Vim?

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).

When multiple files are used with vi we can switch to next file using?

Explanation: When vi editor is used with multiple filenames, it loads the first file. We can switch to next file using :n command. 4.

What does shift 3 do in vi?

Now, when you press Shift+3, it will input # at current cursor position.


2 Answers

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

like image 140
tialaramex Avatar answered Sep 18 '22 01:09

tialaramex


For Linux Red-Hat VI version 7.2.411 use :n and :N to switch next and previous.

like image 34
Cesar Bravo Avatar answered Sep 20 '22 01:09

Cesar Bravo