Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the vim shortcut keys?

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

What are the vim shortcut keys? for this question, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

Vi (vim) is a very common editor on Linux, and many Linux distributions have vi (vim) installed by default. There are a lot of vi (vim) commands, but if you use them flexibly, you will be much more efficient. Vi is the abbreviation of "visual interface" and vim is vi IMproved (enhanced version of vi). Vi is sufficient for general system management and maintenance, and vim can be used if you want to use code highlighting.

Vi has three modes: insert mode, command mode, and low-line mode.

1) insert mode: you can enter characters in this mode, press ESC to return to command mode.

2) Command mode: you can move the cursor, delete characters, etc.

3) low-line mode: you can save files, exit vi, set vi, find and other functions (low-line mode can also be seen as command mode).

Next, I would like to introduce vim shortcut keys to you.

# vim filename

: scriptname / / check which scripts are loaded by vim

: set nu / / set line number

: set tabstop=4 / / set a tab to 4 space lengths

: set ai / / sets automatic indentation

The spacebar / / move one space to the right

X / delete the following characters (in command mode)

X / / Delete the previous character, delete three characters is 3x

Dd / / Delete a row

D / / Delete to the end of the line

Caw / / rewrite the word, c equals d to edit mode

J / / remove the newline character so that the next line is parallel to the next line, and nJ connects the next n line

U / / undo the last operation

U / / undo all changes to the current line

Ctrl+r / / revocation of a pair of undo

I / / insert before the cursor

I / insert at the beginning of the line

A / / insert at the cursor

A / / insert at the end of the line

O / / start another line below the current line and change to insert mode

O / / take another line above the current line and change to insert mode

Ctrl+o / / temporarily changes to command mode (effective once)

: e! / / discard changes, which is equivalent to reopening

: help / / help, you can use ZZ to exit the help window

: 10pr 20y / / copy 10 to 20 lines or 10yy / yy10

: 10pr 20d / / deleted

: 10pr 20m 30 / / 10 to 20 lines, cut to 30 lines later

: 10 co 20 30 / / 10 to 20 lines, copy to 30 lines later

Place the cursor at {and enter v% to select the contents in the curly braces

If the cursor is over the first s and you want to delete it to "(", type dt. The function of t (is to jump to the next "(").

It's the same with ctrl+n automatic completion ctrl+p

Ab hw hello world replaces a long string with an acronym, and here uses hw instead of hello world

# to the previous word the same as the current word

* to the next word the same as the current word

The answers to the questions about vim shortcuts are shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report