July 3 2023

Practical guide to the VI editor for Linux. History, commands and practical use.

VI for UNIX and for Linux systems. Your Ultimate Guide to the Most Powerful and Versatile Text Editor ever developed.

VI Logo Editor

If you are a system administrator or an avid Linux user, the VI text editor is probably a constant traveling companion on your computing journey. This dynamic tool, originally born in the Unix environment, is an unmistakable icon in the Linux world, standing out for its power and versatility. You will hardly find a UNIX operating system or a Linux distribution where VI is not present, whether it is an enterprise server or an embedded system.

VI is not just an ordinary text editor, it is a sophisticated text editing platform, a powerful interface that combines the simplicity of text input with the ability to perform complex and customizable operations on the text itself. This combination of power and flexibility has made VI a must-have for any professional or enthusiast working in the Linux world.

In this article, we aim to take you on a journey of discovering and learning about the VI editor. We will not only introduce you to its history and distinctive features, but we will also guide you through the practical use of VI, teaching you its fundamental commands and its most useful operating practices. Whether you are a novice looking to learn the basics or a veteran looking to hone your skills, you will find in these pages a wealth of information that will help you master VI.

And to help you on your journey, we've included a handy VI command cheat sheet at the end of this post. This quick reference tool will give you an instant guide to the most common VI commands, allowing you to use VIs with greater efficiency and confidence. So, if you're ready to learn more about one of the most powerful and versatile text editors available, read on and discover the world of VI.

History and Popularity of VI

In the digital age, the advent of new tools and technologies is a common phenomenon. However, there are some gems that stand the test of time and continue to reign despite the flood of innovations. One such specimen is the VI text editor. Before diving into the technical details and practical applications of VI, we invite you to join us on an intriguing journey through its fascinating history.

VI, which stands for 'Visual', is a text editor that first appeared in the computing landscape in the late 70s. This wonder was designed and developed by Bill Joy (considered the father of Solaris, the operating system that accompanied Sun's business around the world Unix) for the Unix operating system. At the time, computing was still an infancy field, and VI represented a cornerstone in the text editor landscape due to its unique and innovative design.

Vinod Khosla, Bill Joy, Andy Bechtolsheim, Scott McNealy Sun Microsystems
Vinod Khosla, Bill Joy, Andy Bechtolsheim, Scott McNealy at Sun Microsystems

Since that distant debut, the VI editor has seen a phenomenal rise in popularity. Its presence is not limited to the original Unix operating system; VI has found its way into a huge number of operating systems, becoming a fundamental component of any UNIX system or Linux distribution.

But what makes VI so popular? The secret to its longevity and popularity is rooted in its intrinsic capacity for power and flexibility. At the heart of the VI is the concept of 'mode', a distinctive design feature that gives it unparalleled versatility. Like a chameleon, VI can change its "modes" according to the user's needs, going from simple text entry to advanced manipulation of textual data.

This versatility has not only made VI an extremely powerful tool, it has also made it suitable for a wide variety of tasks. Whether you're coding, editing a configuration file, or taking notes, VI provides an efficient and powerful interface for all of these tasks. This ability to adapt to multiple operational scenarios is a major reason why VI has continued to thrive for decades and continues to be widely used to this day.

VI: A Giant Among Text Editors

One of the most notable features of VI that sets it apart from other text editors like nano or pico is its ability to handle huge file sizes. While many text editors struggle or crash when opening large files, VI can handle multi-gigabyte files with relative ease.

This is partly due to how efficiently VI manages memory. While other text editors may attempt to load the entire file into memory before starting work with it, VI uses a buffering technique that allows it to load only a small part of the file at a time. This means that VI can start working on a file almost immediately, regardless of its size.

This ability to work with large files makes VI an ideal tool for system administrators and programmers who often have to work with large amounts of data. For example, a database administrator might need to examine or edit a multi-gigabyte log file, or a programmer might need to look for a bug in a large code file.

The ability to handle large files isn't the only feature that sets VI apart. Its powerful command syntax, its numerous extensions and its extraordinary customization make it a very powerful tool for text manipulation. But it's its ability to meet and overcome the challenges that challenge other text editors that makes VI a giant in its field.

The VI Editor and its Modes

The VI editor has two main modes: command and insert.

La command mode is where VI starts. This mode allows you to execute commands to manipulate text, navigate through the document, save changes, etc.

La insert mode is the one that allows you to insert text into the document. You can enter this mode by pressing 'i' while in command mode.

Insert Mode

When you start VI, you start in command mode. To enter text, you need to switch to insert mode. As mentioned before, it can be entered by pressing 'i'. Once in insert mode, you can type normally. To exit insert mode and return to command mode, just press 'Esc'.

Command Mode

Once in command mode, you have access to a huge range of features. These include document navigation, text manipulation, saving and exiting, and much more. Here are some of the more common commands:

  1. Navigation: 'h', 'j', 'k', 'l' are used to move left, down, up and right respectively.
  2. Text manipulation: 'dd' deletes a line. 'dw' deletes a word. 'yy' copies a line. 'yiw' copies a word. 'p' pastes the copied text.
  3. Save and Exit: ':w' saves the file. ':q' exits VI. ':wq' saves the file and then exits. ':q!' exit without saving.

Tips and Tricks for Using VI

Knowing how to use VI effectively can make a big difference in your productivity. Here are some tips for getting the most out of VI:

  1. Learn the basic commands by heart: This may seem obvious, but it's surprising how many users don't take the time to memorize the basic VI commands. Once you have them memorized, you will find your working speed will increase dramatically.
  2. Use numbers with your commands: VI allows you to use numbers with commands to execute them multiple times. For example, '2dd' will delete two lines.
  3. Customize VIs to your liking:VI is highly customizable. You can create your own commands, change text colors, set up automatic formatting, and much more.

VI Commands Cheatsheet

Here's a quick cheatsheet of the VI commands:

  • Switch to insert mode: 'i'
  • Return to command mode: 'Esc'
  • Move left: 'h'
  • Move down: 'j'
  • Move up: 'k'
  • Move right: 'l'
  • Delete a line: 'dd'
  • Delete a word: 'dw'
  • Copy a line: 'yy'
  • Copy a word: 'yiw'
  • Paste copied text: 'p'
  • Save file: ':w'
  • Exit VI: ':q'
  • Save and exit: ':wq'
  • Exit without saving: ':q!'

Conclusion

VI is more than just a text editor. It is a very powerful tool for manipulating text, which has proven over time to be an indispensable resource in the skill set of every Linux user, as well as anyone operating in a Unix or Unix-like environment.

One of its main and most beneficial features is its universality. VI is present on virtually any Unix or Unix-like system, including Linux and macOS. This feature makes VI a bulwark of cross-compatibility, allowing you to work in a familiar environment no matter what operating system you're on. Unlike other text editors, such as nano or pico, which while easier to use are not universally installed, learning to use VI ensures that you have a skill applicable on a wide range of systems.

Using VIs isn't just a matter of versatility and cross-compatibility. It can actually boost your productivity once you learn and master its basic commands. The time savings gained from not having to take your hands off the keyboard to use a mouse, combined with VI's ability to quickly perform complex operations on text files, can make your work sessions much more efficient.

Understanding and using VI effectively can seem daunting at first, given its text-oriented interface and wealth of available commands. However, like any skill, learning to use VIs comes down to a matter of practice. Investing in the time to learn VI will not only allow you to work more efficiently, but will also give you a skill that sets you apart in the fields of systems engineering and programming.

Remember, practice makes perfect. While the learning curve may seem steep, the skill and speed you gain will no doubt be rewarded. So, don't hesitate: keep using VI, keep challenging yourself, and in no time you'll become a true master of the most powerful and versatile text editor in existence.

Do you have doubts? Don't know where to start? Contact us!

We have all the answers to your questions to help you make the right choice.

Chat with us

Chat directly with our presales support.

0256569681

Contact us by phone during office hours 9:30 - 19:30

Contact us online

Open a request directly in the contact area.

INFORMATION

Managed Server Srl is a leading Italian player in providing advanced GNU/Linux system solutions oriented towards high performance. With a low-cost and predictable subscription model, we ensure that our customers have access to advanced technologies in hosting, dedicated servers and cloud services. In addition to this, we offer systems consultancy on Linux systems and specialized maintenance in DBMS, IT Security, Cloud and much more. We stand out for our expertise in hosting leading Open Source CMS such as WordPress, WooCommerce, Drupal, Prestashop, Joomla, OpenCart and Magento, supported by a high-level support and consultancy service suitable for Public Administration, SMEs and any size.

Red Hat, Inc. owns the rights to Red Hat®, RHEL®, RedHat Linux®, and CentOS®; AlmaLinux™ is a trademark of AlmaLinux OS Foundation; Rocky Linux® is a registered trademark of the Rocky Linux Foundation; SUSE® is a registered trademark of SUSE LLC; Canonical Ltd. owns the rights to Ubuntu®; Software in the Public Interest, Inc. holds the rights to Debian®; Linus Torvalds owns the rights to Linux®; FreeBSD® is a registered trademark of The FreeBSD Foundation; NetBSD® is a registered trademark of The NetBSD Foundation; OpenBSD® is a registered trademark of Theo de Raadt. Oracle Corporation owns the rights to Oracle®, MySQL®, and MyRocks®; Percona® is a registered trademark of Percona LLC; MariaDB® is a registered trademark of MariaDB Corporation Ab; REDIS® is a registered trademark of Redis Labs Ltd. F5 Networks, Inc. owns the rights to NGINX® and NGINX Plus®; Varnish® is a registered trademark of Varnish Software AB. Adobe Inc. holds the rights to Magento®; PrestaShop® is a registered trademark of PrestaShop SA; OpenCart® is a registered trademark of OpenCart Limited. Automattic Inc. owns the rights to WordPress®, WooCommerce®, and JetPack®; Open Source Matters, Inc. owns the rights to Joomla®; Dries Buytaert holds the rights to Drupal®. Amazon Web Services, Inc. holds the rights to AWS®; Google LLC holds the rights to Google Cloud™ and Chrome™; Facebook, Inc. owns the rights to Facebook®; Microsoft Corporation holds the rights to Microsoft®, Azure®, and Internet Explorer®; Mozilla Foundation owns the rights to Firefox®. Apache® is a registered trademark of The Apache Software Foundation; PHP® is a registered trademark of the PHP Group. CloudFlare® is a registered trademark of Cloudflare, Inc.; NETSCOUT® is a registered trademark of NETSCOUT Systems Inc.; ElasticSearch®, LogStash®, and Kibana® are registered trademarks of Elastic NV This site is not affiliated, sponsored, or otherwise associated with any of the entities mentioned above and does not represent any of these entities in any way. All rights to the brands and product names mentioned are the property of their respective copyright holders. Any other trademarks mentioned belong to their registrants. MANAGED SERVER® is a registered trademark at European level by MANAGED SERVER SRL Via Enzo Ferrari, 9 62012 Civitanova Marche (MC) Italy.

Back to top