Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open multiple files and switch between them in nano text editor?

Tags:

text

editor

nano

In emacs, you can open new files with Ctrl+X, Ctrl+F

And go to the previous file with Ctrl+B, and go to the next file with Ctrl+N.

How to do this in nano text editor? While nano is launched, and then open new files, and how to switch between the opened files in the nano text editor?

like image 653
s-hunter Avatar asked Nov 06 '13 15:11

s-hunter


People also ask

What does Ctrl k do in nano?

To delete the current line, press Ctrl-k . Saving your work: To save your edited file to disk, press Ctrl-o . Nano displays the current filename. (To save the file under a different name, delete the filename that Nano displays and type a new one.)

How do I search and replace in nano editor?

Find and Replace: Press Alt-R (hold down the ALT key and press the R key). You'll be asked what to search for. Enter it, then press the Enter or Return key. You'll be asked for replacement text.


2 Answers

Put "set multibuffer" into ~/.nanorc or start nano with -F. Toggle this inside nano with alt-F. You can now read files into their own buffer with ctrl-R.

Use alt-comma and alt-period to go forward and backward in the file list.

like image 75
Roger Pate Avatar answered Oct 05 '22 13:10

Roger Pate


To switch between open files in nano

alt+. -- move forward one file

alt+, -- move back one file

Steps

Open as many files as you want by listing them as separate arguments to nano, like so:

nano file1.txt file2.log file3.c file4.js file5.py 

The first file is opened, e.g. file1.txt. Use the keyboard shortcuts below to switch between the files.

alt+. -- move forward one file

alt+, -- move back one file

nano --version GNU nano, version 2.9.3

like image 21
activedecay Avatar answered Oct 05 '22 15:10

activedecay