sponsor Vim development Vim logo Vim Book Ad

partialnumber.vim : yet another line number option

 script karma  Rating 1/1, Downloaded by 194    Comments, bugs, improvements  Vim wiki

created by
Rick Howe
script type
This plugin shows line numbers or a mark for the specified range with an optional highlight group, by using the vim's sign feature, without modifying the buffer contents.

While running some plugin or your vimrc, you might have seen such an error message:
        Error detected while processing function MyFunc:
        line   37:
        E706: Variable type mismatch for: abc
        line   61:
        E684: list index out of range: 19
        E15: Invalid expression list[idx]
Even with the use of number and relativenumber options, it is not easy to find where those lines of that function are actually displayed in a vim window. But by using this plugin, for example,
        :g/^function/+1,/^endfunction/-1 SetPNU
will assign and show the line numbers for each function individually so that you can see those line numbers on the sign column.

The highlight group option (default: SignColumn) can be used to show the partial line numbers with its highlight and to identify those line numbers as a group of each highlight. For example,
        :g/^{/,/^}/ SetPNU ToDo
        :.,+12 SetPNU - 0
        :'<,'> SetPNU ToDo @@
        :g/printf/ SetPNU Title ++
can show and make 3 different groups. And then,
        :SetNoPNU ToDo
will clear all the partial line numbers of 'ToDo' group but leave others.
        :SetNoPNU *
will clear all of the groups.

Since the vim's sign feature allows to use just 2 columns, the last 1 or 2 digits of the partial line number are displayed in front of each line.  To try to show upper digits, a line number which can be just divided by 100 is displayed as a circled number until 5000 and an empty circle beyond (100/200/.../5000 = circled 1/2/.../50 (①/②/.../㊿), 5100/5200/... = empty circle (○)).

If some lines are added or deleted while showing the partial line numbers, this plugin does not follow those changes.

:[range]SetPNU [group] [start]
        Show the partial line numbers for [range] with highlight [group].
        [range] : a line range (default: current line)
        [group] : a highlight group (- or default: SignColumn)
        [start] : a start line number, or a mark if not a number (default: 1)
:SetNoPNU [group]
        Clear all the partial line numbers shown with highlight [group].
        [group] : a highlight group (*: all, - or default: SignColumn)

Update 1.1
* Added '*' for SetNoPNU highlight group option
* Changed to display circled line numbers to show upper digits
install details

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
partialnumber.vim 1.1 2015-12-22 7.0 Rick Howe Added '*' for SetNoPNU highlight option. Changed to display circled line numbers.
partialnumber.vim 1.0 2015-12-20 7.0 Rick Howe Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
SourceForge.net Logo