Skip to content
Step by Step Internet 馃寪 Guides for learning to surf the Net

How to edit files in Linux operating system fast and easy? Step by step guide

The Linux terminals make use of a text editor called 'Vi' (Visual). A tool that allows you to copy, paste, move or delete characters from a file. If you want to know how to edit files in Linux operating system fast and easy, continue reading this step by step guide.

He Vi text editor It is used for the file creation. Currently, there is an improved version known as Vim (Vi Improved), so it is present in any system GNU / Linux.

Vim works as a command screen, so you can make spelling corrections, view multiple windows, among other functions.

What are the main commands used for editing files in Linux?

Text editors are command-based tools. Codes that are responsible for executing some function. However, What are the main commands used for editing files in Linux?

So much Vim how Saw are two editors popular for performing programming work on the operating system Linux. They both work as a command terminal. At first, the tools may seem complicated, but it should be noted that they are the most efficient in the area. For that reason, we provide you with a guide with the most useful commands. As Vim is an enhanced version of Vi, they share many of its basic commands.

Here is a list of the main ones:

Basic Vi and Vim Commands

  • (: q): It is the key combination used to exit the editor. The output is done without saving the information.
  • (: q!): The command causes the editor to close without saving the information. It does not matter if any changes have been made to any file.
  • (: wq): Used to save the information in a document and later close the editor.
  • (: filename): It fulfills the function of saving a document with a specific name.
  • (h, j, k, l): They are directional keys. Left, down, up and right. Although you can also use the keyboard arrows.

Vi and Vim editing commands

  • (d): The command is used to delete a character. Specifically, the one under the cursor.
  • (p): It is used to paste text.
  • (dd): Used to remove an entire line. It only affects the one under the cursor.
  • (dxd): The command fulfills the function of removing multiple lines. Begin erasing right at the line under the cursor.
  • (d + num): For example, D6. This command is used for a number of lines. If you type D6, six lines will be removed.
  • (nx): It is a command that removes a number of characters determined by the one right under the cursor.
  • (or): It is a command to undo an action performed.
  • (Ctrl + r): It performs the opposite function. Redo an action.
  • (gg): The command places you at the beginning of the file.
  • (Shift + g): It is used to go to the last line of a file.
  • (Num + G): The command places you on a specific line. For example, 10G. You will be redirected to line ten.
  • (: setnumber): The Vim editor takes care of displaying the numbers for each line.
  • (and): It is a command to move to the end of a line.
  • (w): It is a command to move to the beginning of a line.
  • (: h): It is the command that allows you to access the main help of the tool.
  • (/): It is used for searching. After pressing the ‘key/'You must enter the name of the file. To see the following results, you must press “n”. If you want to return to the previous results, press "N”.

What elements of the file can I modify in Linux?

What elements of the file can I modify in Linux?

Vim is a text editor with multiple functions. Therefore, the extensions of its use exceed those of its predecessor Saw. Its configuration options are abundant, and it is less complex than the previous version. So you can edit files faster. However, What elements of the file can you modify in Linux? The open source editor offers a variety of editing options.

Among which can be highlighted:

  • Autocomplete texts in insert mode.
  • Make corrections spelling from command mode.
  • Open multiple tabs to work different files.
  • Undo and make changes unlimitedly.
  • Run command strings to activate or record a macro.
  • Encrypt files worked in Vim.
  • Fold the text files to increase the visibility of it.

In the same way, the Vim text editor allows you to work with different modalities, they stand out:

  • Normal mode: It is the basic mode in which Vim runs. It allows you to copy, move, or format the text of a file.
  • Insert mode: It is used to edit, directly, the text of a file. Each key combination has a specific function.
  • Visual mode: It fulfills the function of highlighting the editing areas. It can be lines, characters or blocks of text.
  • Selection mode: This mode works to replace a piece of text with a new one.

Other modalities available in the text editor Vim They are: Command line mode and ex mode.

Learn step by step how to edit a file on your computer with Linux

Learn step by step how to edit a file on your computer with Linux

It is necessary access the Linux operating system terminal and enter the command Vim. The text editor will start to run, by default, in normal mode or command mode.

Then, learn step by step how to edit a file on your Linux computer:

Vim-file-name

To edit a file in the text editor Vim, you need to type the file name. For example, if the file is called “test.html”, The command to enter would be: Vim test.html.

Insert

On the main screen of Vim no indication appears. You may notice that you cannot write either. For the terminal to reflect what you type on the keyboard, you must press the 'i' key. You will notice that at the bottom of the screen appears the word "Insert" or "Insert".

ESC

Start writing or make the changes you want to add to the text of the file in question. Remember that you can use the list of commands mentioned above. For example, the arrow keys (h, j, k, l) to scroll through the file.

In the same way, you can press'd'To delete a character,'p'To paste a text or'or'To undo a change. When you're done, tap ESC. The ESC key it is used to return to command mode, from any of the other modes. You can see that the word "Insert" disappeared from the screen.

: wq – save

For save the file you just edited, you need to write two points followed by ‘Wq’ (: wq). This is the command to save. You need to press “Enter”To confirm saving.