VIM Commands

0
247
VIM Commands

VIM Editor Overview

The majority of work in the Linux ecosystem is done through a command-line interface (CLI). Managing file content is one of your key responsibilities.

To do so, you will need a file-editing program. The VIM editor, often known as a visual editor, is one of the most popular editors in the Linux world.

Before we look at some of the best VIM commands, let’s get an overview of VIM.

Cheap SSL

What is VIM?

VIM is a very popular Unix Based operational editor that allows the users to insert and influence the test. It is a visual text editor which doesn’t require a mouse, and all your text modifications can be done with the help of the keyboard itself.

It is also a free source and an easy-to-use code editor. Since it is open-source, it is available on VIM’s official website.

Modes of VIM

Although VIM comprises 12 modes, only six are very important and commonly used. The other 6 modes are variants.

Here we will also be discussing the six major modes before we get started with the commands and how to use VIM.

Six Major Modes of VIM:

1. Normal Mode: As the name specifies, this is the default mode that you see on your screen when you open the editor.

2. Select Mode: The interface works as a visual model, but if commands such as printing characters, carriage returns, newlines, or line feed are entered, VIM switches to an insert mode.

3. Insert Mode: This mode will give you a feel of modern editors. It is used to modify the already existing files with the help of inserted text.

4. Command-line Mode: It only supports single-line input at the end of the VIM window. This mode is triggered by normal commands and some other specific actions, and on completion of the command, it returns to the previous VIM mode.

5. Visual Mode: Visually, this mode is similar to that of the normal mode, except for a few text zones.

6. Ex Mode: It is similar to command-line mode and allows the user to enter a command at the end of the VIM window. Whenever a command is completed, VIM stimulates another Ex Mode to command rather than returning to the previous VIM Mode.

How to use VIM?

As we know by now, VIM uses Commands to insert text and manipulate it. See in the section below, the steps to open a new file in the VIM editor.

Step 1: To open a new file, you have to type the command “vi filename.”

Step 2: Once the new file opens, type “I,” i.e., insert, and the file will move to edit mode.

Now, let us go and look at some commands.

Basic Commands

Commands Code
To open Filename for Editing :e filename
To Save a File :w
To Quit Program without Saving :q!
To close VIM :q
To write file and exit after the changes have been made 😡
To save a file as “Filename.” :sav filename
To repeat the changes that were made in normal mode at last .

Move Commands

These commands are used to make a swift movement in the file when the file is in Command Mode. By using these commands, you can move the cursor, hop to a specific number of lines, or set the position of the cursor at the beginning of the file.

Commands Code
To move a lineup k
To move a line down j
To move at the end of a word e
To move at the beginning of a word b
To move at the beginning of a line 0
To move at the beginning of a file gg
To move at the end of a file G
To move to the end of the screen L
To move to match parenthesis %
To hop to the start of the function. [[
To hop to the start of the block. [{
To move to the desired line number, for ex: 60 :60

Cut, Copy, and Paste Commands

These commands have to run in command mode only, and they are used to cut, copy, and/or paste a section of text.

Commands Code
To copy specific text to clipboard y
To paste the text that was copied to the clipboard p
To cut the line, you are currently on dd
To copy the line, you are on yy
To copy text to the end of line y$
To cut specific text to end of line D

These are only some of the basic commands used by VIM. In order to learn and work properly with VIM, you should know thousands of additional commands.

Advantages of VIM Editor

1. Fast and Flimsy: If put together with other graphic editors, VIM is fairly lightweight and fast. It uses a small amount of memory on its users’ systems and loads quickly.

2. Plugins are like connections that link software and users. VIM has a robust plugin system. There are plugins for everything from management to color outlines.

3. Free and Easily available: It is not just free and open for everyone. Additionally, it is easily accessible via terminal or GUI on all platforms.

4. Portable Configuration: VIM enables users to have the same experience across all their machines once they have set it up to their needs.

5. Easy to use with the only Keyboard: It can be irritating to reach for a mouse when there is a lot on our plate to work with. VIM allows its users to work only with the help of a keyboard as it supports around 200 operations only with a keypress or two-way.

Disadvantages Of VIM Editor

1. Tough Learning Arch: VIM has a rising learning curve but can be time-consuming for the users to learn and tune the settings according to their needs.

2. Learning VIM is tough: It is a very vast software that is very difficult to master. Therefore, every time you sit down to learn and understand you’ll discover a few more new things, and the list is never-ending.

3. Deprived Support for Outer Tools: Many plugins depend on facultative Python and Lua capabilities, which may or may not be encapsulated, depending on the available binaries.

4. Pitiable Feature Determinability: Although all the features are available and can be found with minimal configuration, some can be still unclear. It is difficult to find the records of these features without any expert help.

5. Doesn’t Support cut/paste Machinery: We are used to using the copy and paste technique, but with VIM, sometimes it is difficult to access the clipboard and use this technique.

Conclusion

Overall, VIM is a text editing software that is easy to use and free for all. Despite its disadvantages, the system is widely used and highly recommended, implying that its pros easily outweigh its cons. Functions within this software surpass any limits, enabling you to work quickly and gain a lot of knowledge.

People are also reading: 

LEAVE A REPLY

Please enter your comment!
Please enter your name here