Editing Viewing Text files using Nano text editor RHEL 7

There are many Text Editors are available to edit text files. Most easy to edit text files using Nano editor. It will work just like Notepad in Windows Operating system. Let’s see Editing Viewing Text Files Using Nano text Editor in RHEL 7.  Nano Text editor created as TIP – This isn’t PICO editor.

Advantages of Nano Text Editor

  • Nano Provides more features than PICO
  • Colored Text for writing scripting languages .i.e.C, C++, Shell Scripting and Perl …Etc
  • Smoothing Scrolling
  • Simple Control Keys
  • Regular Expression support to Search Text in file
  • Multiple Buffers to Do Undo, Redo and Edit Text

Editing Viewing Text Files Using Nano Text Editor

Syntax : nano <file name>

Viewing Text file and Adding Data to Text file I am just opening ‘arkit’ file using nano.

[root@puppet ~]# nano arkit

Moving Curser Around

To Move Curser UP / DOWN / Left Side / Right Side we have to Use keyboard arrow keys.

KeyBoard Arrow Keys to Navigate Curser Around

Keyboard Arrow Keys to Navigate Curser Around

Jump Curser from Line beginning to Ling Ending keys. By Pressing CTRL + A key go to Current Begining of the Line and CTRL + E to End of Current Line.

Ctrl+A Go to beginning of current line

Ctrl+A Go to beginning of current line

Ctrl+E Go to end of current line

Ctrl+E Go to end of current line

Move Curser around the paragraph’s using shortcut keys. Use ALT + (  Go to the beginning of a paragraph, then of the previous paragraph. ALT + ) Go to End of the paragraph, then Next end of Paragraph. 

Go just beyond end of paragraph; then of next paragraph

Go just beyond end of paragraph; then of next paragraph

Go to beginning of paragraph; then of previous paragraph

Go to beginning of paragraph; then of the previous paragraph

Read Page by Page

If you’re opening a text file which contains more than two are more pages then you may require to switch from one page to another page using simple shortcut keys in nano Text Editor.

Using ALT + \ Go to the first line of the page    

Press ALT + \ Key Go to the first line of the page

Press ALT + \ Key Go to the first line of the page

Go to the Last Line of the Page ALT + / 

Press ALT + / Go to Last Line of the Page

Press ALT + / Go to the Last Line of the Page

Moving Curser within Paragraph

We can Use CTRL + F Go Forward One character and CTRL + B Go Backward one character, simply using arrow keys also we can move cursor

Go fast move word by word using CTRL + SPACE BAR and ALT + SPACE BAR to Back one word by word

Moving Curser Line by Line Up and Down by Pressing CTRL + P keys to go Previous Line and CTRL + N Keys to Go Next Line.

Copy Text and Paste

Multiplying the Text by Copy & Paste Lines by Lines. Using Nano Text Editor we can copy Selected lines and single-line also, Press ALT + 6 Copy Current cursor position Line to Copy Buffer space.

Paste Copied Text using CTRL + U Or F10 Function Key

Cut Text using CTRL + K Or F9 Function Key, Using CTRL + U Paste the Cut Buffer Text.

Bulk Lines Cut using ALT + T  from the cursor position to the end of the file

Inserting and Deleting

Inserting Same word by Word, Line by Line using ALT + V Insert the next keystroke verbatim
Tab at the cursor position Insert Using Ctrl + I which is very useful to adjust content
Newline at the cursor position Using Ctrl + M Keys Editing Viewing Text Files
Delete Single character which is under the cursor Using Ctrl + D
Ctrl + H Delete the character to the left of the cursor, Meaning deleting from left to right

Indent and Unindent 

Indent the current line Using Keys ALT + } space left between the margin and the start of an indented line. Adding tab space to starting of the Line.
Unindent the current line ALT + { Removing added tab space from starting of the Line

Find and Replace String

Search page Text using a regular expression, We can search text within the opened text file pressing CTRL + W key, Repeating search keyword using ALT + W key.

Replacing particular word using Ctrl + \ Or ALT + R  Replace a string or a regular expression. 

Search to replace word

Search to replace word

Replace With Word

Replace With Word

Press Confirm Yes

Press Yes, No, ALL

Replaced Words Count

Replaced Words Count

Scrolling Up and Down without Scrolling Cursor

Moving the Text Up without scrolling cursor Press Keys ALT+ – Or ALT + _ Scroll up one line
ALT + + Or ALT + = Scroll down one line without scrolling the cursor

Go to Particular Line Using Shortcut Key ALT + G  Or CTRL + _

If you Cut Or Copy the Text it will hold by buffer size, to switch between the versions of previous and Next File Buffer Use ALT + < Or ALT + , for Previous File Buffer and ALT + > Or ALT + . for Next File Buffer

Enabling and Disabling Help Mode

Help Mode Disabled

Help Mode Disabled

Help Mode Enabled

Help Mode Enabled

Pressing ALT + X to enable and disable Help Mode

ALT + C key to enable and disable Constant cursor position Display Editing Viewing Text Files

Enabled and Disabled Constant cursor postion

Enabled and Disabled Constant cursor position

Save (Unload Buffer) and Exit from File

Ctrl + X (F2) Close the current file buffer / Exit from nano
Ctrl + O (F3) Write the current file to disk

Enabling Colored Text to highlight programming code

By default whenever you edit the program code using nano text editor you can’t see colors, syntax highlight colors. To come in color we have to change few settings in nano Text Editor configuration file.

Nano will support at a time one type of programing language.

Edit below mentioned file and un-comment your favorite programming language. I have enabled perl programming support.

#nano /etc/nanorc
## Nanorc files
# include "/usr/share/nano/nanorc.nanorc"

## C/C++
# include "/usr/share/nano/c.nanorc"

## HTML
# include "/usr/share/nano/html.nanorc"

## TeX
# include "/usr/share/nano/tex.nanorc"

## Quoted emails (under e.g. mutt)
# include "/usr/share/nano/mutt.nanorc"

## Patch files
# include "/usr/share/nano/patch.nanorc"

## Manpages
# include "/usr/share/nano/man.nanorc"

## Groff
# include "/usr/share/nano/groff.nanorc"

## Perl
 include "/usr/share/nano/perl.nanorc"

## Python
# include "/usr/share/nano/python.nanorc"

## Ruby
# include "/usr/share/nano/ruby.nanorc"

## Java
# include "/usr/share/nano/java.nanorc"

## Assembler
# include "/usr/share/nano/asm.nanorc"

## Bourne shell scripts
# include "/usr/share/nano/sh.nanorc"

## POV-Ray
# include "/usr/share/nano/pov.nanorc"

Nano colored Output

That’s it about Nano Text Editor. Editing Viewing Text Files

Related Articles

25 Linux Basic Commands

sed command 20 practical examples

ls command with 25 practical examples

Thanks for your wonderful Support and Encouragement

blank

Ravi Kumar Ankam

My Name is ARK. Expert in grasping any new technology, Interested in Sharing the knowledge. Learn more & Earn More

Leave a Reply

Your email address will not be published. Required fields are marked *