Basic Editors in Linux
Table of contents
We all remember opening Notepad or Wordpad on our personal computers and typing away. It was one of the first things we did on our systems for most people.
Creating and working with files is a very basic aspect of learning any Operating System. The same goes for Linux. Linux also has text editors similar to our Notepad or Wordpad. Let me get you introduced with a few-
-Nano Editor
It is a very easy, beginner-friendly text editor that operates with simple keyboard commands which are easy to understand as we are familiar with using keyboard shortcuts in Windows. All these commands are displayed at the bottom of the screen. No worries even if you forget some!
To create a file with Nano simply type- nano file-name
This opens the editor and you can start typing right away.
Save what you have written and exit the editor by pressing Ctrl + 0 and then press Enter.
If you wish to exit without saving the changes you have made, press Ctrl + X.
Many more commands help you with functions such as cut, copy, paste, search, replace, undo, etc. Go ahead and explore those!
-Vi and Vim Editor
Both are terminal-based editors that come preinstalled with most Linux distributions. They are fast and have powerful features that when mastered can increase your productivity by helping you do a lot more than just basic text editing.
Vi stands for "Visual Editor" and Vim stands for "Vi Improved".
While Vi has been around for a long time, Vim is an extended and improved version of Vi with more features and enhancements.
-To create a file using Vi, type vi file-name
-To create a file using Vim, type vim file-name
They both have two modes, one is the command mode and the other is the insert mode.
-Insert mode lets you edit the text you are writing. Press Insert to switch to this mode.
-Command mode helps you navigate the file and perform actions using commands. You cannot edit the file in this mode. This is the default mode when you open a file using Vi or Vim. Press Escape to go to command mode.
Once you have finished editing, press escape to switch to the command mode and type :wq!
:w
- saves the file.
:q
- quits the file. This command alone quits the file without saving it.
!
- quits the file forcefully
Both Vi and Vim may seem difficult and intimidating at first but with practice, they can be extremely useful, especially for tasks involving programming.
So, there you have it! What are you waiting for, go ahead and have fun learning and exploring these editors!
Subscribe to my newsletter
Read articles from Kajal Upadhyay directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by