Skip to content

Instantly share code, notes, and snippets.

@ugovaretto
Last active March 3, 2020 12:36
Show Gist options
  • Save ugovaretto/045e7d09c9a08216ae0ff6ae65aadf28 to your computer and use it in GitHub Desktop.
Save ugovaretto/045e7d09c9a08216ae0ff6ae65aadf28 to your computer and use it in GitHub Desktop.
Add line numbers to code in vim
1) Select lines visually: Shift + v
2) type following command: '<,'>s/^/\=line(".")-line("'<")+1.". "/
\= evaluate expression
line(".") line number of each selected line
line("'<") line number of the first line in the selection
. concatenation operator
". " concatenated string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment