Skip to content

New feature request: sort of bibtex by bibkey #1293

@vanabel

Description

@vanabel

Currently, I develop a javascrip plugin that will replace the bibkey generated by AmsSciNet, which is MRnumber, to Author+Year+Title, it helps me a lot when I cite the reference, since I can distinguish them easily.

I believe it is helpful to sort of bibtex items by the bibtex key, e.g., when we check the dumplicated items, I would like to share a solution from so:
put the following macro into .vimrc,

let @b=':g/^}$/s//}\r
:g/^@/,/^}$/s/\r\|\n/の
:%sort r /{[A-z0-9]\+,の/
:g/の/s//\r/g
:g/^$/d
:w
'

where we should replace the linebreak by ^M, it is Ctrl+V Ctrl+M on windows gvim. After so it, we can apply the macro b in bibtex file by @b in normal mode, which will automatically sort the bibtex items through its bibkey.

Of course, we can execute the macro whenever we write the bibtex data:

au! BufWritePost *.bib :norm @b<cr>:set fdm=syntax<cr>

I think it is interesting to add this function as a minor improvement of vimtex. How about you?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions