Using a Vim First Time - Cursor Movements

Kuzey Köse
3 min readAug 14, 2021

I heard a Vim concept a lot. In few years, my friends praise some of its advantages such as using no more mouse. So, I don’t know why I didn’t try. Today! That’s the day to trying Vim. This blog is about my experience of trying How to use Vim (moving cursor). Also, I am currently using VSCode. There has a nice extension for Vim.

Firstly, I tried to do all steps without using a cheat sheet. Then, I decided that I made difficult it for the learning period.

Moving Around & Editing Code

The basic keys are moving with h,j,k,l characters. They work like pressing arrow keys.

  • h -> left
  • j -> down
  • k -> up
  • l -> right

Not complex right?

If you writing some code to your file. Using i character the set the insert mode. Then, you can get access to changing the file. When the editing is done, pressing ESC or ctrl+c keys to return back.

Moving Fast

If somewhere to take away your cursor fast on a line, then the w key helps you to jump from word to word. Also, ge keys are doing the same in opposite direction. just pressing e key will jump to the end of the word.

Using f{char} move the char directly in a line. For example, if you press f with t then Vim finds the next t in the line in front of the cursor. Character f is meaning like find. Using one time of f{char} is allow to using semicolumn to find the next char which pressed with f.

Sometimes, we want to turn back immediately with the first character of the line or end of the line. Vim has a key for all these.

  • 0 -> Moves first character of the line
  • ^ -> Moves to the first non-blank character of a line
  • $ -> Moves to the end of a line

Moving is really important, also, moving fast is much more important. } jumps entire paragraphs downwards, { key upwards. ctrl+d moves you to down half a page, ctrl+u moves you to up half a page.

Search Pattern

Vim also allows you to search in a file in two ways.

  • /{pattern} to search forward inside a file
  • ?{pattern} to search backwards

Also, you can use the * char the search pattern which the cursor is on.

Other Moving Options

Vim has much more skills for moving, but these are just enough for me. The last ones are a little bit cool.

  • gg goes to the top of the page
  • {line}gg go directly the line like 45gg
  • G goes to the end of the file
  • % jump to matching ({[]})

— — — — — — — — — — — — — — — — — — — — — — —

Refs:

https://github.com/VSCodeVim/Vim/blob/HEAD/ROADMAP.md

--

--