1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
|
*utl_ref.txt* Plugin for executing URLs from text files (reference manual)
For Vim version 6, Version: utl-2.0, $Revision: 1.11 $
Utl.vim Reference Manual
By Stefan Bittner
stb@bf-consulting.de
Contents:
1. The utl.vim reference........|utl-reference-manual|
2. Brief refresher URL and URI..|utl-uriprim|
NOTE: At the moment (utl.vim-2.0) the reference is not complete.
References:
- see |utlusr.txt| for the user manual
==============================================================================
1. The utl.vim reference *utl-reference-manual*
1.1 Fragment expression syntax *utl-fragexpr*
Utl.vim supports the following fragment expressions:
#tn=MySearchText "Text Next Search" *utl-#tn*
#MySearchText Addresses that position in the target file, which is
defined by searching the string "MySearchText" in
forward direction.
The search is done relative, i.e. beginning from the
actual position. This typically is the start of the
document. MySearchText can contain White Space. The
searching is done in a fuzzy manner (see
<URL:../plugin/utl.vim#r=fuzzy>). The basic idea of the
fuzzy search is that the semantic sequence of words
should be sufficient, in order to minimize broken
fragments.
#tp=MySearchText "Text Previous Search" *utl-#tp*
like #tn but search backwards.
#line=MyLineNumber e.g. line=23, line=-8. *utl-#line*
References the given line number in the text.
The search is done relative, like above.
#r=MyIdentifier ID-Reference. *utl-#idref*
References the defined `anchor' id=... in the target
document. See also |utl-fragmedtyp|. MyIdRef should be
an identifier (not a sequence of words). Note that
#r=foo and #r=foobar are distinguished whereas
#tn=foo will perhaps find the wrong position if there
also is as string foobar in the target document.
1.2. Dependency of fragment interpretation from media type *utl-fragmedtyp*
According to RFC2396, the interpretation of fragments determined by
the type of the target document (see:
<URL:http://www.ietf.org/rfc/rfc2396.txt> #tn=is dependent on the media type )
For media types other than "text/*" fragments will be ignored (e.g. for
"image/*")
For "text/*" utl.vim makes a difference between "text/html" and all other
"text/*" subtypes. But the interpretation of tn=, tp=, line= is the same for
_all_ text/* subtypes. Just the IdRef interpretation is different:
text/html IdRef interpreted as a HTML-reference (i.e. NAME="myRef")
text/* IdRef interpreted as "txt-reference" (i.e. id=myRef)
1.3 Utl.vim internals *utl-internals*
1.3.1 Definition of LocalPath
Utl.vim internally has a notion "LocalPath". LocalPath is an absolute path
of the local file system. A real local file (or directory) with that name
exists. A pure buffer is not possible (at the moment). Utl's is simpler due
to this restriction. For localPath a resource mapping exists.
1.4. Mappings and Commands *utl-mappings* *utl-commands*
Note: The mappings below depend on the |mapleader| variable. This means,
instead of \gu it might be ,gu or whatever.
1.4.1 `Goto URL under cursor' mappings *utl-gourlundercurs*
The following mappings are available to execute the URL under the cursor:
\ge, \gE, \gS, \gu *utl-ge* *utl-gS* *utl-gu*
Goto URL under cursor. Open the target read/write.
\ge replaces the current window with the target (:edit)
\gE opens the target in a split window (:split).
\gS opens the target in a vertical split window (:vsplit)
\gu is the same as \ge. It is provided for easy mnemonics: gu = Go Url
It's the only command you really have to know in order to use
utl.vim!
\gv, \gV *utl-gv*
Goto URL under cursor. Open the target read only
\gv replaces the current window with the target (:view).
\gV opens the target in a split window (:sview).
\gr *utl-gr*
Read the URL under cursor into the current buffer at the current
position (:read)
1.4.2 `Goto visual URL' mappings *utl-gourlvis*
Same as the above mappings, but the but the highlighted text is used as the
name of the URL. The visual mappings are useful when you have a text where the
URLs are not embedded. Example: "See http://vim.sf.net for useful Vim plugins"
*utl-v_ge* *utl-v_gs* *utl-v_gu*
{Visual}\ge, {Visual}\gE, {Visual}\gS {Visual}\gu
{Visual}\gv, {Visual}\gV *utl-v_gv*
{Visual}\gr *utl-v_gr*
1.4.3. `Goto URL by command' *utl-gourlcmd*
Type in an URL manually.
:Gu {URL} *utl-:gu*
Goto the typed URL.
The difference between \gu and :Gu is like in an web browser: typing
an URL versus clicking an URL in the displayed text. But there is one
important difference though. :Gu is executed in the context of the
current buffer, i.e. :Gu myurl is the same as clicking \gu on
<URL:myurl> in the text of the current buffer. That means that
relative URLs are possible! So :Gu can be used for relative editing.
See |utl-tipsguusage| or |utl-tuttypeurl| for examples of usage.
1.6.4. Other mappings and commands
\gs *utl-gs*
Show the base URL that is associated with the current buffer in the
status line, if any.
Else shows the text `no associated URL'. That means, that the current
buffer was not invoked as a link target (i.e. was not invoked through
a utl.vim `Goto URL' command like \gu, :Gu etc).
\gs just does a lookup utl's cache (see |utl-gc|).
Tip:
If, in the `no associated URL' case, you like to know what the base
URL is, you can first issue the command
:exe ':Gu ' . expand('%')
to "urlify" the current buffer (see |utl-tutfileisdef|); a
subsequent \gs then shows the associated URL. This can be useful while
learning utl.vim. The associated URL is always an absolute URL. And
it is the base URL that would be taken when a link, containing a
relative URL, would be executed out of the current buffer, e.g. a
<URL:someUrl> is executed.
\gc *utl-gc*
Shows utl.vim's internal cache map in a separate window.
Useful mainly to see what's going on. See |utl-tutcachemap| for
more information.
==============================================================================
2. Brief refresher on URL and URI *utl-uriprim*
This chapter might be worth reading if you are thinking about designing your
own protocols. If you are going to extend Utl, it's source code will be easier
understandable if you know URLs better. But it is also intended for the
interested user to acquire a more thorough understanding of URLs and Utl in
general.
Uniform Resource Identifiers are specified in RFC 2396, see <URL:http://www.
ietf.org/rfc/rfc2396.txt>.
URI vs. URL *utl-uri-uriurl*
-----------
#uu geht so nicht mehr!
( Reference: <URL:http://www.ietf.org/rfc/rfc2396.txt> #tn=^1.2. )
URL - Uniform Resource Locators are a subset of URI: A URL is a URI. As the
name says, a URL identifies a resource by its (network) location. Other ways
to identify a resource are suggested with "Uniform Resource Names" (URN).
URI = URL | URN.
But for the purpose of utl.vim you can ignore the difference between URIs and
URLs.
The three letters U, R, I *utl-uri-3letters*
-------------------------
( Reference: <URL:http://www.ietf.org/rfc/rfc2396.txt> #tn=^1.1 Overview
The following material is directly taken from there )
URI are characterized by the following definitions:
Uniform
Uniformity provides several benefits: it allows different types of resource
identifiers to be used in the same context, even when the mechanisms used
to access those resources may differ; it allows uniform semantic
interpretation of common syntactic conventions across different types of
resource identifiers; it allows introduction of new types of resource
identifiers without interfering with the way that existing identifiers are
used; and, it allows the identifiers to be reused in many different
contexts, thus permitting new applications or protocols to leverage a
pre-existing, large, and widely-used set of resource identifiers.
Resource
A resource can be anything that has identity. Familiar examples include an
electronic document, an image, a service (e.g., "today's weather report for
Los Angeles"), and a collection of other resources. Not all resources are
network "retrievable"; e.g., human beings, corporations, and bound books in
a library can also be considered resources. The resource is the conceptual
mapping to an entity or set of entities, not necessarily the entity which
corresponds to that mapping at any particular instance in time. Thus, a
resource can remain constant even when its content---the entities to which
it currently corresponds---changes over time, provided that the conceptual
mapping is not changed in the process.
Identifier
An identifier is an object that can act as a reference to something that
has identity. In the case of URI, the object is a sequence of characters
with a restricted syntax.
Having identified a resource, a system may perform a variety of operations on
the resource, as might be characterized by such words as `access', `update',
`replace', or `find attributes'.
URI Syntactic Components *utl-uri-syntcomp*
------------------------
( Reference: <URL:http://www.ietf.org/rfc/rfc2396.txt> #tn=^3. URI Syntactic )
An URI goes like this:
<scheme>:<scheme-specific-part>
That means, that the thing behind the colon is specific to the scheme!
The scheme-specific-part is also known as the `opaque' component.
But many schemes have a hierarchical structure, which is also defined by
RFC 2396. The syntax for hierarchical URI is:
<scheme>://<authority><path>?<query>
The `authority' often is a host name (but can also be, say, a windows drive).
An example for a non hierarchical URI is the vimhelp scheme, e.g. `vimhelp:help'.
Another example is the mailto scheme: mailto:stb@bf-consulting.de
Each of the above components may be missing, and it's still a valid URI.
URI References *utl-uri-refs*
--------------
( Reference: <URL:http://www.ietf.org/rfc/rfc2396.txt> #tn=^4. URI References )
URI reference = URI # fragment
The fragment is not part of an URI! But it often appears in conjunction with
it, so RFC2396 deals with the fragments also. Utl.vim doesn't care much
making the correct distinction. Most often it is clear from the context.
Fragment Identifiers *utl-uri-fragids*
--------------------
( References: <URL:http://www.ietf.org/rfc/rfc2396.txt> #tn=^4.1. Fragment )
It is very important to realize, that fragment interpretation only depends on
the media type of the "retrieved" document. Not from, say, the scheme, i.e.
the protocol.
This property is utilized by utl.vim since it defines fragment syntax for
generic, unstructured text (i.e. tn= line=).
Absolute and relative URI *utl-uri-relabs*
-------------------------
( Reference:
<URL:http://www.ietf.org/rfc/rfc2396.txt> #tn=Relative URI references are distinguished )
URI come in two forms: relative and absolute. The rule to distinguish between
the two is very simple:
Scheme component exists = It's an absolute URI
Normally, a relative URI is transformed into an absolute URI by the
application context in which the relative URI appears. Context = base URL
Escaping forbidden characters *utl-uri-forbchars*
-----------------------------
#uu stimmt nicht mehr so
( Reference: <URL:http://www.ietf.org/rfc/rfc2396.txt> #tn=^2. URI Char )
Only a limited set of ascii characters are allowed in an URI. Some other
characters, like < > ? / : for example, are reserved characters, in the sense
that they have a special meaning for the URI itself.
If you need to use a forbidden or reserved character, you have to escape it
by its hex value. Examples:
`>' -> `%3e'
` ' (blank) -> `%20'
Hint: Just use Vim's :asc command <URL:vimhelp:asc> to find out the hex value of
a character!
If in doubt if a character is forbidden you can also escape allowed
characters. Example: <URL:vimhelp:%61%73%63>
==============================================================================
FOOTNOTES
-----id=foot1
Thanks for trying out utl.vim :-)
vim:tw=78:sw=4:sts=4:ts=8:ft=help:norl:
|