Home  >  Article  >  Operation and Maintenance  >  Why doesn’t vim display line numbers in Linux?

Why doesn’t vim display line numbers in Linux?

WBOY
WBOYOriginal
2022-05-17 10:51:534364browse

In Linux, vim can use ":set nonu" to prevent the line number from being displayed during the editing process; the function of this command is to cancel the line number, or you can use the ":setnu" command to display the line number again. If the configuration file ".vimrc" exists, you can add a line "set nonu" to the file so that the file does not display the line number every time.

Why doesn’t vim display line numbers in Linux?

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

Why does vim not display the line number in Linux?

  • :setnu displays the line number

  • :setnonu cancels the line number

In the process of editing with Vim, you often encounter situations where you need to operate several consecutive lines at the same time. In this case, it will be very convenient if each line has a line number prompt.

Enter ":set nu" in command mode to display the line number of each line, as shown in the figure.

Why doesn’t vim display line numbers in Linux?

If you want to cancel the line number, enter ":set nonu" again.

If you want the line number to be displayed by default every time you open a file, you can edit Vim's configuration file. Every time you use Vim to open a file, Vim will read the .vimrc file from the home directory of the currently logged in user (where the user configuration file is located). This file can make some default configuration settings for Vim.

If the .vimrc file exists, read the Vim settings first; otherwise, use the default configuration. By default, this file does not exist in the user's home directory. It needs to be created manually in the current user's home directory, such as "vim~/.vimrc", "~" represents the host directory, and root's home directory is /root/ , the home directory of ordinary users is stored in the /home/ directory. You can directly use Vim to edit and generate this file, add a line "set nu" to this file, save and exit, as shown in the figure.

Why doesn’t vim display line numbers in Linux?

Recommended learning: Linux video tutorial

The above is the detailed content of Why doesn’t vim display line numbers in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn