Search code examples
vim

Format of marks in viminfo


I'm trying to find information on how file marks are stored in the 'viminfo' file. For example, here is an entry I have:

'0  3  11  ~/.vim/hello
|4,48,3,11,1592944829,"~/.vim/hello"

The only obvious things from the above seem to be the filepath the mark is saved, ~/.vim/hello and the timestamp it was created 1592944829. What are the other items, and why are some of the items listed multiple times (3, 11, filename).


Solution

  • you are reading the wrong block.

    In the viminfo file, search for the lines beginning with >, they are mark histories.

    And there is usually comment in the file.

    For example:

    # History of marks within files (newest to oldest):
    
    > /tmp/test/whatevertestfile.txt
        *   1592998167  0
        "   4   0
        ^   1   0
        .   1   0
        +   1   0
        a   4   0
        b   9   0
    

    update

    Oh, I just noticed you mentioned file marks in the question. Then you are looking at the right block.

    The positions in the two lines are always the same because the write_one_filemark() function reads the same values for the two lines.

    • The first 4 is an index in the viminfo file, it indicates the mark type.
    • The 48 is the ascii code of the numbered mark 0 .
    • Then come the position + ts + filename

    If you want to know more detailed, why it is so defined and so on, you can read the related part of this file https://github.com/vim/vim/blob/master/src/viminfo.c