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

The usage of the Linux basic command vim

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "the usage of the Linux basic command vim". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the usage of the basic Linux command vim.

Vim

Vim is the most common text editor in unix system. Its function can be said to be very powerful. It is an upgraded version of vi. Vim has three working modes: edit mode, command mode, and last line mode, which enter command mode when turned on by default.

The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.

Vim has many built-in commands that can help us edit files better.

Command

Description

ESC

Enter command mode

Command mode

A

Add content from after the cursor position

A

Add content from after the cursor position

I

Insert content from the cursor position

I

Insert content from the beginning of the line in which the cursor is located

O

Create a new line below the line of the cursor

O

Create a new line above the line of the cursor

D

Delete the character from the cursor to the end of this line

Dd

Delete the cursor line

Ndd

Delete the n lines at the beginning of the cursor

Yy

Copy cursor row

Nyy

Copy the n lines at the beginning of the cursor

P

Paste below the cursor

P

Paste above the cursor

/ string

Look backwards from the cursor

? String

Look forward from the cursor

:

Enter the last line mode

Last row mode

Num

Skip to the specified line

W

Save

Q

Quit

Q!

Forced exit

Set nu

Show line number

Set nonu

Do not display line number

1. Grammar

Vim [options] file

2. List of options

Option

Description

-- version

Display command version information

-- help

Show help documentation

+ num

Display starts with the specified line of the text

-b

Enter binary mode

-d

Enter diff mode and display the differences when editing multiple files

-m

Modification of files is not allowed

-n

Do not use caching

-o

Open n files at the same time

-p

Display each file in tab format

-r

List the cache and display the restored information

S

Silent mode without displaying any error messages

3. Examples

1) use tab to edit multiple files

[root@localhost weijie] # vim-p 1.c 2.c / / tab displays multiple files

1.c 2.c

Hello world, x

I am david.

I love linux

Love code.

2) display line number

1 hello world

2 i am david.

3 i love linux

4 love code.

~

: set nu / / use set nu to display line numbers in the last line mode

At this point, I believe you have a deeper understanding of "the use of the Linux basic command vim". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Servers

Wechat

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

12
Report