David Gay
David Gay

Reputation: 1154

In Vim, how can I show or hide line numbers depending on the current file's extension?

Vim can be configured to show line numbers by adding set number to your .vimrc.

How can I configure Vim to instead only show or hide line numbers for certain file extensions?

Examples:

A .vimrc-based solution is probably preferable, but barring that, workarounds are welcome.

Upvotes: 4

Views: 928

Answers (1)

Zorzi
Zorzi

Reputation: 792

Here's what you're looking for:

autocmd filetype markdown setlocal nonumber

for your first example, and

set nonumber
autocmd filetype ruby,javascript,vue setlocal number

Upvotes: 6

Related Questions