Pratical Implementation of Command in Vim Editor

You can open vim by running vim command on the terminal.

vim 

There are some commands given to use the vim editor. You can see all commands, and it’s documentation by help command as follows:

:help

Now to exit type this command 

:q!

Now, Let’s Start to use Vim

To open a file in vim editor just write the file name after the vim command in the terminal as follows:

vim filename.txt

Then the file will be opened.

Write into file 

In the previous step we have opened the file now, Let’s write some content in to write data we need to go in insert mode. To go into write mode type i.  As follows:

i

After going into insert mode you will see INSERT in the status bar. After that, we can write any data in it.

Save and Exit:

We have written the data into a file now the task is to save and exit the file to do that first exit from insert mode by pressing the Esc key. To write a command first type semicolon  (  :  )  and then type the command wq!  or x! (both do the same thing) And then hit ENTER.

:wq!

Exit without saving the file:

To exit from the file without saving the file just use the command q! As follows

:q!

Vim also comes with its own tutorial. You can see this tutorial by command vimtutor into the terminal .

vimtutor

Now vim tutorial will be opened as follows:

Text Editing: Insertion

We have edited some text files before by using the i key. There are Four keys used for the insertion of text. Just type the key into the normal mode in vim.

 i    ->   This key is used to put the cursor before the current position.
a -> This key is used to put the cursor after the current position.
o -> This key is used to put the cursor below the line.
O -> This key is used to puts the cursor above the line.

Motion: Motions provide context to your Operators. These execute the action in a particular way.

Here is a list of some motions

w - until the start of the next word, EXCLUDING its first character.
e - to the end of the current word, INCLUDING the last character.
$ - to the end of the line, INCLUDING the last character.

We can use motion with the d key and with many more keys

Count: Count is the number for which replete the motion for count number. Here is a demonstration of the use of count and motion

To move courser 2 words forward use the following command

2w

Here 2 is the number of counts and w is used for word

To move the cursor 4 lines forward use the following command

4$

Vim Editor in Linux

If you’re new to the world of Linux, one of the first things you’ll encounter is the command line interface. And if you’re going to be working in the command line, you’ll inevitably come across various text editors. Among them, Vim stands out as a powerful, yet notoriously complex, text editor. In this guide, we’ll take you through everything you need to know about Vim, from its basics to more advanced features, to help you get started on your journey with this essential tool.

Similar Reads

What is Vim?

Vim, short for Vi IMproved, is a highly configurable text editor built to enable efficient text editing. It’s an enhanced version of the Vi editor, which was developed back in the 1970s. Vim is widely used by programmers, system administrators, and anyone who spends a significant amount of time working in the terminal...

Installation and Configure Vim in Our Linux System

Most Linux distributions come with Vim pre-installed. However, if it’s not available on your system, you can install it using your package manager. For instance, on Ubuntu or Debian, you can use:...

Modes in Vim:

One of the unique features of Vim is its modes. Vim has several modes, each serving a different purpose:...

Basic Commands in Vim:

Here are some basic commands to get you started:...

Navigating in Vim:

Moving the Cursor: Use the arrow keys or `h`, `j`, `k`, `l` keys to move left, down, up, and right respectively. Jumping to the Beginning or End of a Line: Press `0` to jump to the beginning of a line and $ to jump to the end. Jumping to a Specific Line: Type `:` and press Enter to jump to a specific line....

Deletion Commands in Vim:

Always use the Esc key to go into normal mode and use the insertion, deletion keys, and other keys....

Search in Vim Editor

To search the word After the cursor uses the backslash key and then write the word and press enter....

Search and Replace in Vim Editor

To replace the word in file use s/ command in vim like...

Pratical Implementation of Command in Vim Editor

You can open vim by running vim command on the terminal....

Conclusion

In conclusion, navigating the Linux command line often leads to encountering various text editors, and among them, Vim shines as a robust yet intricate tool. This guide has provided a comprehensive overview of Vim, from its installation to basic commands, modes, and advanced features, aiming to equip beginners with the necessary knowledge to embark on their journey with this essential text editor. While Vim’s learning curve may seem steep, mastering its capabilities can significantly enhance productivity and efficiency for programmers, system administrators, and anyone spending time in the terminal. With practice and exploration, Vim opens up a world of powerful text editing possibilities, making it a valuable asset in the Linux environment....

Contact Us