DEV Community

Cover image for 10 Useful vim commands for coders
Onelinerhub
Onelinerhub

Posted on

10 Useful vim commands for coders

You need to be in command mode (pres Esc for that) to use these commands.

1. Add a new line

Press o (small) to add new line below cursor, or O (big) to add new line above cursor.

2. Comment multiple lines

  1. Press Ctrl + v
  2. Select lines with arrows keys
  3. Press Shift + i
  4. Input commenting symbol(s) (e.g. "//")
  5. Press Esc

3. Delete line

Press dd to delete current line.

4. Delete word

Press dw to delete current word (cursor should be placed at the beginning of the word to delete).

5. Disable line wrap:

:set nowrap
Enter fullscreen mode Exit fullscreen mode

6. Enable autoindent

:set smartindent
Enter fullscreen mode Exit fullscreen mode

7. Go to the end of current line

Press $ to to the end of line.

8. Go to the end of file

:$
Enter fullscreen mode Exit fullscreen mode

9. Go to specific line

E.g. to go to line number 51:

:51
Enter fullscreen mode Exit fullscreen mode

10. Open file in a new tab

:tabnew <filename>
Enter fullscreen mode Exit fullscreen mode

More useful Vim commands, add your commands on Github.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs