VIM: Zero-Indexed Line Numbers in :set number

set relativenumber or for short "set rnu" This starts the count from 0


I suggest to wrap your tool in a small script. In the script, either copy the source code and add an empty line at the top of the source or use awk to fix the output (parse the error messages and add 1).

The only way to make vim display line numbers starting with 0 is to patch the source and create a new option (say lno for line number offset) and add this value to the line number. You'd need to patch this in quite a few places (display, goto commands, search patterns, etc). Shouldn't take more than one or two years to make it work :) Good luck on getting the author of Vim to accept this as a patch.


I don't think this is possible; however, assuming the output of your external tool is just text, it would probably be fairly easy to filter the output such that the numbering is 1-indexed to match Vim. Can you give us an example of your output?

Edit

Alternatively, if you call the external command from Vim, you could do something like (basically, add a blank line, run the external command and then delete the blank line):

command! RunMyExternalProgramme call RunMyExternalProgramme()

func! RunMyExternalProgramme()
    " Save the old setting of makeprg
    let s:savedMakePrg = &makeprg

    " Save the screen layout
    let s:savedView = winsaveview()

    if config_file != ''
        " Put a blank line at the start of the file
        :1put! =''
        " Save
        write
        " Change makeprg and run it
        let &makeprg = '/path/to/programme -options etc'
        make
        " Delete the blank line
        1d
        " Save
        write
    endif

    " Restore the screen layout (optional)
    call winrestview(s:savedView)

    " Restore the old setting of 'makeprg'
    let &makeprg = s:savedMakePrg
endfunc

Tags:

Vim