Moving Around With vim (keyboard short cuts)

This is a user contributed FAQ.

Q. Can you tell me few useful vim text editor keyboard short cuts for moving around while editing text files?

A.
Moving around with vim.

Open any file, for example
$ vim /etc/httpd/conf/httpd.conf

1. Go to the first line
gg or 1 shift g or :0 (zero) Enter

2. Go to the last line.
Shift g or :$ Enter

3. Go to line 8
8 shift g

4. To scroll down one screen
Ctrl f

5. To scroll up one screen
Ctrl b

6. First position on line
0(zero)

7. Last position on line
$

8. Go to matching parenthesis
%

9. Right, left, up, down respectively.
l, h, k, j
Or You can also use arrow keys

10. Where Am I?
Ctrl g
Note: previous command works in command mode

11. You can see a nice summery of more vim commands here.

This article / faq is contributed by Yoander Valdés Rodríguez (yoander). nixCraft welcomes readers’ tips / howtos.


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 2 comments so far... add one


CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
2 comments… add one
  • Stanislav Lechev [AngelFire] May 22, 2008 @ 9:19

    for point 3 you can use :8 as well (like :0 for the 1st line)

    for point 9 (l, h, k, j) are alternatives for the arrows, it’s easies to use arrow keys…

    one more thing… you can hit 7 and then down/up/left/right to move 7 lines/chars in that direction

  • chika Jun 13, 2008 @ 5:20

    try this

    :set number

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum