pyceanx
pyceanx

Reputation: 43

Show line numbers only on command mode

I only ever use the line numbers when I want to switch to a line on the screen, which I use the command mode for (e.g. :82)

Is there a way to show the line numbers when I switch to command mode?

Upvotes: 4

Views: 1639

Answers (1)

SibiCoder
SibiCoder

Reputation: 1496

Yes. You can use map for that.

: nnoremap : :set nu<CR>:

This will set line numbers when you enter command line mode.

The following command will not show line numbers when you leave command-line mode.

  :nnoremap <CR> :set nonu<CR>

But this needs two enters to be pressed.

** As Andrew suggests, the following command des the same and avoids typing enter twice.**

:cnoremap <silent> <CR> <CR>:set nonu<CR> 

Put these two lines in your ~/.vimrc file.

Upvotes: 5

Related Questions