Created
February 26, 2012 22:00
-
-
Save dsanson/1919205 to your computer and use it in GitHub Desktop.
Vim Folding for RIS files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Some folding functions for using Vim with RIS files... | |
" Lines starting with 'TY -' trigger folds | |
set foldexpr=RIS_Fold() | |
set foldmethod=expr | |
fun! RIS_Fold() | |
let thisline = getline(v:lnum) | |
if thisline =~ '^TY -.*' | |
return '>1' | |
else | |
return '=' | |
endif | |
endfun | |
" When entry is folded, display the ID, or, if no ID, author and title. | |
set foldtext=RIS_FoldText() | |
fun! RIS_FoldText() | |
let linenum = v:foldstart + 1 | |
let result = '' | |
while linenum < v:foldend | |
if getline(linenum) =~ '^ID.*' | |
return substitute(getline(linenum), '^ID - ', '', '') | |
elseif getline(linenum) =~ '^AU.*' | |
let result = substitute(getline(linenum), '^AU - ', '', '') . '. ' . result | |
elseif getline(linenum) =~ '^TI.*' | |
let result = result . substitute(getline(linenum), '^TI - ', '', '') | |
endif | |
let linenum += 1 | |
endwhile | |
return result | |
endfun | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For plain-text management of bibliographic data, RIS is promising because it is so simple. There is a vim-ris plugin here. The syntax file works okay, though it could use some work. I haven't been able to get the rest of that plugin working.
Other functions that would be nice implement in a vim RIS plugin: sorting entries by field; autogenerating citekeys (IDs); opening links to URLs and local files; displaying skim comments... Importing and exporting to other formats could be handled by bibutils.