Home  >  Article  >  System Tutorial  >  How to set the line number of vim in Ubuntu? How to set the line number of vim in Ubuntu

How to set the line number of vim in Ubuntu? How to set the line number of vim in Ubuntu

PHPz
PHPzforward
2024-01-07 11:41:30793browse

Today I used vim to write code under Ubuntu. As usual, I set the line number of vim first. I didn’t think about anything every time, but today I thought about it. Can vim be initialized when it is opened? Woolen cloth?

I checked the relevant information online and practiced it myself. If it works, I will post it and share it with everyone! (The set vim line number is valid for all users (including root user))

1. Open the terminal, enter cd /etc/vim in the command line and hit Enter to enter the /etc/vim directory;

2. After entering the etc/vim directory, find the vimrc file (vim’s initialization file) and use the cp command to back it up. The command is: cp vimrc vimrc.bak (backup is a security mechanism, please remember) ;

3. Open vimrc with administrator rights, the command is: sudo vi vimrc

4. After opening, add a line of command at the end of the vimrc file: set nu;

5. After adding, write, exit, restart vim, you can find the line number mark.

The above is the detailed content of How to set the line number of vim in Ubuntu? How to set the line number of vim in Ubuntu. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete