sponsor Vim development Vim logo Vim Book Ad

utlx_interwiki.vim : A scheme that adds interwiki linking to the script UTL

 script karma  Rating 12/3, Downloaded by 507    Comments, bugs, improvements  Vim wiki

created by
Marko Mahnič
 
script type
utility
 
description
A scheme for the vimscript#293 (UTL) that adds interwiki linking.
Requires vimscript#293. By default it supports UTL version 3.0.
To use with UTL 2.0, see Customization below.

A wiki can be defined anywhere in the current file like this:

   [wp]: http://en.wikipedia.org/wiki

A link from the current file to a page on the wiki may look like this:

   iw://wp/Vim_(text_editor)

By placing the cursor on the link, and executing :Utl, the link will be
internally expanded to

   http://en.wikipedia.org/wiki/Vim_(text_editor)

and passed to UTL which will open the URL in the preferred program.
See vimscript#293 for more information.

The URL can contain a placeholder '%p' that will be replaced with
the path of an interwiki link, for example

   [script]: http://www.vim.org/scripts/script.php?script_id=%p
   'iw://script/2997' --> http://www.vim.org/scripts/script.php?script_id=2997


Global wikis can be defined in .vimrc:

   let g:utlextra_interwikis = {
      \ 'LOG': ['/path/to/log', '.txt'],
      \ 'google': 'http://www.google.com/search?q=%p',
      \ }

This defines a wiki named LOG that is in the directory '/path/to/log' and
uses files with the extension '.txt'. To jump to a log entry from anywhere
an URL like the following can be used:

   iw://LOG/201002#tn=2010-02-27
  
which will be expanded to:
  
   file:///path/to/log/201002.txt#tn=2010-02-27

The extension .txt is added only if the path in the URL (/201002 in this case)
doesn't have one.

If at some point the log files are moved to another directory, all references
to the log entries will be valid if the value for '/path/to/log' is changed
in g:utlextra_interwikis.

The second interwiki, 'google' displays the results of a google search. Because
it doesn't have a default extension it is defined as a simple string.
The link iw://google/vim+editor will be expanded to

   http://www.google.com/search=vim+editor

('%p' is replaced by 'vim+editor') and displayed in the browser.

The format of g:utlextra_interwikis is similar to the format used in
vimscript#861 (Viki/Deplate). In fact if the 'intervikis' are defined
for Viki/Deplate, they will be imported by this script (interwikis
defined in g:utlextra_interwikis take precedence).

If interwikis are defined globally and also in the current file, locally
defined interwikis take precedence.

The format of an interwiki definition is:

   [name]: URL | default_extension

where default_extension starts with a dot. The format may change in the future
to avoid confilcts with other markup applications, for example:

   [w=name]: URL | default_extension

(please report confilcts and suggest alternatives on vim wiki).

Interwikis can also be defined in comments, but only a limited set of
comments is currently supported and the feature has not been extensively
tested:
   " [wiki]:...
   * [wiki]:...
   # [wiki]:...
   // [wiki]:...
   /* [wiki]:...

If the interwiki URL uses an empty wikiname, the link will be transformed
as a link inside the current wiki. The path of the current file will be
matched to all defined interwikis and if found, the settings for that wiki
will be used. If a wiki isn't defined, the target file will have the same
extension as the current file (if the path in URL doesn't already have an
extension).
  
   'iw:///localfile'        --> ./localfile.txt
   'iw:///localfile.viki'   --> ./localfile.viki
   'iw://./localfile'       --> ./localfile.txt


Customization:

g:utlextra_interwiki_scheme = 'iw'
   Change the scheme to use instead of 'iw'. Multiple schemes can
   be used for interwiki linking, for example 'iw,wiki'.

g:utlextra_utl_version = 3
   Which version of UTL is installed. The interface for defining
   additional schemas handlded by UTL has changed between versions
   2 and 3. This script supports version 3 by default.
   Set to 2 to use with UTL 2.0.

g:utlextra_import_viki = 1
   Set to 1 to import interwikis from Viki/Deplate.
   Set to 0 to skip importation.

g:utlextra_interwiki_match_case = 0
   If set to 1, the exact case must be used for interwiki names.
   If set to 0, first a case-sensitive match will be performed
   and if it fails a case insensitive will be used.

 
install details
Unpack into ~/.vim directory.

Add the follwing line to .vimrc to specify the installed version of UTL:
   let g:utlextra_utl_version = 2
(you can check the version of UTL with :h utl)

If the wrong version of UTL is specified, you will get an error like:
   E118: Too many arguments for function: Utl_AddressScheme_iw    

Prerequisites:
   * install vimscript#293 (UTL)
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
utlx_interwiki.zip 0.4 2011-02-17 7.0 Marko Mahnič * documentation added
* minor fixes
utlx_interwiki.zip 0.3 2010-02-28 7.0 Marko Mahnič Added parameter %p to interwiki URL definition
utlx_interwiki.zip 0.2 2010-02-28 7.0 Marko Mahnič Added support for UTL 2.0
utlx_interwiki.zip 0.1 2010-02-27 7.2 Marko Mahnič Initial upload
ip used for rating: 54.197.205.40

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo