Site icon UnixArena

Quick vi editor hacks for DevOps Engineers

DevOps engineers have to work on a wide range of toolsets to meet the organization’s requirements. In the DevOps role, one tool is going to stay forever to make an engineer’s life simple and more powerful. As the article heading says, it is “vi” editor. The “vi” editor is created by Bill Joy in 1976 for Unix operating systems. Though it has been created 46 years ago, still “vi” editor is one of the most widely used text editors in the world. “vi” editor is mostly found in *nix operating systems and doesn’t feature on the windows operating system. In the DevOps world, engineers more often need to play around with Linux instances, and “vi” editors can’t be avoided.

Once Dennis Ritchie said,

UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity.

But this quote is complementing the “vi” editor as well. This editor looks simple but more powerful than you think. In this article, I will share 10 “vi” hacks to make the job easier. These “vi” tips and tricks will increase productivity for sure. This article is intended for Linux/Unix beginners.

To open a file using the vi editor, (vi file_name)

[lingesh@okd4 ~]$ vi redis_ep.yaml
  1. To set line numbers
vi editor – set line numbering

2. To insert a specific character at the beginning of the line.

Insert space beginning of the line

3. To insert a specific text at the beginning of specific lines.

Inserted text beginning of specific lines – vi editor

4. To search specific text in the “vi” editor.

search text in vi editor

5. To perform search and replace operation on the current line.

Search and replace on current line – vi editor

6. To perform search and replace operation on the complete file.

Search and replace on file – vi editor

7. To perform a search and replace a range of lines in the file,

Search and replace on a range of lines – vi editor

8. How to select the text in the vi editor?

Select the text in the vi editor

9. To Convert to Upper and Lowercase or vice-versa

Convert the text to UPPER case – vi editor

10. To delete the selected lines on the vi editor, simply enter “dd” (delete lines).

Hope this article is informative to you.

Exit mobile version