This website uses cookies to enhance the user experience

Text Editing with Vim and Nano

Share:

In this chapter, we're moving from the world of "Iron Man" where high-tech gadgetry does all the work, to the world of "The Dark Knight". It's raw, it's gritty, and it's intensive – welcome to Linux text editing with vim and nano. Just like Bruce Wayne relies on his skills and instincts more than shiny gadgets, we, too, are going to rely on two powerful, albeit challenging to learn, text editors: Vim and Nano.

Understanding Vim

Vim, which stands for Vi I ("I" stands for improved in this context) is a highly configurable and efficient text editor incorporated into Linux.

Installation and Usage

To commence Vim typing, we press vim command followed by the name of the file we intend to open. For our example let's call it Joker&Batman, so the command will look like vim Joker&Batman.

If Vim isn't installed, we can conveniently install it utilizing terminal commands. For Debian-based distributions, we apply:

sudo apt-get install vim

while for Red Hat-based distributions, we use:

sudo yum install vim

Vim Modes

Operating Vim, we have to understand its two primary modes: normal mode and insert mode. For beginners, moving between these modes might feel like Batman grappling over the rooftops of Gotham City. The normal mode lets us navigate the text, copy it, paste it, or delete it, while the insert mode allows us to enter or alter the text.

To switch from normal mode to insert mode, we press the i key. To move from insert mode back to normal mode, we press the Esc key. It's as if you're Batman, constantly switching between the billionaire Bruce and the crimefighter persona.

Let’s create our first line with Vim:

Press i to switch to the insert mode and then write:

It's not who I am underneath, but what I do that defines me.

Press Esc to go back to normal mode. Your cursor needs to go to the beginning of the line. Press the 0 key, and the cursor will "zip-line" to the start of the line, just like Batman would.

Saving And Quitting Documents in Vim

We need to use the :wq command where w stands for write (save) and q for quit. If you want to exit without saving (like Batman disappearing into the night), use :q!.

Altering And Deleting Text

Where Vim becomes truly powerful (and starts feeling less like driving the Batmobile and more like doing detective work) is with altering and deleting text.

To delete a character, place your cursor over it and press x.

To delete a word, place your cursor at the beginning of the word and press dw.

To change a word, place the cursor at the beginning of the word and type cw, which will delete the word and move you to insert mode.

Nano Text Editor

Nano, on the other hand, is much simpler and easier to use—it's like the Jarvis to Vim’s Batman. But despite its simplicity, it's a practical and useful text editor.

Installation and Usage

Just as with Vim, if Nano isn't installed, we can conveniently install it using terminal commands. For Debian-based distributions, we will apply:

sudo apt-get install nano

while for Red Hat-based distributions, we use:

sudo yum install nano

To start Nano, type nano followed by the filename. For our example, let's use Thanos&IronMan, so the command will look like nano Thanos&IronMan.

Writing and Saving Files in Nano

Writing in Nano is straightforward, just like communicating with Jarvis: just start typing! When you finish, press Ctrl + O to invoke the save command, then Enter to confirm the file name, and Ctrl + X to exit Nano.

While Vim has a steep learning curve and requires you to learn various commands and modes, Nano is much more beginner-friendly. Choosing between them boils down to your preferences, needs, and specific tasks -- much like selecting between Batman's get-your-hands-dirty philosophy and Iron Man's high-tech approach.

In conclusion, Linux text editing with Vim and Nano might seem like an arduous journey at first -- much like the road to becoming a superhero -- but with practice, it becomes a superpower. With these text editors in your Linux arsenal, you'll tackle text editing tasks sleekly and efficiently, and maybe even feel a little like a superhero yourself.

0 Comment


Sign up or Log in to leave a comment


Recent job openings

Egypt, Giza, Ad Doqi

Remote

Full-time

Java

Java

PHP

PHP

posted 1 week ago

United Kingdom, Cambridge, England

Remote

Full-time

Python

Python

posted 1 week ago

Greece, Nea Ionia, Attica

Remote

Full-time

Swift

Swift

TypeScript

TypeScript

posted 1 week ago

Bulgaria

Remote

Full-time

SQL

SQL

React

React

posted 1 week ago
company logo
Senior Software Engineer (Java)

FINARTIX Fintech Solutions S.A.

Greece, Athens, Attica

Remote

Full-time

Java

Java

SQL

SQL

+4

posted 1 week ago