Linux Systems and Text Editor - LINUX: The Ultimate Beginner’s Guide! (2015)

LINUX: The Ultimate Beginner’s Guide! (2015)

Chapter 6: Linux Systems and Text Editor

This chapter will explain the importance of text editors in Linux operating systems. Additionally, it will teach you how to master text editors.

General Information About Text Editors

Why should you use this kind of tool?

As a Linux user, you must know how to use a text editor. The skill to use this tool is a necessary step to achieving proficiency and independence.

You have to master at least one editor since you will likely edit files in the Linux environment. File editing can be easily done using text editors. If you are an advanced user, you will utilize this type of tool when working on websites, books, scripts, and computer programs. Basically, mastering a text editor will vastly enhance your overall productivity and capabilities.

Which text editor should you choose?

This chapter focuses on text editors, which can be used for terminal windows and systems that lack a graphical interface. As a bonus, you can use text editors on remote computers. Because you are not required to send the whole graphical interface through the system, working with a text editor improves your efficiency and productivity.

Obviously, you have various methods to solve the problem. Here are some of the text editors being used for Linux systems:

GNU Emacs

Emacs is a customizable, versatile, self-documenting text editor that can display information in real-time. This editor is used on Linux and Unix operating systems. While you are typing commands, the screen will show and update the text you are working on. It is considered as “real-time” since it updates information frequently, often after every character you type. That means you can reduce the bulk of data you have to memorize while editing.

Computer users refer to it as an “advanced” tool since it allows them to do lots of things. Here are some examples: deletion and insertion of characters, managing subtasks, viewing multiple files simultaneously, modifying text files, and automated indentation of computer programs. Additionally, it allows users to work on text files in terms of lines, words, characters, sentences, pages, and paragraphs. Users may even use comments and expressions from various programming languages.

VIM

This tool was previously called “Vi Imitation.” However, the numerous improvements it experienced required a name change. Now, VIM means “Vi Improved.” Basically, this tool is an improved version of vi (i.e. a Unix text editor).

When using VIM, you can enter commands using your keyboard. That means you can keep your hands on your keyboard and your eyes on the computer screen. You don’t need to move the mouse so using this tool is simple and easy. If you prefer to use a mouse, however, you may activate it using the tool’s configuration page.

How to Use the VIM Editor

VIM is a powerful tool that contains a detailed pre-installed manual. To access the manual, you may run the :help command while VIM is running. This section of the book will teach you how to use this text editor.

VIM can be extremely confusing for beginners because it has two different modes: insert mode and command mode. This text editor will start in command mode 100% of the time. In general, commands help you to mark, search, and replace texts. The command mode also has a switch that you can use to initiate VIM’s insert mode.

Thus, every key has two potential uses: it may represent commands for the tool (while in command mode), or characters that you need to add (while in insert mode.)

The Basic Functions

How to Move Through Text Contents

You can use the arrow keys of your keyboard to move through texts. If this is not possible, you may:

· Press “k” to move the cursor upward

· Press “j” to move the cursor downward

· Press “l” to move the cursor to the right

· Press “h” to move the cursor to the left

· Use Shift + G to put the cursor at the end of the active text file.

The Basic Operations

Here are the well-known VIM commands:

· x – This deletes the character highlighted by the cursor.

· :n – This moves the cursor to line n of the document.

· :w – This saves (or writes) the document.

· :q – Use this command to exit the text editor.

· :wq – This command allows you to save the recent file changes and exit VIM.

· :q! – This command allows you to exit the program without saving the recent changes.

· n p – This command pastes the copied text n times.

· n dd – This deletes n lines from the cursor’s current position.

· n dw – This deletes n words to the right of the cursor.

· :w newfile – This command saves the document to “newfile.”

· :wq! – This overrides the read-only permission.

· /astring – This command searches the string in the document and places the cursor on the first result it finds.

· / - This command performs the previous search. Use this if you want to see the next search result.

· yy – This command copies text content.

· :recover – This command allows you to recover a document. Use this if you experienced a process interruption while editing or writing a text file.

The Commands That Allow You to Activate VIM’s Insert Mode

· a – Aside from triggering the insert mode, you can use this command to append data to existing files.

· i – This command can activate the insert mode and insert some data into an existing file.

· o – This command can also add a blank line on the cursor’s current position.

You can go back to the tool’s command mode by pressing the Escape key. In general, you can use this key if you aren’t sure about the mode you are currently using. You’ll know that you are in the command mode once you have pressed the Esc key.

An Easy Way

Rather than perusing the VIM manual, which can be extremely boring, you may trigger vimtutor to understand basic VIM commands. Vimtutor is a 30-minute tutorial that explains the fundamental VIM functions. With this tutorial, you’ll be a good VIM-user after completing eight simple exercises. Although you can’t master VIM in just 30 minutes, this learning material is created to explain sufficient commands. That means you’ll be skilled enough to use VIM as a multi-purpose text editor.

For Unix and Windows systems, if VIM was installed properly, you may initiate the program using either the shell or a command line. This method will create a new copy of the tutorial, allowing you to modify it without affecting the original file. As of now, this tutorial is available in different languages. To check if your language is available, you may utilize the two-letter code for languages. For English, this would be vimtutor en.