Posted 2007-01-06T17:06:00+01:00 in web

SPARQL syntax file for the Vim editor

Recently I am toying with RDF and SPARQL. SPARQL is a language to query RDF triple stores, simply put. It is a bit what SQL is for relational databases. To keep me from writing spelling errors I wrote a first stab at a syntax file for SPARQL: sparql.vim

Example

PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc:   <http://purl.org/dc/elements/1.1/>
PREFIX :     <http://example/ns#>

SELECT ?book ?title
WHERE
{ ?t rdf:subject    ?book  .
  ?t rdf:predicate  dc:title .
  ?t rdf:object     ?title .
  ?t :saidBy        "Bob" .
}

# vim: filetype=sparql

Example taken from SPARQL Query Language for RDF, §2.9 Querying Reification Vocabulary

Installation

There are two methods to use this file: copy the file to your syntax files directory, e.g. ~/.vim/syntax/sparql.vim, and use the command "set syntax=sparql". The other option is to explicitly use the syntax at a location of your choice, by issuing a command in Vim like "syntax=downloads/sparql.vim".

Note that this syntax file only supports the query language, not the protocol or result file syntax.