nano is a text editor for Unix-like computing systems or operating environments using a command line interface. It emulates the Pico text editor, part of the Pine email client, and also provides additional functionality. nano was first created in 1999 with the name TIP by Chris Allegretta. The name was changed to nano on 10 January 2000 to avoid a naming conflict with the existing Unix utility tip. In this tutorial, we will discuss the basic usage of the Nano editor, as well as some of the features it provides. The following screenshot shows the editor in action:
There are four main sections of the editor, the top line shows the program version, the current filename being edited, and whether or not the file has been modified. Next is the main editor window showing the file being edited. The status line is the third line from the bottom and shows important messages. The bottom two lines show the most commonly used shortcuts in the editor. The following sections explain the basic usage usage as well as some of the features of Nano.
1. To start nano editor just type 'nano' in your terminal
2. Now to write the typed text on a file, press 'Control + o', when you press that key combination than it will ask for file name for save the data in it.
after typing the filename just hit Enter and your file will be written.
3. To create a file at startup of nano, just give the file name as argument, and it will create the file
4. To open an existing file just put the file name as argument.
5. Cut and Paste text :
To cut and paste a perticular line, bring the cursor at that line and then press Control+k to cut , and go the line where you want to paste it. Than press Control+u to paste it. In the below screenshot we cut the first line 'This is a guide for nano text editor' by Control+k and paste it in the last line by Control+u.
We can also cut a particular word and paste it. To do this place the cursor at the beginning of the word or string and press Alt+a or Control+6, this will activate the Marking and now select the word or string portions by moving the arrow keys, then after the selection as usual press Control+k to cut and Control+u to paste the text.
in the above two screenshots, ‘Guide’ was selectively cut and pasted at the bottom.
6. Search and Replace words in nano :
To search a particular word just press Control+w, then it will for word you want to search
type the word and hit the enter, it will take you to the matched entry.
To replace a word with another keyword just press Control+\ , then it will ask for the word to be replaced.
after entering the word, press enter and it will ask for the replacement word.
After this, it will ask you to confirm the changes, to confirm it press a. Once confirmed, changes are made.
7. Place cursor on specific line and column at startup :
We can also place the cursor on specific line and column of a file at startup of nano editor. To do this just put the line number and column number at the first command line argument like this :
8. Backup previous version of a file :
In order to create a backup of a file before you edit it, just provide -B as first argument
9. Converting Tabs into Spaces :
To convert tabs into spaces just use -E flag as the first argument
10. Insert another file into Current opened file :
To insert the contents of another file into currently open one, press the Control+r button and give the path of the file which you want to copy the data into current one
at the above example we are copying data of data1.txt file into data2.txt file.
For help Menu press Control + g. These are the basics of nano text editor. now you can begin to use nano for text editing.
Thanks for visiting us.
There are four main sections of the editor, the top line shows the program version, the current filename being edited, and whether or not the file has been modified. Next is the main editor window showing the file being edited. The status line is the third line from the bottom and shows important messages. The bottom two lines show the most commonly used shortcuts in the editor. The following sections explain the basic usage usage as well as some of the features of Nano.
1. To start nano editor just type 'nano' in your terminal
$ nano
2. Now to write the typed text on a file, press 'Control + o', when you press that key combination than it will ask for file name for save the data in it.
after typing the filename just hit Enter and your file will be written.
3. To create a file at startup of nano, just give the file name as argument, and it will create the file
$ nano hello.txt
To save the contents press 'Control + o' and hit enter.4. To open an existing file just put the file name as argument.
$nano file.txt
and to save the modification in the file, press 'Control + o' and hit enter.5. Cut and Paste text :
To cut and paste a perticular line, bring the cursor at that line and then press Control+k to cut , and go the line where you want to paste it. Than press Control+u to paste it. In the below screenshot we cut the first line 'This is a guide for nano text editor' by Control+k and paste it in the last line by Control+u.
We can also cut a particular word and paste it. To do this place the cursor at the beginning of the word or string and press Alt+a or Control+6, this will activate the Marking and now select the word or string portions by moving the arrow keys, then after the selection as usual press Control+k to cut and Control+u to paste the text.
in the above two screenshots, ‘Guide’ was selectively cut and pasted at the bottom.
6. Search and Replace words in nano :
To search a particular word just press Control+w, then it will for word you want to search
type the word and hit the enter, it will take you to the matched entry.
To replace a word with another keyword just press Control+\ , then it will ask for the word to be replaced.
after entering the word, press enter and it will ask for the replacement word.
After this, it will ask you to confirm the changes, to confirm it press a. Once confirmed, changes are made.
7. Place cursor on specific line and column at startup :
We can also place the cursor on specific line and column of a file at startup of nano editor. To do this just put the line number and column number at the first command line argument like this :
$ nano +line,column [file_name]
example : $ nano +4,13 hello.txt
8. Backup previous version of a file :
In order to create a backup of a file before you edit it, just provide -B as first argument
$ nano -B [file_name]
example : $ nano -B hello.txt
The above command will create replica of file hello.txt with a ~(tilde) sign hello.txt~9. Converting Tabs into Spaces :
To convert tabs into spaces just use -E flag as the first argument
$ nano -E [file_name]
example : $ nano -E test.txt
10. Insert another file into Current opened file :
To insert the contents of another file into currently open one, press the Control+r button and give the path of the file which you want to copy the data into current one
at the above example we are copying data of data1.txt file into data2.txt file.
For help Menu press Control + g. These are the basics of nano text editor. now you can begin to use nano for text editing.
Thanks for visiting us.