GIT FUNDAMENTALS - INTRODUCTION TO TEXT EDITORS

GIT FUNDAMENTALS - INTRODUCTION TO TEXT EDITORS

GIT FUNDAMENTALS - INTRODUCTION TO TEXT EDITORS

GIT FUNDAMENTALS - INTRODUCTION TO TEXT EDITORS

Welcome back, in our previous articles we defined the command line interface (CLI), why it is used by professionals, how to navigate the computer and files using the command line and more. We also compared the command line to the traditional graphical user interface (GUI) that we are used to and the advantages the command lint has over it. One of the most important advantages of the command line is its speed of executing commands, and evidence of this is the ease with which you can use text editors to create and edit text of other file formats with speed.

In this article we are going to be looking at the most text editors used in the command line interface that are also available in Git bash which you use for working with Github. Let us look at the topics for these articles and what you are expected to know after reading this article.

TOPICS

  1. What is the command line?
  2. What is a text Editor?
  3. Types of text Editors.
  4. Examples of most popular command line text editors.
  5. Introduction to Nano text editor.
  6. How to use a Nano text editor to create and edit text documents.
  7. Conclusions

WHAT IS THE COMMAND LINE INTERFACE

The command line, also called the windows command line, command screen, or text interface is a user interface that is navigated by typing commands at prompts, instead of using a mouse to control a cursor like in the regular graphical user interface format we are used to. The command line interface makes it very easy and fast to execute commands with the computer without loading unnecessary graphic resources.

WHAT IS A TEXT EDITOR?

A text editor is a tool that allows a user to create documents on a computer. Though this task can be carried out in other modes, the word text editor commonly refers to the tool that does this interactively. Earlier computer documents used to be primarily plain text documents, but nowadays due to improved input-output mechanisms and file format a document  can contain pictures along with texts whose appearance (script, size, color and style) can be varied within the document. Apart from producing output of such a wide variety, text editors today provide many advanced features of interactiveness and output.

All the above statements are trying to say simply that a text editor is used to create documents on a computer, while being able to provide features to enable us to add pictures and other interactive elements in documents on a computer. Take note that text editors do not only exist on the command line, they are also on the GUI we normally use.

TYPES OF TEXT EDITORS

There are different types of text editors, each for a different use case scenario and also based on the user functionality. Let us look at the types in use today.

  1. Line Editors
  2. Stream Editors
  3. Screen Editors
  4. Word Processors
  5. Structure Editors

For the main scope of this article, we will not go into full details and explanations of this articles but you can visit the following resource for more information.

This article will focus on the text editors that can be used on the command line ro perform editing tasks.

EXAMPLES OF MOST POPULAR TEXT EDITORS

The following text editors are the most popular and used text editors for developers and programmers, keep in mind that editors present on either the command line or GUI will be mentioned and then we can focus on the editors found on the command line.

Example: Vscode, sublime text, vi, vim, nano, Emacs, notepad, notepad++ and so much more.

For the purpose of this article we will be using “Nano” a lightweight text editor for simple document and file manipulations on the command line. 

The Emacs, vi and vim can be used but they are a bit complex and not too user friendly.

INTRODUCTION TO THE NANO TEXT EDITOR 

Nano is the default terminal based text editor in Ubuntu and many other Linux distributions. It is less complicated to use than other text editors like Vim and Emacs.

HOW TO USE NANO TEXT EDITOR TO CREATE AND EDIT FILES

Enough talk and explanations, let us write some code and get acquainted with the command line text editors. We are going to create a text file, save it and edit it again.

  1. Start your computer and open git bash to write your code.
  2. Be sure to change directory to one you will easily find later.
    cd desktop

  1. Create an empty file using the touch command with any name of your choice, see the code below. Remember to always add the file extensions like .txt or .js etc
    touch tutorial.txt



  1. Now we have to edit the file with nano, write the code below and replace the name with the file name you chose. I recommend a text file with a .txt extension for it.
    nano tutorial.txt



  1. Once you are in, write the content you want to be inside of the file, once you are done the next step is to save the file.
  2. On your computer type the following command ctrl + x.
  3. It will bring up some options asking you to save the file, select Y for yes and save the file.
  4. Congratulations, you have created your first file using a text editor on the command line.

HOW TO USE NANO TEXT EDITOR TO EDIT FILES

Editing files on nano is pretty simple, follow the steps below.

  1. Open the files by using the nano command then the filename
    nano tutorial.txt
  2. Simply make changes to files and key in ctrl + x to save and exit
  3. It's very simple and similar to creating a text file.

This tutorial article is pretty straightforward and focused on one thing, getting more used to coding on the command line and manipulating computer files with it. In the next article for this series, we will discuss more on committing and pushing files to Github with a more practical approach.

What's Your Reaction?

like

dislike

love

funny

angry

sad

wow