QueHow

A How-To and wiki Blog

  • Operating System
    • Windows
      • Windows 10
      • Windows 7
    • Linux
  • Software
    • Application Software
    • Microsoft Office
      • Outlook
      • Word
      • PowerPoint
  • Internet
    • Browsers
      • Mozilla Firefox
      • Google Chrome
    • CMS
    • Tips & Tricks
  • Website
    • ecommerce
    • Google
    • Social Networking
    • General Websites
  • Mobile
  • Email
    • Gmail
  • Wiki

How to use VIM Editor in Ubuntu?

By Neha T Leave a Comment

Vim editor is a tool for creating, editing, merging and performing the operations, as you may used to do in the editors like Wordpad, Notepad, etc. The editor is used more by the programmers as they like to be with their keyboard only, not making much use of a mouse or a touchpad. Besides this, VIM editor has a feature of Autocomplete which is most liked by the developers.

Want to explore with the latest vim editor? Oh, well, it’s comparatively trickier than other editors like notepad & word processors. Vim editor has many advanced features which vi editor does not have. Vim editor is based on commands, but it also support GUI. Vim editor has 3 modes in which only the operations such as copying, pasting, deleting, inserting and saving can be performed . These three modes are named as:

  1. Command mode
  2. Insert mode
  3. Last line mode

1. Command mode: In this mode you can play with the text already written in a file. but you can not insert or add anything to that file. By default, vim editor open ups in command mode only.There are numerous commands by which you can perform editing, some of these are as follows:

h – this is used to move one character left
l – this is used to move one character right
k – this is used to move up
j – this is used to move down
yy – this is used to copy a single line
dd- this is used to delete a single line
p – this is used to paste which you have copied
^ -this is used to reach at a beginning of a line
$ – this is used to reach at end of the line

2. Insert mode: You can enter into the insert mode by simply pressing “i”. This mode is used to insert the content into a file, you can navigate between the lines by the use of arrow keys.

3. Last line mode: To switch to the last line you have to press “: (colon)” then you can perform the operation that you want such as to save a file, quit from the vi editor and many more. For an example:

:set number – this is used to do the numbering in the content
:set nu- this is used to remove the numbering from the content

Steps to Use VIM Editor in Ubuntu

Step 1: To open a file in vim, firstly, go to the path where it is stored. My file is stored under home->Desktop and as I am already in home path, so I will go to the Desktop section. For this the directory has to be changed, so type the command “cd ~/Desktop”.

how-to-use-vim-editor-in-ubuntu-Step1

Step 2: Now the path is changed, open the file you want using the command “vim filename.txt”

I have entered “vim demo.txt” to open the file named as demo.txt.

how-to-use-vim-editor-in-ubuntu-Step2

Step 3: Here you can see the content of the file. We are in Command mode so the operations which are stated earlier can be performed here.

As you can see the cursor is at the letter “s” of the word “lets’, in order to go at the starting point of the line, you have to press “^”.

how-to-use-vim-editor-in-ubuntu-Step3

Step 4: You can see in the figure below, that the cursor has come to the starting point of the line, this means that the above operation worked correctly.

how-to-use-vim-editor-in-ubuntu-Step4

Step 5: Lets go to the start mode by using the “i” command. At the bottom of the terminal you will see “–INSERT–” that confirms, you have successfully entered into the insert mode.

how-to-use-vim-editor-in-ubuntu-Step5

Step 6: Now you can append as much lines as you want in the respective file. I have typed in two lines as shown in the figure below.

To save the changes you need to exit from the insert mode by clicking the “ESC” key.

how-to-use-vim-editor-in-ubuntu-Step6

Step 7: Once you are finished with the editing, you have to enter into the Last line mode by pressing “:” i.e. colon.

To save the file type “w” after colon i.e “:w”.

how-to-use-vim-editor-in-ubuntu-Step7

Step 8: To exit from the vim editor you have to press “:q” which means to quit.

how-to-use-vim-editor-in-ubuntu-Step8

Step 9: If, due to any reason, you are not able to exit or want to close the editor without saving the last editing you’ve performed, then you can forcefully close the editor by using “:q!” command as shown in the figure below.

how-to-use-vim-editor-in-ubuntu-Step9

Step 10: Some other last line mode commands such as “:set number” or “:set nu”, are used to enter numbers into the content that increases the readability of the content, as shown in the image below.

how-to-use-vim-editor-in-ubuntu-Step10

Step 11: The content of the file demo.txt is arranged according to the number of lines present, as demonstrated in the figure.

how-to-use-vim-editor-in-ubuntu-Step11

Step 12: If at, any point of time, you feel to undo the changes, then you can remove the numbers by just typing the “:set nu!” command.

how-to-use-vim-editor-in-ubuntu-Step12

 

You Might Also Like:

how-to-copy-and-move-files-and-directories-in-ubuntuHow to Copy and Move Files & Directories in Ubuntu How-to-install-oracle-java-in-ubuntuHow to Download and Install Oracle Java in Ubuntu How we can Change the Directory in Ubuntu How to Open Registry Editor in Windows 7 how-to-install-ubuntu-on-windows7-using-vmware-workstationHow to Install Ubuntu on windows 7 using Vmware Workstation how-to-install-and-configure-ssh-in-ubuntuHow to Install and Configure SSH (Secure SHell) in Ubuntu How to Start Ubuntu in Safe Mode Installed on VMware Workstation Open Registry Editor in Windows 10-featured-imageHow to open Registry editor in Windows 10

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Viewed

  • How to Install and Use TELNET in Ubuntu
  • How to install Hindi fonts in MS Word
  • How to Change a File Extension in Windows 10?
  • How to create a flipkart account in 3 simple steps
  • How to Change Monitor Refresh Rate in Windows 10?
  • How to install IIS on Windows 10
  • How to Insert Clickable Checkbox in MS Word 2016?
  • How to Set Auto Reply in Outlook 2016?
  • How to Login as Administrator in Windows 10?
  • How to Check RAM Size and System Type in Windows 10?

Recent Additions

  • How to Hide Active Status in Instagram?
  • How to Download and Save Instagram Stories?
  • How to Deactivate Account in Instagram?
  • How to Download Private Instagram Stories?
  • How to Slow Motion a Video in PowerDirector?
  • How to Check Who Unfollow You On Instagram?
  • How to Use Boomerang on Instagram?
  • How to Edit Video in PowerDirector?
  • How to Mute Someone’s Stories or Posts on Instagram?
  • How to Hide and Unhide Posts on Instagram?

Related Searches

  • How to Change Login Screen Background in Windows 10?
  • How to Change Screen Resolution in Windows 10?
  • How to Open Registry Editor in Windows 7
  • How to delete “Google apps for Work” account
  • How to SUMIF in Excel?

Copyright © 2021 · QueHow · Contact Us