VIM Editor

Recently, I had to use Vim Editor after years. Honestly, I had to google how to use it. I used it daily for some morning manual checks when…

Recently, I had to use Vim Editor after years. Honestly, I had to google how to use it. I used it daily for some morning manual checks when I was working as a Full Stack Developer years ago but you just get rusty without regular use.

A cold Vimto with chip shop chips — a top 3 lunch in my student days.

Context

I was having vulnerability scanning issues with a scan engine hosted on a Linux server. The support engineer for the tool advised me to edit out the comment tags in a specific file to enable debugging. When you look at files on the command line, there is no GUI so you cannot click on files to open them up and edit. To do this, I used Vim. Vim is a command line text editor. It allows us to edit files from the command line.

Vim Modes

VIM has several modes I needed to be aware of.

Command Mode — this is the default mode when you run VIM.

Insert Mode — Enter “i” to switch to Insert mode which allows you to edit the file. To go back to Command mode enter Esc.

I read there are other modes but this was sufficient for what I needed to do.

This is what I did for my own reference.

  1. SSH to server
  2. Navigate to directory that contains the file that I needed to edit.
  3. Enter vim <file name> This opens up the file.
  4. Enter i You should see “Insert” appear somewhere near the bottom of the screen. This tells you you are now in Insert mode and you can use the keyboard as normal for text editing.
  5. Deleted the comment tags.
  6. Press Esc. This will exit Insert Mode back to Command Mode.
  7. At this point your changes are not saved.
    To save changes enter :w
    If permissions allow this should save the file. If elevation is required try :w!
  8. To check the changes were saved, open the file again with vim <file name>
  9. Finally, enter :q to quit Vim. This takes me back to the normal Linux Command line.