-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathutl_usr.txt
2194 lines (1563 loc) · 80 KB
/
utl_usr.txt
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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*utl_usr.txt* Plugin for executing URLs in plain text files
*utl* *utl-plugin*
Version Utl v3.0a ALPHA, for Vim version 7, 2008-07-31
Utl.vim User Manual
By Stefan Bittner
Contents:
1. Intro........................|utl-intro|
2. Getting started..............|utl-start|
3. Tutorial.....................|utl-tutorial|
4. Smart Samples................|utl-smartSamples|
5. Usage Patterns...............|utl-usagePatterns|
6. Tips, details, pittfalls.....|utl-tipsDetails|
7. Configuration and Options....|utl-config|
8. Changes since Utl v2.0.......|utl-changes|
9. Todo.........................|utl-todo|
10. Credits......................|utl-credits|
See http://vim.sf.net/script.php?script_id=293 for getting and installing
Utl.vim.
See |utl-changes| for things that have changed in this version.
Any comments, bug reports, patches, fixes and suggestions are welcome.
Happy linking,
Stefan Bittner <url:mailto:[email protected]>
==============================================================================
1. Intro *utl-intro*
What is Utl.vim?
It brings the benefits of URL-based hyperlinking to plain text, extending the
URL syntax for plain text needs, in accordance with the RFC 2396 (towards
current RFC 3986) URL specification.
Keywords: Hypertext, URL, URI, email, footnotes, Wiki.
Usages:
- Open any URLs found in text with appropriate handler
- Open files of any media type from within Vim (.pdf, .jpg, etc)
- Small helper utilities via embedded Vimscript
- Project management
- Organizing ideas
- Commenting source code
- Personal Wiki
- Editing HTML
Characteristics:
- Well documented and helpful verbose mode
- Is easy to get started
- Stays out of the way, no side effects
- Extensible
Now lets dive into the live examples.
=============================================================================
2. Getting started *utl-start* *utl-getStarted*
Utl.vim's basic command to open an URL is :Utl . That's all you need!
Live Examples now!!!
Position the cursor on the next line:
<url:#r=here>
Then type the comamnd :Utl . This should take you ...
id=here.
You just executed your first link!
`#r=abc' refers to a position in the document, that looks like `id=abc'. (If
you know HTML: that's analogues to a <A HREF="#abc"> which refers to
ID="abc".) The `r' in the expression stands for `reference'.
Executing :Utl on <url:#tn=some text> takes you to ...
some text.
The special syntax `tn=' just means that the target of the link is defined by
searching the denoted string 'some text' in forward direction (tn stands for
Text Next). You can omit the `tn=' prefix and just write <url:#some text>
because the tn= is the default prefix.
Executing :Utl on <url:../plugin/utl.vim> takes you to the file utl.vim.
Please come back here again after having executed the link!
Executing :Utl on <url:../plugin/utl.vim#tn=thanks for> takes you to a
specific position in the file utl.vim. This example can be seen as the
combination of the two previous examples: URL + #xxx
The #xxx suffix is called a fragment expression in URL lingo.
Executing :Utl on <url:http://www.vim.org> will invoke your web browser with
that URL. Just try it, if you are lucky Utl.vim already knows how to open web
pages, else Utl.vim will assist you to set up your favorite browser.
You can leave away the <url:...> embedding. Try for example:
http://www.vim.org
or even
www.vim.org
An advantage of embedding-less links is that normally you will find URLs in
given documents in this form. Furthermore the <url:...> embedding can be a bit
clunky. The disadvantage is that there is no safe parsing for "naked" URLs and
as one consequence of this, no syntax highlighting.
The above utl.vim link without embedding reads:
../plugin/utl.vim
For some file in the same directory as the current file you would have:
./someFile.txt
or, a file without a suffix:
otherFile
or
WikiWord
This means that you can use Utl.vim to turn Vim into your personal Wiki.
There a specialized Vim plugins (vimwiki, potwiki.vim), but people
told me the linking (and document creation) feature already does a good part
of the job.
Utl.vim supports links that could be called reference style links or just
footnotes. Position the cursor on the [10] in the next line and execute :Utl :
The software can be downloaded from [10]
.
.
[10] http://www.vim.org/download.php
One often encounters such references in given text. So Utl.vim does not invent
a new syntax but just supports what is there. (The same is actually true for
the for the URL based links.)
From now on I will use those [] -footnotes :-)
You can also type an URL in the command line:
:Utl openLink ../plugin/utl.vim # Open file that is in same directory
# as current file
or in short form
:Utl ol ../plugin/utl.vim # same as above
Other
:Utl ol www.google.com # Open web page from within vim. Sometimes faster
# faster than from desktop.
If you feel it's now time for a "hello world" test, just go ahead and write
your own links. There is no meta data and no tags file needed. Its nothing
but plain text.
Before you seriously start using Utl.vim it is recommended to continue with
reading the next chapter, 3, Tutorial. If you are in doubt if Utl is valuable
for you, have a look at chapter 5, Examples of use, |utl-examples| first.
==============================================================================
3. Tutorial *utl-tutorial*
3.1 Forth and back *utl-tutforthback*
From the previous chapter you already know how to follow links by executing
:Utl for links under the cursor.
The following link, as you know, takes you to another file:
<url:../plugin/utl.vim>
Try this now! ... No, Wait! To come back here again, just use the regular
vim command CTRL-O. That's the BACK-Button in the "Vim browser" - and it might
need to be typed more than once.
Now do it!
Hope you are back again.
3.2 Relative and absolute URLs *utl-tutrelabs*
The following URLs are all equivalent:
<url:utl_usr.txt>
<url:./utl_usr.txt>
<url:../doc/utl_usr.txt>
These are all so called relative URLs. This means that the path given in the
URL is relative to the path of the document containing the URL. NOte that this
is different to Vim's :e command where file names are relative to the current
working directory (see |:pwd|). Whenever possible you should use relative
URLs. But sometimes you need absolute URLs, just as you sometimes need
absolute path names with Vim's :e command. Here is an absolute URL:
<url:file:///home/stb/.vim/plugin/utl.vim>
An absolute URL always has a so called scheme (also called protocol) in
front, e.g. file: , http:, mailto: . (And, if there is a protocol in front it
always is an absolute URL.) What also makes sense is to write the above URL
without the protocol:
<url:/home/stb/.vim/plugin/utl.vim> # equivalent to above
This is a relative URL (because there is no protocol) ... containing an
absolute path. The contrary does not make sense: An absolute URL with a
relative path:
<url:file:../plugin/utl.vim> # WRONG!!! Absolute URL with relative path
# is an invalid URL.
When you try to execute this URL, the current implementation of Utl.vim opens
a file utl.vim in the current working directory - not a good behavior
for an URL.
3.3 Running Utl.vim in verbose mode *utl-tutverbosemode*
Utl.vim supports a verbose mode:
:let utl_opt_verbose=1 # Switched on
:let utl_opt_verbose=0 # Switched off (default)
Verbose mode can be very useful to figure out what's going on. For instance
for the previous section you can see the different processing between absolute
and relative URLs and how the latter are turned into absolute URLs by
constructing a base URL. Try for example to execute:
<url:../plugin/utl.vim>
with verbose mode switched on. Don't forget to use this feature when things
get more complicated!
3.4 Drive letters and network shares *utl-tutdrivesshares*
Under Windows you can specify drive letters like this:
<url:file://d:/path/to/foo.txt> or, which is the same,
<url://d:/path/to/foo.txt>
This is in conformance with URL specifications. Note that you always should
use forward slashes, no matter on what OS you are; URLs are universal and thus
independent of the OS.
Utl supports notation for network file access, e.g. Shares under
Windows, NFS under Unix.
Windows Example: Utl converts <url://127.0.0.1/ADMIN$/System32/EULA.txt>
internally into the UNC path \\127.0.0.1\ADMIN$\System32\EULA.txt, which is
directly passed/edited to/by Vim, since SMB shares are transparent under
Windows.
Unix Example: Utl converts <url://server/sharefolder/path> internally
into server:/sharefolder/path . (Don't really know if this makes
sense :-)
Windows Examples:
<url://89.11.11.11/testinput/cfg/sid_7_configuration_list.txt>
<url://56.240.74.41/c$/install_pers/setup.log>
Utl does neither care if authentication is needed on the server resource nor
does it offer direct means for authentication [20].
3.5 Fragments *utl-tutfrags*
--- Intro *utl-tutfragsintro*
Now lets add fragments to URLs.
The next link again references the same file as in the above examples, but is
extended by a fragment expression. That way a specific position in the target
file can be jumped to. Try to execute the link:
<url:../plugin/utl.vim#tn=thanks for>
and come back again with CTRL-O. The next link specifies the same file, but
the fragment expression is different:
<url:../plugin/utl.vim#r=foot1>
Execute it and come back again! It took you to about the same position as the
previous link, but by other means. The fragment `#r=foot1' means, that the
file utl.vim is searched for the ID reference `foot1'. What follows r=
should be a simple string (an identifier to be exact).
The #tn fragment has one big advantage over #r= fragments. It allows to
refer to specific positions in the target document without the need to
modify that target document, either because you don't want it or because you
don't have write access. The advantage of the ID reference fragment is that
the link is more robust.
#tn= and #r= are the most important fragment specifiers in Utl.vim. As
already said, the #tn= prefix is the default prefix, i.e. you can leave it
away. Thus the link above will normally be written shorter:
<url:../plugin/utl.vim#thanks for>
This is also called a naked fragment identifier because there is no `key='
prefix.
The found string will _not_ get the current search string (I don't know why).
This means it will not be highlighted and you cannot search the next
occurrence with Vims n command. But the string is one up in the search
history, so you can recall it from there.
--- Line fragment and bottom up addressing *utl-tutfragsline*
Another fragment identifier is #line. It positions to the given line,
e.g.
<url:utl_usr.txt#line=10> (or #line=+10)
This is useful for documents that won't change much. Negative numbers
can be given as well:
<url:utl_usr.txt#line=-10>
This counts the lines from bottom of the buffer upwards, -1 specifies
the last line. For the #tn identifier there is also a "bottom-up" possibility,
the #tp identifier. Try and compare these two:
<url:utl_usr.txt#tp=vim>
<url:utl_usr.txt#tn=vim>
--- Relative addressing *utl-tutfragsrel*
So far all fragment addressing was relative from top or bottom of the buffer.
It can also be relative to the current cursor position in two cases:
a) Same-document references *utl-tutfragsdref*
These are URLs that only consists of a fragment. Examples:
<url:#line=3>
<url:#line=-3>
<url:#tn=fragment>
<url:#tp=relative>
Same document references are often useful, for instance to turn phrases like
"see above" into hotlinks. NOte that for an #r= -reference, see
<#tp=ID Reference>, there is no relative addressing because only one id=
target per file is assumed.
b) Non file oriented resources and the Vimhelp scheme *utl-tutfragsnonfile*
The best example is the Vimhelp scheme, e.g. <url:vimhelp::ls> (which is
hereby introduced). When you execute this URL the Vim help for the :ls
command is displayed. Although the help will normally be presented as a text
file in Vim (namely doc/windows.txt) the file is not really the resource, the
help item itself is the resource. It's often useful to use the Vimhelp URL and
sometimes especially useful to combine it with a fragment. Example:
Readonly buffers are marked with `=', see <url:vimhelp::ls#readonly>
The utl.vim source code gives more realistic examples, see for instance
<url:../plugin/utl.vim#since a string>.
See <url:../plugin/utl.vim#r=Utl_processFragmentText> for details about
fragment processing.
3.6 Other media types *utl-tutmtypes*
URLs are not restricted to .txt files or web pages. You can for instance
reference a PDF document:
<url:foo.pdf>
To make this work a handler for .pdf type files has to be present. If you are
lucky Utl.vim already defined a handler for you. Utl.vim aims to provide a
generic media type handler for the most common platforms. The generic media
type handler should handle a file like the system does (e.g. left (double)
click to the file in the systems file explorer). The generic media type
handler is implemented by the Vim variable g:utl_cfg_hdl_mt_generic .
It can be overruled by a specific media type handler. For PDF files this would
be g:utl_cfg_hdl_mt_application_pdf. See explanation under
<url:config:#r=mediaTypeHandlers> how to provide a specific handler. Normally
the generic handler will be sufficient. A specific handler is needed for instance
if fragments should be handled (see |utl-tutextfrag|).
It is a good idea to test with verbose mode switched on if you want to
define a specific media type handler If none of the handlers (specific and
generic) is present, Utl.vim will try to make creation of a handler as
painless as possible through a smart setup facility which is invoked
automatically then [22].
3.7 Link to folders *utl-tutfolders*
An URL can also specify a folder:
<url://c:/Program Files> # Windows
<url:/usr/local/bin> # Unix
<url:./tmp>
<url:.>
Folders also have a media type associated: text/directory. This means
the specific or the generic media type handler has to be present to open
a folder-URL. Utl.vim predefines the specific handler. The definition is:
:let g:utl_cfg_hdl_mt_text_directory='VIM'
The special value 'VIM' means that no external handler shall be called but the
folder should be opened by (the current) Vim, which will use Vim's built in
netrw directory browser. The special value 'VIM' can also be used for all
other utl_cfg_hdl_mt_xxx handlers. Try to execute <url:.> to see how that
works.
But what if you want to open a directory not with Vim but rather with the file
explorer of your system? Well, that is easy if your generic handler is set
up [23]:
:let g:utl_cfg_hdl_mt_text_directory=g:utl_cfg_hdl_mt_generic
Another possibility is to open a directory in a command-shell, i.e.
open a shell with CWD set to the directory. Can be achieved by:
:let g:utl_cfg_hdl_mt_text_directory__cmd = ':!start cmd /K cd /D "%P"' " Windows (DOS box)
:let g:utl_cfg_hdl_mt_text_directory__cmd = ':!bash ... " Unix
Unfortunately Utl.vim does not provide a means to dynamically choose one of
these handlers, i.e. open one directory in Vim, the other in the systems
explorer, the next in a command shell. But there is a workaround: Define
mappings for the above assignments. See <url:config:r=#map_directory> for
suggested mappings.
3.8 Typing an URL *utl-tuttypeurl*
In a web browser there are two ways to go to a page:
- You follow a hyperlink from the page you are in.
- You type an URL in the address field.
Possibility 1 corresponds to ':Utl' in Utl.vim. Possibility 2 corresponds to
the command. Examples:
:Utl openLink ../plugin/utl.vim
:Utl openLink www.vim.org
You can use this for editing another file which is in the same directory as
the current file. Example:
gvim /really/an/annoying/long/path/to/src/main.c
:Utl openLink option.c " [24]
I myself use :Utl a lot for this purpose. Most often I type directory-URLs,
see previous section |utl-tutfolders|. And my favorite folder is . (dot), i.e.
the current directory:
:Utl openLink . " or, shorter:
:Utl ol .
So :Utl ol . opens the directory the current file is in. Either in Vim, the
systems file explorer or in the command-shell.
3.9 The Utl user interface *utl-tutUI*
Until now you know the commands :Utl (to open the URL under the cursor) and
:Utl openLink myUrl (to open a typed URL). The general command interface is:
:Utl <command> <operand> <mode>
:Utl (without any arguments) is the same as:
:Utl openLink underCursor edit
since these are the default values for the three arguments. Instead edit
which displays the file in Vim [25] with the Vim command :edit you might
want to open the link in a split buffer or in a new tab and so on (just as
you open files in Vim in many different ways):
:Utl openLink underCursor split " Open link in split window
:Utl openLink underCursor tabe " Open link in new tab
Try these with the URL
<url:../plugin/utl.vim> !
Utl.vim provides command line completion for the arguments to save typing. I
recommend to set the 'wildmenu' option for enhanced completion [26]. Try:
:Utl co<Tab> " or
:Utl co<CTRL-D> " or
:Utl<Tab> " etc.
The completion works the like for second and third argument. Another aspect
of completion besides saving typing is that it offers the possibilities in a
menu like manner which makes it unnecessary to learn all the commands,
especially those used less frequently [27].
Additionally to completion Utl.vim supports abbreviations for the arguments.
The following are equivalent:
:Utl openLink underCursor edit " is same as:
:Utl ol uc edit " is same as:
:Utl o u edit
See <url:../plugin/utl.vim#r=cmd_abbreviations> for all abbreviations and
explanation of the abbreviation rules. If you typed an abbreviation for
an argument completion does still work for further arguments, e.g.
:Utl o u<CTRL-D>
Again, verbose mode might help to figure out what's going on when playing with
abbreviations.
One design goal of the Utl.vim user interface is to make mappings obsolete
for the most since commands are short enough. Note that you can save one
character on :Utl,
:Ut
is possible in standard Vim 7.1 [28]. See <url:../plugin/utl.vim#r=suggested_
mappings> if you consider to use mappings anyway.
3.10 Visual URLs *utl-tutVisUrls*
Sometimes you want to execute an URL which is different from what Utl.vim
would parse out. Examples (desired URL underlined):
~dp0register_packages.bat " (Windows) file name not separated as (Utl) word
---------------------
<url:./path/to/file.txt > " Only the directory part wanted
---------
Visually select the URL, possibly copy to clipboard (with CTRL-C under
Windows), then execute
:Utl openLink visual " or, shorter
:Utl o v " [29].
3.11 The Vimscript scheme *utl-tutVimscript*
Utl.vim supports a special non standard protocol to execute Vim commands from
within a plain text document. It is introduced here because needed in the
sections which follow. The general format is:
vimscript:<ex-command>
Try these examples:
<url:vimscript::ls> " This which is the same as:
<url:vimscript:ls> " (i.e. you can omitt the `:')
"Ex-command" is just the same as what you can type in an ex command line, for
instance multiple commands can be concatenated with `|'. Example:
<url:vimscript:split|call input('I will open a new window now!')>
Certain characters needed in an ex command line will collide with characters
that have special meaning for URLs. In this case you have use normal URL percent
encoding. Example:
<url:vimscript:call input('Hit %3creturn%3e to continue')>
The 3c is the hex value of the < character, the 3e is the hex value
of the > character. Just keep in mind that if an URL does not work, then try
to encode the characters appearing dangerous with percent encoding [30].
Vimscript ex commands are executed in the context of a function (namely
the handler, <../plugin/utl_scm.vim#r=vimscript>). This has the implication
that global variables must be prefixed with g:
See |utl-smartsamples|for more vimscript examples.
3.12 Other commands and options to operate on an URL *utl-tutOtherCmds*
COPYLINK *utl-tutCopyLink*
Until now we always opened (displayed) the target of an URL, i.e. jumped to
the URL. You can also copy the link to the clipboard:
:Utl copyLink " or, shorter
:Utl cl
This does the same as the right mouse popup function called 'copy link
address' or so in web browser. Try for instance :Utl cl on
<url:../plugin/utl.vim> and
check the * register by executing
<url:vimscript::reg *>.
NOte that the register contains an absolute URL, not a relative one. Copying
links is often useful, for instance to email a link address to someone.
Another nice usage is to open the current file in another Vim instance:
:Utl copyLink currentFile
then switch to the other Vim instance and perform:
:Utl openLink <URL pasted from clipboard>
This example also introduced the currentFile operand (you already know
underCursor, visual, <typed URL>).
COPYFILENAME *utl-tutCopyFileName*
Related to copyLink is copyFileName
:Utl copyFileName " or, shorter
:Utl cf
which copies the full path to the clipboard. Try the URL with the command
:Utl copyFileName:
<url:../plugin/utl.vim>
and check the * register. Usage example: use copyFileName for a file you
want to mail to someone as an attachment. Paste that file name in your mailer.
Probably even more interesting is the other way round: You received a
mail attachment and want to make it hot linkable from within a text file.
Create a new link in the text file, e.g.
<url:./infos/20080523_Instructions_Workreports_ext.ppt> ,
then perform
:Utl copyFileName
and paste the result into the 'save as' dialog of your mailer [31]. This can
save you a lot of tedious browsing down directories in GUI programs
(especially under Windows). CopyFileName does only work for (implicit or
explicit) file:// URLs, not for example for http:// URLs.
The file name will have slashes or back slashes depending on your system.
But you can force the one or the other (for instance if using Cygwin under
Windows):
:Utl copyFileName underCursor backslash
:Utl copyFileName underCursor slash
(As these are positional parameters you have to provide a second argument,
'underCursor' here).
For reference of all available commands and arguments see:
:Utl help commands
3.13 The http scheme *utl-tutscmhttp*
Until now we concentrated on local files. The scheme for a local file is
(implicitly or explicitly) `file', e.g. file://path/to/file. Of course
an URL can be used to retrieve other than local resources (a web page) or
other resources than files (an email).
Depending on what you are using Utl.vim for, file might be the most important
scheme, followed by mail and http . Lets consider http now.
You already know that you can execute the links:
<url:http://www.vim.org>
http://www.vim.org
www.vim.org
They are all equivalent. To make a http URL with fragment work, e.g.
http://www.vim.org/download.php#unix
the defined handler has to support that, which might not be the case in
the default setup. You have to set up a handler that supports the %f
conversion specifier. See the hints and instructions
<url:config:#r=schemeHandlerHttp>
how to do this. A http URL does not necessarily mean "web browser". Consider
for instance the URL:
<url:http://www.ietf.org/rfc/rfc3986.txt>
*utl-tutscmhttpwget*
This is a plain text document. Wouldn't it much better to display it in Vim?
Utl.vim provides interfacing to the non interactive download tool wget . For
this purpose the handler utl_cfg_hdl_scm_http has to be set up as:
:let g:utl_cfg_hdl_scm_http=g:utl_cfg_hdl_scm_http__wget
Use this vimscript service URL to do the configuration (unless you prefer
to type it in yourself :-)
<url:vimscript:let g:utl_cfg_hdl_scm_http=g:utl_cfg_hdl_scm_http__wget>
Now try the above link with this configuration! The RFC3986 will be displayed
in Vim as a temporary file. So now you can browse the RFC3986 document
directly in Vim.
It gets even more interesting if you want to address a specific part in the
target document. Examples:
<url:http://www.ietf.org/rfc/rfc3986.txt#^1.1.2. Examples>
<url:http://www.ietf.org/rfc/rfc3986.txt#line=343>
<url:http://www.vim.org/scripts/download_script.php?src_id=3640#horizontal or vertical>
Now the ultimate combination of all techniques: retrieving a document from the
web (with wget), using an external media type handler configured in Utl.vim
for the ability to add a fragment:
<url:http://bullium.com/support/vim.pdf#page=3>
See |utl-tutpdffrag| how to make this work.
In practice the one URL you want to display with your browser, the other URL
using the wget handler. Again (like |utl-tutfolders|) no real dynamic
switching between the handlers is possible. The suggested workaround is again
to define mappings that switch between the handlers, see
<url:config:#r=map_http>.
3.13 The mail scheme *utl-tutscmmail*
There is a special, non standard scheme for referencing specific emails
from your local mail boxes via URL. For instance, executing the link
<url:mail:///Inbox?date=12.04.2008 15:04>
will open the so specified email in your mailer. This can be very
convenient if you are using Vim for project management, software
development, PDA etc. It helps you to have all relevant information at your
fingertips.
The only implementation of the mail scheme currently available is
MS Outlook (under Windows) [32]. If you use another mailer you might
consider to contribute an implementation [33]. If you don't use Outlook but
like to reference emails you can workaround: save the mail as file (.txt,
.rtf, .msg etc format) and create a link to this file.
If your mailer is MS Outlook read on.
Suppose you have an email in your Inbox, received the 2008-04-12 at 15:04
you can open the mail by executing the link (make sure that Outlook is
already running!):
<url:mail:///Inbox?date=12.04.2008 15:04>
Currently the date is locale dependent, the above sample is for a German
Outlook. The date format is directly that of Outlook in the 'Received'
column ('Erhalten in German), but without the week day prepended. The
above can be written shorter as:
<url:mail:///Inbox?12.04.2008 15:04>
since `date' is the default query [34]
Examples using different mail folders are:
<url:mail:///Sent Items?12.04.2008 15:04>
<url:mail://archive/Inbox?12.04.2008 15:04>
The form /// denotes the default folder (maybe this syntax is too Outlook
specific).
3.14 Other schemes *utl-tutscmoth*
*utl-tutscmothstd*
Besides file and http scheme Utl.vim currently Utl.vim supports the following
standard schemes:
ftp:
Delegates to http (web browser to handle this)
https:
Delegates to http (web browser to handle this)
mailto:
Delegates call to your mail client.
configurable by g:utl_cfg_hdl_scm_mailto
Mailto URL specified at <url:http://www.ietf.org/rfc/rfc2368>
Examples:
<url:mailto:[email protected]>
<url:mailto:[email protected]?subject=otto&[email protected]&body=test>
<url:mailto:[email protected]?body=subscribe%20bamboo-l>
scp:
Uses Vims netrw-Plugin, see |scp|
configurable by g:utl_cfg_hdl_scm_scp
Syntax:
<url:scp://hostname/path/to/file>
*utl-tutscmothnonstd*
Moreover, besides mail, vimscript and vimhelp scheme Utl.vim introduces and
supports the following non standard schemes:
man:
Accesss manual pages via URL.
Relies on the ManPageView plugin (:Man command) which needs to be
installed [35].
Example:
<url:man:ls>
config:
Utl specific. Ad hoc scheme for accessing Utls setup file.
Not really exciting.
Examples:
<url:config:> (try it!)
:Utl ol config:
foot:
Interface to make footnotes accessible via URL. Normally not called
directly but through heuristic form as has been explained at
<url:foot:10>. This will be elaborated in the next section.
The schemes http, mail, mailto, scp are configurable by
utl_cfg_hdl_scm_<scheme>. All other schemes not (yet). See <url:../plugin/utl.
vim#r=spec_ihsv> for specification of that configuration interface.
You can easily implement your own schemes or define new ones. You just
implement a Vim function somewhere. Utl.vim dynamically calls those functions.
Have a look at <url:../plugin/utl_scm.vim#r=implscmfunc> or just hack one of
the existing functions in ../plugin/utl_scm.vim. But I recommend that you
read chapter 5, Tips, details, pitfalls, before you write your own scheme
handler. A common misunderstanding is to create a new scheme where support
media type support to an existing one would be the better choice. See
|utl-privateScmHdl|for an elaborated example below.
3.15 Footnotes *utl-tutfoot*
Now let's go into some detail with footnotes (reference style links).
As you already know (from [10]), Utl.vim supports these commonly used
references in square brackets:
The software can be downloaded from [11]
.
.
[11] http://www.vim.org/download.php
Besides given texts from elsewhere, there are some Vim plugins that create
such footnotes [36]. But AFAIK there is no tool except Utl.vim that cares
about making them executable.
Often, like in the previous example, the [] syntax is used to indirectly
reference URLs because, citing from [36_2]: "Inline URIs [...] make the text
around them obscure". Utl.vim normally does not dereference the reference
target; in the example above it does not open the http:// Link
Often [] references are used for simple footnotes:
This is true [101]
.
.
[101] but not always
In this case () style references like (*), (1),(2) might be more common,
but this is not supported by Utl.vim.
-----
Syntax Details *utl-tutfragsyn*
References are not restricted to numbers, you can also use mnemonics
or abbreviations like [UTL_RC]. Allowed characters inside [...] are
_, A-Z, 0-9. Amongst others this style is useful for document reference.
According to common use of references the slight syntax variations for the
reference target are supported:
[102] This is used most often (and in all examples so far)
[102]: A bit exotic, but more parse-safe [37].
NOte that 102. (= number followed by just a point, no square brackets), is
not supported as reference target because in practice too often the wrong
target is found. The 102. form is useed by [36_2].
Obviously with the first form the reference source and target look the same.
And it can actually be possible to switch the roles. When searching for the
target, the source line is excluded. Often the reference target will be
located at the bottom of the text, but needs not. The reference target must
appear at the beginning of the line (after optional whitespace) [38]. ---
Don't forget to run Utl.vim in verbose mode (see |utl-tutverbosemode|) if I
confused you :-) Verbose mode also shows you the search algorithm.
-----
Footnote Fragments *utl-tutfootfrag*
You can append a fragment to [] references. Example:
[UTL_RC]#tn=1.3.
This will open the target of the reference, i.e. file .plugin/utl_rc.vim and
position the cursor according the fragment in this file. So adding a reference
allows you to automatically forward a [] reference. Obviously this only makes
sense if the reference target is a reference itself and not just a footnote
text. Forwarding also happens with empty fragments. Try for example to execute
this reference:
[36_1]#
Reference fragments can be especially useful if you have more than one
references into another document, e.g.
[UTL_RC]#r=utl_cfg_hdl_scm_http
[UTL_RC]#r=utl_cfg_hdl_scm_scp
[UTL_RC]#r=utl_cfg_hdl_scm_mailto
There is no Utl.vim option or so to let you choose whether to
automatically forward or not.
Well, #-fragments appended to [] style footnotes is a new syntax introduced by
Utl, in the hope that it will be useful.
-----
Reference Links are implemented as URLs *utl-tutfooturl*
Inside utl.vim there is not much special treatment of [] references, they are
handled as URLs, a new non standard scheme "foot:" has been introduced. So
most of the specific code is hence in the corresponding handler outside the
kernel of utl.vim. The following Urls are equivalent: <url:foot:36> =
<url:[36]> = [36]. Again, to see what's going on internally you can the
verbose option: <url:vimscript:let g:utl_opt_verbose=1>
3.16 Fragments to external Media Type Handlers *utl-tutextfrag*
As foretold at |utl-tutmtypes| defining a specific media type handler makes
sense if you want to address fragments in files not displayed within Vim.
Utl.vim offers limited support for PDF and MS Word documents.
-----
PDF page addressing *utl-tutpdffrag*
You can execute an URL like
<url:http://www.tech-invite.com/RFCs/PDF/RFC3986.pdf#page=4>
if you use Acrobat Reader to display PDF documents. Enable enable the specific
handler for media type application/pdf:
- Execute <url:config:#r=utl_cfg_hdl_mt_application_pdf__acrobat>,
- uncommment the two lines below the cursor and activate
the change by :w , :so %
- Then look for a test PDF on you computer with a least 4 pages,
e.g. /path/to/my.pdf
- Open this file with:
:Utl ol /path/to/my.pdf#page=4
- follow the directives (to configure Acrobat Reader).
This can be very useful for, say, to reference technical specifications (= PDF
document) from within source code.
NOte that addressing PDF pages this is not restricted to local files. To make
the above http link work (after set up of the specific handler) you just need
to bypass your web browser (AFAIK these do not support addressing pages) and
use the wget handler as described in section |utl-tutscmhttp|.
Currently only #page= fragments are supported.
-----
MS Word text search *utl-tutwordfrag*
Analog to PDF, to execute an URL like
<url:my.doc#tn=textToSearch>
<url:my.doc#textToSearch> (short form)
you just need to enable the specific handler for media type
application/msword:
- Execute <url:config:#r=utl_cfg_hdl_mt_application_msword__word> and
- uncommment the two lines below the cursor and activate
the change by :w , :so %
- Then try a .doc URL (with tn= fragment) and
- follow the directives (to setup the .vbs interface and configure MS Word).
Currently only text search (#tn= fragment) is supported.
#page= and #r= for jumping to numbered elements, section, text marks etc
would be desirable.
Addressing fragments can be quite useful for:
- technical documentation if you use Vim for collecting and managing changes
of your document or to use Vim as annotation system for MS Word.
- Referencing documents from within source code