How to Enable Line Numbers
To start using line numbers in vi
or vim
, you'll first need to open your file with vi
by typing:
bashvi filename
Once you’re in, you might notice that line numbers are not displayed by default. To enable them, ensure you are in normal mode (not insert mode), press the Esc
key, and type:
arduino:set number
Press Enter
to execute this command. You should now see line numbers appearing on the left side of your editor window.
Making Line Numbers Permanent
If you find line numbers useful and would like them to appear every time you open a file, you can make this setting permanent by adding it to your vimrc
configuration file:
Open the
vimrc
file invi
:bashvi ~/.vimrc
Add the following line:
arduinoset number
Save and close the file.
This will ensure that line numbers are always enabled whenever you use vi
or vim
.
Navigating to a Specific Line
Knowing how to jump directly to a specific line can save you time, especially when working with large files. Here’s how you can do it:
Using the
G
Command: PressEsc
to go to normal mode, type the line number you want to go to followed byG
. For example,100G
takes you to line 100.Using the Command-Line Mode: Alternatively, you can use the command-line mode by typing
:
followed by the line number. For example,:100
will also take you directly to line 100.
No comments:
Post a Comment