This file is indexed.

/usr/share/doc/vim/html/repeat.html is in vim-doc 2:8.0.1453-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-type" content="text/html; charset=ISO-8859-1">
<TITLE>Vim documentation: repeat</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>Vim documentation: repeat</H1>
<A NAME="top"></A>
<A HREF="index.html">main help file</A>

<HR>
<PRE>

*<A NAME="repeat.txt"></A><B>repeat.txt</B>*    For Vim version 8.0.  Last change: 2017 Dec 17


		  VIM REFERENCE MANUAL    by <A HREF="intro.html#Bram">Bram</A> <A HREF="intro.html#Moolenaar">Moolenaar</A>



Repeating commands, Vim scripts and debugging			*<A NAME="repeating"></A><B>repeating</B>*

Chapter 26 of the user manual introduces <A HREF="#repeating">repeating</A> |<A HREF="usr_26.html">usr_26.txt</A>|.

1. Single repeats		|<A HREF="#single-repeat">single-repeat</A>|
2. Multiple repeats		|<A HREF="#multi-repeat">multi-repeat</A>|
3. Complex repeats		|<A HREF="#complex-repeat">complex-repeat</A>|
4. Using Vim scripts		|<A HREF="#using-scripts">using-scripts</A>|
5. Using Vim packages		|<A HREF="#packages">packages</A>|
6. Creating Vim <A HREF="#packages">packages</A>	|<A HREF="#package-create">package-create</A>|
7. Debugging scripts		|<A HREF="#debug-scripts">debug-scripts</A>|
8. Profiling			|<A HREF="#profiling">profiling</A>|

==============================================================================

1. Single repeats					*<A NAME="single-repeat"></A><B>single-repeat</B>*


							*<A NAME="."></A><B>.</B>*
.			Repeat last change, with <A HREF="intro.html#count">count</A> replaced with <A HREF="intro.html#[count]">[count]</A>.
			Also repeat a <A HREF="change.html#yank">yank</A> command, when the '<A HREF="change.html#y">y</A>' flag is
			included in <A HREF="options.html#'cpoptions'">'cpoptions'</A>.  Does not repeat a
			command-line command.

Simple changes can be repeated with the &quot;<A HREF="#.">.</A>&quot; command.  Without a <A HREF="intro.html#count">count</A>, the
<A HREF="intro.html#count">count</A> of the last change is used.  If you enter a <A HREF="intro.html#count">count</A>, <A HREF="motion.html#it">it</A> will replace the
last one.  |<A HREF="eval.html#v:count">v:count</A>| and |<A HREF="eval.html#v:count1">v:count1</A>| will be set.

If the last change included a specification of a numbered <A HREF="sponsor.html#register">register</A>, the
register number will be incremented.  See |<A HREF="undo.html#redo-register">redo-register</A>| for an example how
to use this.

Note that when <A HREF="#repeating">repeating</A> a command that used a <A HREF="visual.html#Visual">Visual</A> selection, the same SIZE
of area is used, see |<A HREF="visual.html#visual-repeat">visual-repeat</A>|.


							*<A NAME="@:"></A><B>@:</B>*
<A HREF="#@:">@:</A>			Repeat last command-line <A HREF="intro.html#[count]">[count]</A> times.
			{not available when compiled without the
			|<A HREF="various.html#+cmdline_hist">+cmdline_hist</A>| feature}


==============================================================================

2. Multiple repeats					*<A NAME="multi-repeat"></A><B>multi-repeat</B>*


						*<A NAME=":g"></A><B>:g</B>* *<A NAME=":global"></A><B>:global</B>* *<A NAME="E148"></A><B>E148</B>*
:[range]g[lobal]/{pattern}/[cmd]
			Execute the <A HREF="intro.html#Ex">Ex</A> command [cmd] (default &quot;<A HREF="various.html#:p">:p</A>&quot;) on the
			lines within <A HREF="cmdline.html#[range]">[range]</A> where {pattern} matches.

:[range]g[lobal]!/{pattern}/[cmd]
			Execute the <A HREF="intro.html#Ex">Ex</A> command [cmd] (default &quot;<A HREF="various.html#:p">:p</A>&quot;) on the
			lines within <A HREF="cmdline.html#[range]">[range]</A> where {pattern} does NOT match.


							*<A NAME=":v"></A><B>:v</B>* *<A NAME=":vglobal"></A><B>:vglobal</B>*
:[range]v[global]/{pattern}/[cmd]
			Same <A HREF="motion.html#as">as</A> :g!.

Instead of the '<A HREF="pattern.html#/">/</A>' which surrounds the {pattern}, you can use any other
single byte character, but not an alphabetic character, '\', &#39;&#34;'' or '&#124;'.
This is useful if you want to include a '<A HREF="pattern.html#/">/</A>' in the search <A HREF="pattern.html#pattern">pattern</A> or
replacement <A HREF="eval.html#string">string</A>.

For the definition of a pattern, see |<A HREF="pattern.html#pattern">pattern</A>|.

NOTE [cmd] may contain a range; see |<A HREF="tips.html#collapse">collapse</A>| and |<A HREF="usr_25.html#edit-paragraph-join">edit-paragraph-join</A>| for
examples.

The global commands work by first scanning through the <A HREF="cmdline.html#[range]">[range]</A> lines and
marking each line where a match occurs (for a multi-line <A HREF="pattern.html#pattern">pattern</A>, only the
start of the match matters).
In a second scan the [cmd] is executed for each marked line, <A HREF="motion.html#as">as</A> if the cursor
was in that line.  For &quot;<A HREF="#:v">:v</A>&quot; and &quot;:g!&quot; the command is executed for each not
marked line.  If a line is deleted its <A HREF="motion.html#mark">mark</A> disappears.
The default for <A HREF="cmdline.html#[range]">[range]</A> is the whole buffer (1,$).  Use &quot;<A HREF="pattern.html#CTRL-C">CTRL-C</A>&quot; to interrupt
the command.  If an error message is given for a line, the command for that
line is aborted and the global command continues with the next marked or
unmarked line.

								*<A NAME="E147"></A><B>E147</B>* 
When the command is used recursively, <A HREF="motion.html#it">it</A> only works on one line.  Giving a
range is then not allowed. This is useful to find all lines that match a
<A HREF="pattern.html#pattern">pattern</A> and <A HREF="diff.html#do">do</A> not match another <A HREF="pattern.html#pattern">pattern</A>:
<B>	:g/found/v/notfound/{cmd}</B>
This first finds all lines containing &quot;found&quot;, but only executes {cmd} when
there is no match for &quot;notfound&quot;.

To execute a non-Ex command, you can use the `:normal` command:
<B>	:g/pat/normal {commands}</B>
Make sure that {commands} ends with a whole command, otherwise Vim will wait
for you to type the rest of the command for each match.  The screen will not
have been updated, so you don't know what you are doing.  See |<A HREF="various.html#:normal">:normal</A>|.

The undo/redo command will undo/redo the whole global command at once.
The previous context <A HREF="motion.html#mark">mark</A> will only be set once (with &quot;'&#39;&#34;' you go back to
where the cursor was before the global command).

The global command sets both the last used search <A HREF="pattern.html#pattern">pattern</A> and the last used
substitute <A HREF="pattern.html#pattern">pattern</A> (this is <A HREF="intro.html#vi">vi</A> compatible).  This makes <A HREF="motion.html#it">it</A> <A HREF="starting.html#easy">easy</A> to globally
replace a <A HREF="eval.html#string">string</A>:
	:g/pat/s//PAT/g
This replaces all occurrences of &quot;pat&quot; with &quot;PAT&quot;.  The same can be done with:
	:&#37;s/pat/PAT/g
Which is two characters shorter!

When using &quot;global&quot; in <A HREF="intro.html#Ex">Ex</A> mode, a special <A HREF="change.html#case">case</A> is using &quot;<A HREF="editing.html#:visual">:visual</A>&quot; <A HREF="motion.html#as">as</A> a
command.  This will move to a matching line, go to <A HREF="intro.html#Normal">Normal</A> mode to let you
execute commands there until you use |<A HREF="intro.html#Q">Q</A>| to return to <A HREF="intro.html#Ex">Ex</A> mode.  This will be
repeated for each matching line.  While doing this you cannot use &quot;<A HREF="#:global">:global</A>&quot;.
To abort this type <A HREF="pattern.html#CTRL-C">CTRL-C</A> <A HREF="if_cscop.html#twice">twice</A>.

==============================================================================

3. Complex repeats					*<A NAME="complex-repeat"></A><B>complex-repeat</B>*


							*<A NAME="q"></A><B>q</B>* *<A NAME="recording"></A><B>recording</B>*
q{0-9a-zA-Z&quot;}		Record typed characters into <A HREF="sponsor.html#register">register</A> {0-9a-zA-Z&quot;}
			(uppercase to append).  The '<A HREF="#q">q</A>' command is disabled
			while executing a <A HREF="sponsor.html#register">register</A>, and <A HREF="motion.html#it">it</A> doesn't work inside
			a <A HREF="map.html#mapping">mapping</A> and |<A HREF="various.html#:normal">:normal</A>|.

			Note: If the <A HREF="sponsor.html#register">register</A> being used for <A HREF="#recording">recording</A> is also
			used for |<A HREF="change.html#y">y</A>| and |<A HREF="change.html#p">p</A>| the result is most likely not
			what is expected, because the put will paste the
			recorded <A HREF="map.html#macro">macro</A> and the <A HREF="change.html#yank">yank</A> will overwrite the
			recorded <A HREF="map.html#macro">macro</A>. {Vi: no recording}

<A HREF="#q">q</A>			Stops <A HREF="#recording">recording</A>.  (Implementation note: The '<A HREF="#q">q</A>' that
			stops <A HREF="#recording">recording</A> is not stored in the <A HREF="sponsor.html#register">register</A>, unless
			<A HREF="motion.html#it">it</A> was the result of a <A HREF="map.html#mapping">mapping</A>)  {Vi: no recording}


							*<A NAME="@"></A><B>@</B>*
@{0-9a-z&quot;.=*+}		Execute the contents of <A HREF="sponsor.html#register">register</A> {0-9a-z&quot;.=*+} <A HREF="intro.html#[count]">[count]</A>
			times.  Note that <A HREF="sponsor.html#register">register</A> '<A HREF="motion.html#&#37;">&#37;</A>' (name of the current
			file) and '<A HREF="pattern.html##">#</A>' (name of the alternate file) cannot be
			used.
			The <A HREF="sponsor.html#register">register</A> is executed like a <A HREF="map.html#mapping">mapping</A>, that means
			that the difference between <A HREF="options.html#'wildchar'">'wildchar'</A> and <A HREF="options.html#'wildcharm'">'wildcharm'</A>
			applies.
			For &quot;<A HREF="change.html#@=">@=</A>&quot; you are prompted to enter an <A HREF="eval.html#expression">expression</A>.  The
			result of the <A HREF="eval.html#expression">expression</A> is then executed.
			See also |<A HREF="#@:">@:</A>|.  {Vi: only named registers}


							*<A NAME="@@"></A><B>@@</B>* *<A NAME="E748"></A><B>E748</B>*
<A HREF="#@@">@@</A>			Repeat the previous @{0-9a-z&quot;:*} <A HREF="intro.html#[count]">[count]</A> times.

:[addr]*{0-9a-z&quot;.=+}						*:@* *:star*
:[addr]@{0-9a-z&quot;.=*+}	Execute the contents of <A HREF="sponsor.html#register">register</A> {0-9a-z&quot;.=*+} <A HREF="motion.html#as">as</A> an <A HREF="intro.html#Ex">Ex</A>
			command.  First set cursor at line [addr] (default is
			current line).  When the last line in the <A HREF="sponsor.html#register">register</A> does
			not have a <A HREF="motion.html#&lt;CR&gt;">&lt;CR&gt;</A> <A HREF="motion.html#it">it</A> will be added automatically when
			the '<A HREF="motion.html#e">e</A>' flag is present in <A HREF="options.html#'cpoptions'">'cpoptions'</A>.
			Note that the &quot;:*&quot; command is only recognized when the
			'*' flag is present in <A HREF="options.html#'cpoptions'">'cpoptions'</A>.  This is NOT the
			default when <A HREF="options.html#'nocompatible'">'nocompatible'</A> is used.
			For &quot;:@=&quot; the last used <A HREF="eval.html#expression">expression</A> is used.  The
			result of evaluating the <A HREF="eval.html#expression">expression</A> is executed <A HREF="motion.html#as">as</A> an
			<A HREF="intro.html#Ex">Ex</A> command.
			Mappings are not recognized in these commands.
			{Vi: only in some versions} Future: Will execute the
			<A HREF="sponsor.html#register">register</A> for each line in the address range.


							*<A NAME=":@:"></A><B>:@:</B>*
:[addr]@:		Repeat last command-line.  First set cursor at line
			[addr] (default is current line).  {not in Vi}


:[addr]@							*<A NAME=":@@"></A><B>:@@</B>*
:[addr]@@		Repeat the previous :@{0-9a-z&quot;}.  First set cursor at
			line [addr] (default is current line).  {Vi: only in
			some versions}

==============================================================================

4. Using Vim scripts					*<A NAME="using-scripts"></A><B>using-scripts</B>*

For <A HREF="editing.html#writing">writing</A> a Vim <A HREF="usr_41.html#script">script</A>, see chapter 41 of the user manual |<A HREF="usr_41.html">usr_41.txt</A>|.


					*<A NAME=":so"></A><B>:so</B>* *<A NAME=":source"></A><B>:source</B>* *<A NAME="load-vim-script"></A><B>load-vim-script</B>*
:so[urce] <A HREF="editing.html#{file}">{file}</A>	Read <A HREF="intro.html#Ex">Ex</A> commands from <A HREF="editing.html#{file}">{file}</A>.  These are commands that
			start with a &quot;<A HREF="cmdline.html#:">:</A>&quot;.
			Triggers the |<A HREF="autocmd.html#SourcePre">SourcePre</A>| <A HREF="autocmd.html#autocommand">autocommand</A>.

:so[urce]! <A HREF="editing.html#{file}">{file}</A>	Read Vim commands from <A HREF="editing.html#{file}">{file}</A>.  These are commands
			that are executed from <A HREF="intro.html#Normal">Normal</A> mode, like you type
			them.
			When used after |<A HREF="#:global">:global</A>|, |<A HREF="editing.html#:argdo">:argdo</A>|, |<A HREF="windows.html#:windo">:windo</A>|,
			|<A HREF="windows.html#:bufdo">:bufdo</A>|, in a loop or when another command follows
			the display won't be updated while executing the
			commands.
			{not in Vi}


							*<A NAME=":ru"></A><B>:ru</B>* *<A NAME=":runtime"></A><B>:runtime</B>*
:ru[ntime][!] [where] <A HREF="editing.html#{file}">{file}</A> ..
			Read <A HREF="intro.html#Ex">Ex</A> commands from <A HREF="editing.html#{file}">{file}</A> in each directory given
			by <A HREF="options.html#'runtimepath'">'runtimepath'</A> and/or <A HREF="options.html#'packpath'">'packpath'</A>.  There is no error
			for non-existing files.
			
			Example:
<B>				:runtime syntax/c.vim</B>

 			There can be multiple <A HREF="editing.html#{file}">{file}</A> arguments, separated by
			spaces.  Each <A HREF="editing.html#{file}">{file}</A> is searched for in the first
			directory from <A HREF="options.html#'runtimepath'">'runtimepath'</A>, then in the second
			directory, etc.  Use a <A HREF="intro.html#backslash">backslash</A> to include a space
			inside <A HREF="editing.html#{file}">{file}</A> (although it's better not to use spaces
			in file names, <A HREF="motion.html#it">it</A> causes trouble).

			When [!] is included, all found files are sourced.
			When <A HREF="motion.html#it">it</A> is not included only the first found file is
			sourced.

			When [where] is omitted only <A HREF="options.html#'runtimepath'">'runtimepath'</A> is used.
			Other values:
				START	search under &quot;start&quot; in <A HREF="options.html#'packpath'">'packpath'</A>
				OPT 	search under &quot;opt&quot; in <A HREF="options.html#'packpath'">'packpath'</A>
				PACK	search under &quot;start&quot; and &quot;opt&quot; in
					<A HREF="options.html#'packpath'">'packpath'</A>
				ALL	first use <A HREF="options.html#'runtimepath'">'runtimepath'</A>, then search
					under &quot;start&quot; and &quot;opt&quot; in <A HREF="options.html#'packpath'">'packpath'</A>

			When <A HREF="editing.html#{file}">{file}</A> contains <A HREF="editing.html#wildcards">wildcards</A> <A HREF="motion.html#it">it</A> is expanded to all
			matching files.  Example:
<B>				:runtime! plugin/*.vim</B>
 			This is what Vim uses to load the <A HREF="usr_05.html#plugin">plugin</A> files when
			starting up.  This similar command:
<B>				:runtime plugin/*.vim</B>
 			would source the first file only.

			When <A HREF="options.html#'verbose'">'verbose'</A> is one or higher, there is a message
			when no file could be found.
			When <A HREF="options.html#'verbose'">'verbose'</A> is two or higher, there is a message
			about each searched file.
			{not in Vi}


							*<A NAME=":pa"></A><B>:pa</B>* *<A NAME=":packadd"></A><B>:packadd</B>* *<A NAME="E919"></A><B>E919</B>*
:pa[ckadd][!] {name}	Search for an optional <A HREF="usr_05.html#plugin">plugin</A> directory in <A HREF="options.html#'packpath'">'packpath'</A>
			and source any <A HREF="usr_05.html#plugin">plugin</A> files found.  The directory must
			match:
<B><FONT COLOR="PURPLE">				pack/*/opt/{name} </FONT></B>
			The directory is added to <A HREF="options.html#'runtimepath'">'runtimepath'</A> if <A HREF="motion.html#it">it</A> wasn't
			there yet.
			If the directory pack/*/opt/{name}/after exists <A HREF="motion.html#it">it</A> is
			added at the end of <A HREF="options.html#'runtimepath'">'runtimepath'</A>.

			If loading <A HREF="#packages">packages</A> from &quot;pack/*/start&quot; was skipped,
			then this directory is searched first:
<B><FONT COLOR="PURPLE">				pack/*/start/{name} </FONT></B>

			Note that {name} is the directory name, not the name
			of the .vim file.  All the files matching the <A HREF="pattern.html#pattern">pattern</A>
<B><FONT COLOR="PURPLE">				pack/*/opt/{name}/plugin/**/*.vim </FONT></B>
			will be sourced.  This allows for using subdirectories
			below &quot;<A HREF="usr_05.html#plugin">plugin</A>&quot;, just like with plugins in
			<A HREF="options.html#'runtimepath'">'runtimepath'</A>.

			If the <A HREF="filetype.html#filetype">filetype</A> detection was not enabled yet (this
			is usually done with a &quot;<A HREF="syntax.html#syntax">syntax</A> enable&quot; or &quot;<A HREF="filetype.html#filetype">filetype</A>
			on&quot; command in your <A HREF="starting.html#.vimrc">.vimrc</A> file), this will also look
			for &quot;{name}/ftdetect/*.vim&quot; files.

			When the optional ! is added no <A HREF="usr_05.html#plugin">plugin</A> files or
			<A HREF="filetype.html#ftdetect">ftdetect</A> scripts are loaded, only the matching
			directories are added to <A HREF="options.html#'runtimepath'">'runtimepath'</A>.  This is
			useful in your <A HREF="starting.html#.vimrc">.vimrc</A>.  The plugins will then be
			loaded during <A HREF="starting.html#initialization">initialization</A>, see |<A HREF="starting.html#load-plugins">load-plugins</A>|.

			Also see |<A HREF="#pack-add">pack-add</A>|.


						*<A NAME=":packl"></A><B>:packl</B>* *<A NAME=":packloadall"></A><B>:packloadall</B>*
:packl[oadall][!]	Load all <A HREF="#packages">packages</A> in the &quot;start&quot; directory under each
			entry in <A HREF="options.html#'packpath'">'packpath'</A>.
			
			First all the directories found are added to
			<A HREF="options.html#'runtimepath'">'runtimepath'</A>, then the plugins found in the
			directories are sourced.  This allows for a <A HREF="usr_05.html#plugin">plugin</A> to
			depend on something of another <A HREF="usr_05.html#plugin">plugin</A>, e.g. an
			&quot;<A HREF="eval.html#autoload">autoload</A>&quot; directory.  See |<A HREF="#packload-two-steps">packload-two-steps</A>| for
			how this can be useful.

			This is normally done automatically during <A HREF="starting.html#startup">startup</A>,
			after loading your <A HREF="starting.html#.vimrc">.vimrc</A> file.  With this command <A HREF="motion.html#it">it</A>
			can be done earlier.

			Packages will be loaded only once.  After this command
			<A HREF="motion.html#it">it</A> won't happen again.  When the optional ! is added
			this command will load <A HREF="#packages">packages</A> even when done before.

			An error only causes sourcing the <A HREF="usr_41.html#script">script</A> where <A HREF="motion.html#it">it</A>
			happens to be aborted, further plugins will be loaded.
			See |<A HREF="#packages">packages</A>|.


:scripte[ncoding] [encoding]		*<A NAME=":scripte"></A><B>:scripte</B>* *<A NAME=":scriptencoding"></A><B>:scriptencoding</B>* *<A NAME="E167"></A><B>E167</B>*
			Specify the character encoding used in the <A HREF="usr_41.html#script">script</A>.
			The following lines will be converted from [encoding]
			to the value of the <A HREF="options.html#'encoding'">'encoding'</A> option, if they are
			different.  Examples:
<B>				scriptencoding iso-8859-5</B>
<B>				scriptencoding cp932</B>
 
			When [encoding] is empty, no conversion is done.  This
			can be used to restrict conversion to a sequence of
			lines:
<B>				scriptencoding euc-jp</B>
<B>				... lines to be converted ...</B>
<B>				scriptencoding</B>
<B>				... not converted ...</B>

 			When conversion isn't supported by the system, there
			is no error message and no conversion is done.  When a
			line can't be converted there is no error and the
			original line is kept.

			Don't use &quot;ucs-2&quot; or &quot;ucs-4&quot;, scripts cannot be in
			these encodings (they would contain NUL bytes).
			When a sourced <A HREF="usr_41.html#script">script</A> starts with a BOM (Byte Order
			<A HREF="motion.html#Mark">Mark</A>) in <A HREF="mbyte.html#utf-8">utf-8</A> format Vim will recognize <A HREF="motion.html#it">it</A>, no need
			to use &quot;<A HREF="#:scriptencoding">:scriptencoding</A> utf-8&quot; then.

			If you set the <A HREF="options.html#'encoding'">'encoding'</A> option in your |<A HREF="starting.html#.vimrc">.vimrc</A>|,
			`:scriptencoding` must be placed after that. E.g.:
<B>				set encoding=utf-8</B>
<B>				scriptencoding utf-8</B>
 
			When compiled without the |<A HREF="various.html#+multi_byte">+multi_byte</A>| feature this
			command is ignored.
			{not in Vi}


						*<A NAME=":scr"></A><B>:scr</B>* *<A NAME=":scriptnames"></A><B>:scriptnames</B>*
:scr[iptnames]		<A HREF="eval.html#List">List</A> all sourced <A HREF="usr_41.html#script">script</A> names, in the order they were
			first sourced.  The number is used for the <A HREF="usr_41.html#script">script</A> ID
			|<A HREF="map.html#&lt;SID&gt;">&lt;SID&gt;</A>|.
			{not in Vi} {not available when compiled without the
			|<A HREF="various.html#+eval">+eval</A>| feature}


						*<A NAME=":fini"></A><B>:fini</B>* *<A NAME=":finish"></A><B>:finish</B>* *<A NAME="E168"></A><B>E168</B>*
:fini[sh]		Stop sourcing a <A HREF="usr_41.html#script">script</A>.  Can only be used in a Vim
			<A HREF="usr_41.html#script">script</A> file.  This is a quick way to skip the rest of
			the file.  If <A HREF="motion.html#it">it</A> is used after a |<A HREF="eval.html#:try">:try</A>| but before the
			matching |<A HREF="eval.html#:finally">:finally</A>| (if present), the commands
			following the &quot;<A HREF="eval.html#:finally">:finally</A>&quot; up to the matching |<A HREF="eval.html#:endtry">:endtry</A>|
			are executed first.  This process applies to all
			nested &quot;<A HREF="eval.html#:try">:try</A>&quot;s in the <A HREF="usr_41.html#script">script</A>.  The outermost &quot;<A HREF="eval.html#:endtry">:endtry</A>&quot;
			then stops sourcing the <A HREF="usr_41.html#script">script</A>.  {not in Vi}

All commands and command sequences can be repeated by putting them in a named
<A HREF="sponsor.html#register">register</A> and then executing <A HREF="motion.html#it">it</A>.  There are two ways to get the commands in the
<A HREF="sponsor.html#register">register</A>:
- Use the record command &quot;<A HREF="#q">q</A>&quot;.  You type the commands once, and while they are
  being executed they are stored in a <A HREF="sponsor.html#register">register</A>.  Easy, because you can see
  what you are doing.  If you make a mistake, &quot;p&quot;ut the <A HREF="sponsor.html#register">register</A> into the
  file, edit the command sequence, and then delete <A HREF="motion.html#it">it</A> into the <A HREF="sponsor.html#register">register</A>
  again.  You can continue <A HREF="#recording">recording</A> by appending to the <A HREF="sponsor.html#register">register</A> (use an
  <A HREF="change.html#uppercase">uppercase</A> <A HREF="print.html#letter">letter</A>).
- Delete or <A HREF="change.html#yank">yank</A> the command sequence into the <A HREF="sponsor.html#register">register</A>.

Often used command sequences can be put under a function key with the '<A HREF="map.html#:map">:map</A>'
command.

An alternative is to put the commands in a file, and execute them with the
':source!' command.  Useful for long command sequences.  Can be combined with
the '<A HREF="map.html#:map">:map</A>' command to put complicated commands under a function key.

The '<A HREF="#:source">:source</A>' command reads <A HREF="intro.html#Ex">Ex</A> commands from a file line by line.  You will
have to type any needed keyboard input.  The ':source!' command reads from a
<A HREF="usr_41.html#script">script</A> file character by character, interpreting each character <A HREF="motion.html#as">as</A> if you
typed <A HREF="motion.html#it">it</A>.

Example: When you give the &quot;:!ls&quot; command you get the |<A HREF="message.html#hit-enter">hit-enter</A>| prompt.  If
you '<A HREF="#:source">:source</A>' a file with the line &quot;!ls&quot; in <A HREF="motion.html#it">it</A>, you will have to type the
<A HREF="intro.html#&lt;Enter&gt;">&lt;Enter&gt;</A> yourself.  But if you ':source!' a file with the line &quot;:!ls&quot; in <A HREF="motion.html#it">it</A>,
the next characters from that file are read until a <A HREF="motion.html#&lt;CR&gt;">&lt;CR&gt;</A> is found.  You will
not have to type <A HREF="motion.html#&lt;CR&gt;">&lt;CR&gt;</A> yourself, unless &quot;:!ls&quot; was the last line in the file.

It is possible to put ':source[!]' commands in the <A HREF="usr_41.html#script">script</A> file, so you can
make a top-down hierarchy of <A HREF="usr_41.html#script">script</A> files.  The '<A HREF="#:source">:source</A>' command can be
nested <A HREF="motion.html#as">as</A> deep <A HREF="motion.html#as">as</A> the number of files that can be opened at one time (about
15).  The ':source!' command can be nested up to 15 levels deep.

You can use the &quot;<A HREF="cmdline.html#&lt;sfile&gt;">&lt;sfile&gt;</A>&quot; <A HREF="eval.html#string">string</A> (literally, this is not a special key) inside
of the sourced file, in places where a file name is expected.  It will be
replaced by the file name of the sourced file.  For example, if you have a
&quot;other.vimrc&quot; file in the same directory <A HREF="motion.html#as">as</A> your &quot;<A HREF="starting.html#.vimrc">.vimrc</A>&quot; file, you can source
<A HREF="motion.html#it">it</A> from your &quot;<A HREF="starting.html#.vimrc">.vimrc</A>&quot; file with this command:
<B>	:source &lt;sfile&gt;:h/other.vimrc</B>

In <A HREF="usr_41.html#script">script</A> files terminal-dependent key codes are represented by
terminal-independent two character codes.  This means that they can be used
in the same way on different kinds of terminals.  The first character of a
key code is 0x80 or 128, shown on the screen <A HREF="motion.html#as">as</A> &quot;~@&quot;.  The second one can be
found in the <A HREF="eval.html#list">list</A> |<A HREF="intro.html#key-notation">key-notation</A>|.  Any of these codes can also be entered
with <A HREF="visual.html#CTRL-V">CTRL-V</A> followed by the three digit decimal code.  This does NOT work for
the &lt;t_xx&gt; <A HREF="term.html#termcap">termcap</A> codes, these can only be used in mappings.


							*<A NAME=":source_crnl"></A><B>:source_crnl</B>* *<A NAME="W15"></A><B>W15</B>*
<A HREF="os_msdos.html#MS-DOS">MS-DOS</A>, <A HREF="os_win32.html#Win32">Win32</A> and <A HREF="os_os2.html#OS/2">OS/2</A>: Files that are read with &quot;<A HREF="#:source">:source</A>&quot; normally have
&lt;CR&gt;&lt;NL&gt; &lt;EOL&gt;s.  These always work.  If you are using a file with <A HREF="motion.html#&lt;NL&gt;">&lt;NL&gt;</A> &lt;EOL&gt;s
(for example, a file made on Unix), this will be recognized if <A HREF="options.html#'fileformats'">'fileformats'</A>
is not empty and the first line does not end in a <A HREF="motion.html#&lt;CR&gt;">&lt;CR&gt;</A>.  This fails if the
first line has something like &quot;<A HREF="map.html#:map">:map</A> <A HREF="helphelp.html#&lt;F1&gt;">&lt;F1&gt;</A> :help^M&quot;, where &quot;^M&quot; is a <A HREF="motion.html#&lt;CR&gt;">&lt;CR&gt;</A>.  If
the first line ends in a <A HREF="motion.html#&lt;CR&gt;">&lt;CR&gt;</A>, but following ones don't, you will get an error
message, because the <A HREF="motion.html#&lt;CR&gt;">&lt;CR&gt;</A> from the first lines will be lost.

<A HREF="os_mac.html#Mac">Mac</A> Classic: Files that are read with &quot;<A HREF="#:source">:source</A>&quot; normally have <A HREF="motion.html#&lt;CR&gt;">&lt;CR&gt;</A> &lt;EOL&gt;s.
These always work.  If you are using a file with <A HREF="motion.html#&lt;NL&gt;">&lt;NL&gt;</A> &lt;EOL&gt;s (for example, a
file made on Unix), this will be recognized if <A HREF="options.html#'fileformats'">'fileformats'</A> is not empty and
the first line does not end in a <A HREF="motion.html#&lt;CR&gt;">&lt;CR&gt;</A>.  Be careful not to use a file with <A HREF="motion.html#&lt;NL&gt;">&lt;NL&gt;</A>
linebreaks which has a <A HREF="motion.html#&lt;CR&gt;">&lt;CR&gt;</A> in first line.

On other systems, Vim expects &quot;:source&quot;ed files to end in a <A HREF="motion.html#&lt;NL&gt;">&lt;NL&gt;</A>.  These
always work.  If you are using a file with &lt;CR&gt;&lt;NL&gt; &lt;EOL&gt;s (for example, a
file made on MS-DOS), all lines will have a trailing <A HREF="motion.html#&lt;CR&gt;">&lt;CR&gt;</A>.  This may cause
problems for some commands (e.g., mappings).  There is no automatic <A HREF="intro.html#&lt;EOL&gt;">&lt;EOL&gt;</A>
detection, because it's common to start with a line that defines a <A HREF="map.html#mapping">mapping</A>
that ends in a <A HREF="motion.html#&lt;CR&gt;">&lt;CR&gt;</A>, which will confuse the automaton.


							*<A NAME="line-continuation"></A><B>line-continuation</B>*
Long lines in a &quot;<A HREF="#:source">:source</A>&quot;d <A HREF="intro.html#Ex">Ex</A> command <A HREF="usr_41.html#script">script</A> file can be split by <A HREF="insert.html#inserting">inserting</A>
a line continuation symbol &quot;\&quot; (backslash) at the start of the next line.
There can be white space before the <A HREF="intro.html#backslash">backslash</A>, which is ignored.

Example: the lines
<B>	:set comments=sr:/*,mb:*,el:*/,</B>
<B>		     \://,</B>
<B>		     \b:#,</B>
<B>		     \:%,</B>
<B>		     \n:&gt;,</B>
<B>		     \fb:-</B>
are interpreted <A HREF="motion.html#as">as</A> if they were given in one line:
	<A HREF="options.html#:set">:set</A> <A HREF="options.html#'comments'">comments</A>=sr:/*,mb:*,el:*/,://,b:#,:&#37;,n:&gt;,fb:-

All leading <A HREF="pattern.html#whitespace">whitespace</A> characters in the line before a <A HREF="intro.html#backslash">backslash</A> are ignored.
Note however that trailing <A HREF="pattern.html#whitespace">whitespace</A> in the line before <A HREF="motion.html#it">it</A> cannot be
inserted freely; <A HREF="motion.html#it">it</A> depends on the position where a command is split up
whether additional <A HREF="pattern.html#whitespace">whitespace</A> is allowed or not.

When a space is required it's best to put <A HREF="motion.html#it">it</A> right after the <A HREF="intro.html#backslash">backslash</A>.  A
space at the end of a line is hard to see and may be accidentally deleted.
<B>	:syn match Comment</B>
<B>		\ "very long regexp"</B>
<B>		\ keepend</B>

There is a problem with the &quot;<A HREF="insert.html#:append">:append</A>&quot; and &quot;<A HREF="insert.html#:insert">:insert</A>&quot; commands:
<B>   :1append</B>
<B>   \asdf</B>
<B>   .</B>
The <A HREF="intro.html#backslash">backslash</A> is seen <A HREF="motion.html#as">as</A> a <A HREF="#line-continuation">line-continuation</A> symbol, thus this results in the
command:
<B>   :1appendasdf</B>
<B>   .</B>
To avoid this, add the '<A HREF="change.html#C">C</A>' flag to the <A HREF="options.html#'cpoptions'">'cpoptions'</A> option:
<B>   :set cpo+=C</B>
<B>   :1append</B>
<B>   \asdf</B>
<B>   .</B>
<B>   :set cpo-=C</B>

Note that when the commands are inside a function, you need to add the '<A HREF="change.html#C">C</A>'
flag when defining the function, <A HREF="motion.html#it">it</A> is not relevant when executing <A HREF="motion.html#it">it</A>.
<B>   :set cpo+=C</B>
<B>   :function Foo()</B>
<B>   :1append</B>
<B>   \asdf</B>
<B>   .</B>
<B>   :endfunction</B>
<B>   :set cpo-=C</B>

Rationale:
	Most programs work with a trailing <A HREF="intro.html#backslash">backslash</A> to indicate line
	continuation.  Using this in Vim would cause incompatibility with <A HREF="intro.html#Vi">Vi</A>.
	For example for this <A HREF="intro.html#Vi">Vi</A> <A HREF="map.html#mapping">mapping</A>:
<B>		:map xx  asdf\</B>
 	Therefore the unusual leading <A HREF="intro.html#backslash">backslash</A> is used.

==============================================================================

5. Using Vim <A HREF="#packages">packages</A>					*<A NAME="packages"></A><B>packages</B>*

A Vim package is a directory that contains one or more plugins.  The
advantages over normal plugins:
- A package can be downloaded <A HREF="motion.html#as">as</A> an archive and unpacked in its own directory.
  Thus the files are not mixed with files of other plugins.  That makes <A HREF="motion.html#it">it</A>
  <A HREF="starting.html#easy">easy</A> to update and remove.
- A package can be a git, mercurial, etc. repository.  That makes <A HREF="motion.html#it">it</A> really
  <A HREF="starting.html#easy">easy</A> to update.
- A package can contain multiple plugins that depend on each other.
- A package can contain plugins that are automatically loaded on <A HREF="starting.html#startup">startup</A> and
  ones that are only loaded when needed with `:packadd`.


<B><FONT COLOR="PURPLE">Using a package and loading automatically </FONT></B>

Let's assume your Vim files are in the &quot;~/.vim&quot; directory and you want to add a
package from a <A HREF="pi_zip.html#zip">zip</A> archive &quot;/tmp/foopack.zip&quot;:
	<A HREF="motion.html#&#37;">&#37;</A> mkdir <A HREF="starting.html#-p">-p</A> ~/.vim/pack/foo
	<A HREF="motion.html#&#37;">&#37;</A> cd ~/.vim/pack/foo
	<A HREF="motion.html#&#37;">&#37;</A> unzip /tmp/foopack.zip

The directory name &quot;foo&quot; is arbitrary, you can pick anything you like.

You would now have these files under ~/.vim:
	pack/foo/README.txt
	pack/foo/start/foobar/plugin/foo.vim
	pack/foo/start/foobar/syntax/some.vim
	pack/foo/opt/foodebug/plugin/debugger.vim

When Vim starts up, after processing your <A HREF="starting.html#.vimrc">.vimrc</A>, <A HREF="motion.html#it">it</A> scans all directories in
<A HREF="options.html#'packpath'">'packpath'</A> for plugins under the &quot;pack/*/start&quot; directory.  First all those
directories are added to <A HREF="options.html#'runtimepath'">'runtimepath'</A>.  Then all the plugins are loaded.
See |<A HREF="#packload-two-steps">packload-two-steps</A>| for how these two steps can be useful.

In the example Vim will find &quot;pack/foo/start/foobar/plugin/foo.vim&quot; and adds 
&quot;~/.vim/pack/foo/start/foobar&quot; to <A HREF="options.html#'runtimepath'">'runtimepath'</A>.

If the &quot;foobar&quot; <A HREF="usr_05.html#plugin">plugin</A> kicks in and sets the <A HREF="options.html#'filetype'">'filetype'</A> to &quot;some&quot;, Vim will
find the syntax/some.vim file, because its directory is in <A HREF="options.html#'runtimepath'">'runtimepath'</A>.

Vim will also load <A HREF="filetype.html#ftdetect">ftdetect</A> files, if there are any.

Note that the files under &quot;pack/foo/opt&quot; are not loaded automatically, only the
ones under &quot;pack/foo/start&quot;.  See |<A HREF="#pack-add">pack-add</A>| below for how the &quot;opt&quot; directory
is used.

Loading <A HREF="#packages">packages</A> automatically will not happen if loading plugins is disabled,
see |<A HREF="starting.html#load-plugins">load-plugins</A>|.

To load <A HREF="#packages">packages</A> earlier, so that <A HREF="options.html#'runtimepath'">'runtimepath'</A> gets updated:
<B>	:packloadall</B>
This also works when loading plugins is disabled.  The automatic loading will
only happen once.

If the package has an &quot;after&quot; directory, that directory is added to the end of
<A HREF="options.html#'runtimepath'">'runtimepath'</A>, so that anything there will be loaded later.


<B><FONT COLOR="PURPLE">Using a single plugin and loading it automatically </FONT></B>

If you don't have a package but a single <A HREF="usr_05.html#plugin">plugin</A>, you need to create the extra
directory level:
	<A HREF="motion.html#&#37;">&#37;</A> mkdir <A HREF="starting.html#-p">-p</A> ~/.vim/pack/foo/start/foobar
	<A HREF="motion.html#&#37;">&#37;</A> cd ~/.vim/pack/foo/start/foobar
	<A HREF="motion.html#&#37;">&#37;</A> unzip /tmp/someplugin.zip

You would now have these files:
	pack/foo/start/foobar/plugin/foo.vim
	pack/foo/start/foobar/syntax/some.vim

From here <A HREF="motion.html#it">it</A> works like above.


<B><FONT COLOR="PURPLE">Optional plugins </FONT></B>

							*<A NAME="pack-add"></A><B>pack-add</B>*
To load an optional <A HREF="usr_05.html#plugin">plugin</A> from a pack use the `:packadd` command:
<B>	:packadd foodebug</B>
This searches for &quot;pack/*/opt/foodebug&quot; in <A HREF="options.html#'packpath'">'packpath'</A> and will find
~/.vim/pack/foo/opt/foodebug/plugin/debugger.vim and source <A HREF="motion.html#it">it</A>.

This could be done if some conditions are met.  For example, depending on
whether Vim supports a feature or a dependency is missing.

You can also load an optional <A HREF="usr_05.html#plugin">plugin</A> at <A HREF="starting.html#startup">startup</A>, by putting this command in
your YXXY.vimrc|:
<B>	:packadd! foodebug</B>
The extra &quot;<A HREF="change.html#!">!</A>&quot; is so that the <A HREF="usr_05.html#plugin">plugin</A> isn't loaded if Vim was started with
|<A HREF="starting.html#--noplugin">--noplugin</A>|.

It is perfectly normal for a package to only have files in the &quot;opt&quot;
directory.  You then need to load each <A HREF="usr_05.html#plugin">plugin</A> when you want to use <A HREF="motion.html#it">it</A>.


<B><FONT COLOR="PURPLE">Where to put what </FONT></B>

Since color schemes, loaded with `:colorscheme`, are found below
&quot;pack/*/start&quot; and &quot;pack/*/opt&quot;, you could put them anywhere.  We recommend
you put them below &quot;pack/*/opt&quot;, for example
&quot;.vim/pack/mycolors/opt/dark/colors/very_dark.vim&quot;.

Filetype plugins should go under &quot;pack/*/start&quot;, so that they are always
found.  Unless you have more than one <A HREF="usr_05.html#plugin">plugin</A> for a file type and want to
select which one to load with `:packadd`.  E.g. depending on the compiler
version:
<B>	if foo_compiler_version &gt; 34</B>
<B>	  packadd foo_new</B>
<B>	else</B>
<B>	  packadd foo_old</B>
<B>	endif</B>

The &quot;after&quot; directory is most likely not useful in a package.  It's not
disallowed though.

==============================================================================

6. Creating Vim <A HREF="#packages">packages</A>				*<A NAME="package-create"></A><B>package-create</B>*

This assumes you write one or more plugins that you distribute <A HREF="motion.html#as">as</A> a package.

If you have two unrelated plugins you would use two <A HREF="#packages">packages</A>, so that Vim
users can chose what they include or not.  Or you can decide to use one
package with optional plugins, and tell the user to add the ones he wants with
`:packadd`.

Decide how you want to distribute the package.  You can create an archive or
you could use a repository.  An archive can be used by more users, but is a
bit harder to update to a new version.  A repository can usually be kept
up-to-date easily, but <A HREF="motion.html#it">it</A> requires a program like &quot;git&quot; to be available.
You can <A HREF="diff.html#do">do</A> both, github can automatically create an archive for a release.

Your directory layout would be like this:
   start/foobar/plugin/foo.vim    	&quot; always loaded, defines commands
   start/foobar/plugin/bar.vim    	&quot; always loaded, defines commands
   start/foobar/autoload/foo.vim  	&quot; loaded when foo command used
   start/foobar/doc/foo.txt       	&quot; help for foo.vim
   start/foobar/doc/tags          	&quot; help <A HREF="tagsrch.html#tags">tags</A>
   opt/fooextra/plugin/extra.vim  	&quot; optional <A HREF="usr_05.html#plugin">plugin</A>, defines commands
   opt/fooextra/autoload/extra.vim  	&quot; loaded when extra command used
   opt/fooextra/doc/extra.txt  	        &quot; help for extra.vim
   opt/fooextra/doc/tags  	        &quot; help <A HREF="tagsrch.html#tags">tags</A>

This allows for the user to <A HREF="diff.html#do">do</A>:
<B>	mkdir ~/.vim/pack/myfoobar</B>
<B>	cd ~/.vim/pack/myfoobar</B>
<B>	git clone https://github.com/you/foobar.git</B>

Here &quot;myfoobar&quot; is a name that the user can choose, the only condition is that
<A HREF="motion.html#it">it</A> differs from other <A HREF="#packages">packages</A>.

In your documentation you explain what the plugins <A HREF="diff.html#do">do</A>, and tell the user how
to load the optional <A HREF="usr_05.html#plugin">plugin</A>:
<B>	:packadd! fooextra</B>

You could add this packadd command in one of your plugins, to be executed when
the optional <A HREF="usr_05.html#plugin">plugin</A> is needed.

Run the `:helptags` command to generate the doc/tags file.  Including this
generated file in the package means that the user can drop the package in his
pack directory and the help command works right away.  Don't forget to re-run
the command after <A HREF="change.html#changing">changing</A> the <A HREF="usr_05.html#plugin">plugin</A> help:
<B>	:helptags path/start/foobar/doc</B>
<B>	:helptags path/opt/fooextra/doc</B>


<B><FONT COLOR="PURPLE">Dependencies between plugins </FONT></B>

							*<A NAME="packload-two-steps"></A><B>packload-two-steps</B>*
Suppose you have two plugins that depend on the same functionality. You can
put the common functionality in an <A HREF="eval.html#autoload">autoload</A> directory, so that <A HREF="motion.html#it">it</A> will be
found automatically.  Your package would have these files:

	pack/foo/start/one/plugin/one.vim 
<B>		call foolib#getit()</B>
 	pack/foo/start/two/plugin/two.vim
<B>		call foolib#getit()</B>
 	pack/foo/start/lib/autoload/foolib.vim
<B>		func foolib#getit()</B>

This works, because loading <A HREF="#packages">packages</A> will first add all found directories to
<A HREF="options.html#'runtimepath'">'runtimepath'</A> before sourcing the plugins.

==============================================================================

7. Debugging scripts					*<A NAME="debug-scripts"></A><B>debug-scripts</B>*

Besides the obvious <A HREF="message.html#messages">messages</A> that you can add to your scripts to find out what
they are doing, Vim offers a debug mode.  This allows you to step through a
sourced file or user function and set breakpoints.

NOTE: The debugging mode is far from perfect.  Debugging will have side
effects on how Vim works.  You cannot use <A HREF="motion.html#it">it</A> to debug everything.  For
example, the display is messed up by the debugging <A HREF="message.html#messages">messages</A>.
{Vi does not have a debug mode}

An alternative to debug mode is setting the <A HREF="options.html#'verbose'">'verbose'</A> option.  With a bigger
number <A HREF="motion.html#it">it</A> will give more <A HREF="starting.html#verbose">verbose</A> <A HREF="message.html#messages">messages</A> about what Vim is doing.



STARTING DEBUG MODE						*<A NAME="debug-mode"></A><B>debug-mode</B>*

To enter debugging mode use one of these methods:
1. Start Vim with the |<A HREF="starting.html#-D">-D</A>| argument:
<B>	vim -D file.txt</B>
   Debugging will start <A HREF="motion.html#as">as</A> soon <A HREF="motion.html#as">as</A> the first <A HREF="starting.html#vimrc">vimrc</A> file is sourced.  This is
   useful to find out what is happening when Vim is starting up.  A side
   effect is that Vim will switch the <A HREF="terminal.html#terminal">terminal</A> mode before initialisations
   have finished, with unpredictable results.
   For a GUI-only version (Windows, <A HREF="os_mac.html#Macintosh">Macintosh</A>) the debugging will start <A HREF="motion.html#as">as</A>
   soon <A HREF="motion.html#as">as</A> the <A HREF="gui.html#GUI">GUI</A> <A HREF="windows.html#window">window</A> has been opened.  To make this happen early, add a
   &quot;<A HREF="gui_x11.html#:gui">:gui</A>&quot; command in the <A HREF="starting.html#vimrc">vimrc</A> file.

								*<A NAME=":debug"></A><B>:debug</B>*
2. Run a command with &quot;<A HREF="#:debug">:debug</A>&quot; prepended.  Debugging will only be done while
   this command executes.  Useful for debugging a specific <A HREF="usr_41.html#script">script</A> or user
   function.  And for scripts and <A HREF="eval.html#functions">functions</A> used by autocommands.  Example:
<B>	:debug edit test.txt.gz</B>

3. Set a breakpoint in a sourced file or user function.  You could <A HREF="diff.html#do">do</A> this in
   the command line:
<B>	vim -c "breakadd file */explorer.vim" .</B>
   This will run Vim and stop in the first line of the &quot;explorer.vim&quot; <A HREF="usr_41.html#script">script</A>.
   Breakpoints can also be set while in debugging mode.

In debugging mode every executed command is displayed before <A HREF="motion.html#it">it</A> is executed.
Comment lines, empty lines and lines that are not executed are skipped.  When
a line contains two commands, separated by &quot;|&quot;, each command will be displayed
separately.


DEBUG MODE

Once in debugging mode, the usual <A HREF="intro.html#Ex">Ex</A> commands can be used.  For example, to
inspect the value of a variable:
<B>	echo idx</B>
When inside a user function, this will print the value of the local variable
&quot;idx&quot;.  Prepend &quot;<A HREF="eval.html#g:">g:</A>&quot; to get the value of a global variable:
<B>	echo g:idx</B>
All commands are executed in the context of the current function or <A HREF="usr_41.html#script">script</A>.
You can also set <A HREF="options.html#options">options</A>, for example setting or resetting <A HREF="options.html#'verbose'">'verbose'</A> will show
what happens, but you might want to set <A HREF="motion.html#it">it</A> just before executing the lines you
are interested in:
<B>	:set verbose=20</B>

Commands that require updating the screen should be avoided, because their
effect won't be noticed until after leaving debug mode.  For example:
<B>	:help</B>
won't be very helpful.

There is a separate command-line <A HREF="cmdline.html#history">history</A> for debug mode.

The line number for a function line is relative to the start of the function.
If you have trouble figuring out where you are, edit the file that defines
the function in another Vim, search for the start of the function and <A HREF="diff.html#do">do</A>
&quot;99j&quot;.  <A HREF="insert.html#Replace">Replace</A> &quot;99&quot; with the line number.

Additionally, these commands can be used:

							*<A NAME="&gt;cont"></A><B>&gt;cont</B>*
	cont		Continue execution until the next breakpoint is hit.

							*<A NAME="&gt;quit"></A><B>&gt;quit</B>*
	quit		Abort execution.  This is like using <A HREF="pattern.html#CTRL-C">CTRL-C</A>, some
			things might still be executed, doesn't abort
			everything.  Still stops at the next breakpoint.

							*<A NAME="&gt;next"></A><B>&gt;next</B>*
	next		Execute the command and come back to debug mode when
			it's finished.  This steps over user function calls
			and sourced files.

							*<A NAME="&gt;step"></A><B>&gt;step</B>*
	step		Execute the command and come back to debug mode for
			the next command.  This steps into called user
			<A HREF="eval.html#functions">functions</A> and sourced files.

							*<A NAME="&gt;interrupt"></A><B>&gt;interrupt</B>*
	interrupt	This is like using <A HREF="pattern.html#CTRL-C">CTRL-C</A>, but unlike &quot;<A HREF="#&gt;quit">&gt;quit</A>&quot; comes
			back to debug mode for the next command that is
			executed.  Useful for <A HREF="eval.html#testing">testing</A> |<A HREF="eval.html#:finally">:finally</A>| and |<A HREF="eval.html#:catch">:catch</A>|
			on interrupt exceptions.

							*<A NAME="&gt;finish"></A><B>&gt;finish</B>*
	finish		Finish the current <A HREF="usr_41.html#script">script</A> or user function and come
			back to debug mode for the command after the one that
			sourced or called <A HREF="motion.html#it">it</A>.

							*<A NAME="&gt;bt"></A><B>&gt;bt</B>*

							*<A NAME="&gt;backtrace"></A><B>&gt;backtrace</B>*

							*<A NAME="&gt;where"></A><B>&gt;where</B>*
	backtrace	Show the call stacktrace for current debugging session.
	bt
	where

							*<A NAME="&gt;frame"></A><B>&gt;frame</B>*
	frame N		Goes to N backtrace level. + and - <A HREF="sign.html#signs">signs</A> make <A HREF="intro.html#movement">movement</A>
			relative.  E.g., &quot;:frame +3&quot; goes three frames up.

							*<A NAME="&gt;up"></A><B>&gt;up</B>*
	up		Goes one level up from call stacktrace.

							*<A NAME="&gt;down"></A><B>&gt;down</B>*
	down		Goes one level down from call stacktrace.

About the additional commands in debug mode:
- There is no command-line completion for them, you get the completion for the
  normal <A HREF="intro.html#Ex">Ex</A> commands only.
- You can shorten them, up to a single character, unless more than one command
  starts with the same <A HREF="print.html#letter">letter</A>.  &quot;<A HREF="motion.html#f">f</A>&quot; stands for &quot;finish&quot;, use &quot;fr&quot; for &quot;frame&quot;.
- Hitting <A HREF="motion.html#&lt;CR&gt;">&lt;CR&gt;</A> will repeat the previous one.  When doing another command, this
  is reset (because it's not clear what you want to repeat).
- When you want to use the <A HREF="intro.html#Ex">Ex</A> command with the same name, prepend a colon:
  &quot;:cont&quot;, &quot;<A HREF="editing.html#:next">:next</A>&quot;, &quot;<A HREF="#:finish">:finish</A>&quot; (or shorter).

The backtrace shows the hierarchy of function calls, e.g.:
<B><FONT COLOR="PURPLE">	&gt;bt </FONT></B>
<B><FONT COLOR="PURPLE">	  3 function One[3] </FONT></B>
<B><FONT COLOR="PURPLE">	  2 Two[3] </FONT></B>
<B><FONT COLOR="PURPLE">	-&gt;1 Three[3] </FONT></B>
<B><FONT COLOR="PURPLE">	  0 Four </FONT></B>
<B><FONT COLOR="PURPLE">	line 1: let four = 4 </FONT></B>

The &quot;-&gt;&quot; points to the current frame.  Use &quot;up&quot;, &quot;down&quot; and &quot;frame N&quot; to
select another frame.

In the current frame you can evaluate the local function <A HREF="eval.html#variables">variables</A>.  There is
no way to see the command at the current line yet.


DEFINING BREAKPOINTS

							*<A NAME=":breaka"></A><B>:breaka</B>* *<A NAME=":breakadd"></A><B>:breakadd</B>*
:breaka[dd] func [lnum] {name}
		Set a breakpoint in a function.  Example:
<B>			:breakadd func Explore</B>
 		Doesn't check for a valid function name, thus the breakpoint
		can be set before the function is defined.

:breaka[dd] file [lnum] {name}
		Set a breakpoint in a sourced file.  Example:
<B>			:breakadd file 43 .vimrc</B>

:breaka[dd] here
		Set a breakpoint in the current line of the current file.
		Like doing:
<B>			:breakadd file &lt;cursor-line&gt; &lt;current-file&gt;</B>
 		Note that this only works for commands that are executed when
		sourcing the file, not for a function defined in that file.

The [lnum] is the line number of the breakpoint.  Vim will stop at or after
this line.  When omitted line 1 is used.


							*<A NAME=":debug-name"></A><B>:debug-name</B>*
{name} is a <A HREF="pattern.html#pattern">pattern</A> that is matched with the file or function name.  The
<A HREF="pattern.html#pattern">pattern</A> is like what is used for autocommands.  There must be a full match (as
if the <A HREF="pattern.html#pattern">pattern</A> starts with &quot;<A HREF="motion.html#^">^</A>&quot; and ends in &quot;$&quot;).  A &quot;*&quot; matches any sequence
of characters.  <A HREF="options.html#'ignorecase'">'ignorecase'</A> is not used, but &quot;\c&quot; can be used in the <A HREF="pattern.html#pattern">pattern</A>
to ignore <A HREF="change.html#case">case</A> |<A HREF="pattern.html#/\c">/\c</A>|.  Don't include the () for the function name!

The match for sourced scripts is done against the full file name.  If no path
is specified the current directory is used.  Examples:
<B>	breakadd file explorer.vim</B>
matches &quot;explorer.vim&quot; in the current directory.
<B>	breakadd file *explorer.vim</B>
matches &quot;.../plugin/explorer.vim&quot;, &quot;.../plugin/iexplorer.vim&quot;, etc.
<B>	breakadd file */explorer.vim</B>
matches &quot;.../plugin/explorer.vim&quot; and &quot;explorer.vim&quot; in any other directory.

The match for <A HREF="eval.html#functions">functions</A> is done against the name <A HREF="motion.html#as">as</A> it's shown in the output
of &quot;<A HREF="eval.html#:function">:function</A>&quot;.  For local <A HREF="eval.html#functions">functions</A> this means that something like &quot;&lt;SNR&gt;99_&quot;
is prepended.

Note that <A HREF="eval.html#functions">functions</A> are first loaded and later executed.  When they are loaded
the &quot;file&quot; breakpoints are checked, when they are executed the &quot;func&quot;
breakpoints.


DELETING BREAKPOINTS

						*<A NAME=":breakd"></A><B>:breakd</B>* *<A NAME=":breakdel"></A><B>:breakdel</B>* *<A NAME="E161"></A><B>E161</B>*
:breakd[el] {nr}
		Delete breakpoint {nr}.  Use |<A HREF="#:breaklist">:breaklist</A>| to see the number of
		each breakpoint.

:breakd[el] *
		Delete all breakpoints.

:breakd[el] func [lnum] {name}
		Delete a breakpoint in a function.

:breakd[el] file [lnum] {name}
		Delete a breakpoint in a sourced file.

:breakd[el] here
		Delete a breakpoint at the current line of the current file.

When [lnum] is omitted, the first breakpoint in the function or file is
deleted.
The {name} must be exactly the same <A HREF="motion.html#as">as</A> what was typed for the &quot;<A HREF="#:breakadd">:breakadd</A>&quot;
command.  &quot;explorer&quot;, &quot;*explorer.vim&quot; and &quot;*explorer*&quot; are different.


LISTING BREAKPOINTS

							*<A NAME=":breakl"></A><B>:breakl</B>* *<A NAME=":breaklist"></A><B>:breaklist</B>*
:breakl[ist]
		<A HREF="eval.html#List">List</A> all breakpoints.


OBSCURE


						*<A NAME=":debugg"></A><B>:debugg</B>* *<A NAME=":debuggreedy"></A><B>:debuggreedy</B>*
:debugg[reedy]
		Read debug mode commands from the normal input stream, instead
		of getting them directly from the user.  Only useful for test
		scripts.  Example:
<B>		  echo 'q^Mq' | vim -e -s -c debuggreedy -c 'breakadd file script.vim' -S script.vim</B>

:0debugg[reedy]
		Undo &quot;<A HREF="#:debuggreedy">:debuggreedy</A>&quot;: get debug mode commands directly from the
		user, don't use typeahead for debug commands.

==============================================================================

8. Profiling						*<A NAME="profile"></A><B>profile</B>* *<A NAME="profiling"></A><B>profiling</B>*

Profiling means that Vim measures the time that is spent on executing
<A HREF="eval.html#functions">functions</A> and/or scripts.  The |<A HREF="various.html#+profile">+profile</A>| feature is required for this.
It is only included when Vim was compiled with &quot;huge&quot; features.
{Vi does not have profiling}

You can also use the |<A HREF="eval.html#reltime()">reltime()</A>| function to measure time.  This only requires
the |<A HREF="various.html#+reltime">+reltime</A>| feature, which is present more often.

For <A HREF="#profiling">profiling</A> <A HREF="syntax.html#syntax">syntax</A> highlighting see |<A HREF="syntax.html#:syntime">:syntime</A>|.

For example, to <A HREF="#profile">profile</A> the one_script.vim <A HREF="usr_41.html#script">script</A> file:
<B>	:profile start /tmp/one_script_profile</B>
<B>	:profile file one_script.vim</B>
<B>	:source one_script.vim</B>
<B>	:exit</B>



:prof[ile] start {fname}			*<A NAME=":prof"></A><B>:prof</B>* *<A NAME=":profile"></A><B>:profile</B>* *<A NAME="E750"></A><B>E750</B>*
		Start <A HREF="#profiling">profiling</A>, write the output in {fname} upon exit.
		&quot;~/&quot; and environment <A HREF="eval.html#variables">variables</A> in {fname} will be expanded.
		If {fname} already exists <A HREF="motion.html#it">it</A> will be silently overwritten.
		The variable |<A HREF="eval.html#v:profiling">v:profiling</A>| is set to one.

:prof[ile] pause
		Don't <A HREF="#profile">profile</A> until the following &quot;<A HREF="#:profile">:profile</A> continue&quot;.  Can be
		used when doing something that should not be counted (e.g., an
		external command).  Does not nest.

:prof[ile] continue
		Continue <A HREF="#profiling">profiling</A> after &quot;<A HREF="#:profile">:profile</A> pause&quot;.

:prof[ile] func {pattern}
		Profile function that matches the <A HREF="pattern.html#pattern">pattern</A> {pattern}.
		See |<A HREF="#:debug-name">:debug-name</A>| for how {pattern} is used.

:prof[ile][!] file {pattern}
		Profile <A HREF="usr_41.html#script">script</A> file that matches the <A HREF="pattern.html#pattern">pattern</A> {pattern}.
		See |<A HREF="#:debug-name">:debug-name</A>| for how {pattern} is used.
		This only profiles the <A HREF="usr_41.html#script">script</A> itself, not the <A HREF="eval.html#functions">functions</A>
		defined in <A HREF="motion.html#it">it</A>.
		When the [!] is added then all <A HREF="eval.html#functions">functions</A> defined in the <A HREF="usr_41.html#script">script</A>
		will also be profiled.
		Note that <A HREF="#profiling">profiling</A> only starts when the <A HREF="usr_41.html#script">script</A> is loaded
		after this command.  A <A HREF="#:profile">:profile</A> command in the <A HREF="usr_41.html#script">script</A> itself
		won't work.



:profd[el] <A HREF="eval.html#...">...</A>						*<A NAME=":profd"></A><B>:profd</B>* *<A NAME=":profdel"></A><B>:profdel</B>*
		Stop <A HREF="#profiling">profiling</A> for the arguments specified. See |<A HREF="#:breakdel">:breakdel</A>|
		for the arguments.


You must always start with a &quot;<A HREF="#:profile">:profile</A> start fname&quot; command.  The resulting
file is written when Vim exits.  Here is an example of the output, with line
numbers prepended for the explanation:

<B><FONT COLOR="PURPLE">  1 FUNCTION  Test2() </FONT></B>
<B><FONT COLOR="PURPLE">  2 Called 1 time </FONT></B>
<B><FONT COLOR="PURPLE">  3 Total time:   0.155251 </FONT></B>
<B><FONT COLOR="PURPLE">  4  Self time:   0.002006 </FONT></B>
<B><FONT COLOR="PURPLE">  5  </FONT></B>
<B><FONT COLOR="PURPLE">  6 count  total (s)   self (s) </FONT></B>
<B><FONT COLOR="PURPLE">  7	9	       0.000096   for i in range(8) </FONT></B>
<B><FONT COLOR="PURPLE">  8	8   0.153655   0.000410     call Test3() </FONT></B>
<B><FONT COLOR="PURPLE">  9	8	       0.000070   endfor </FONT></B>
<B><FONT COLOR="PURPLE"> 10				  " Ask a question </FONT></B>
<B><FONT COLOR="PURPLE"> 11	1	       0.001341   echo input("give me an answer: ") </FONT></B>

The header (lines 1-4) gives the time for the whole function.  The &quot;Total&quot;
time is the time passed while the function was executing.  The &quot;Self&quot; time is
the &quot;Total&quot; time reduced by time spent in:
- other user defined <A HREF="eval.html#functions">functions</A>
- sourced scripts
- executed autocommands
- external (shell) commands

Lines 7-11 show the time spent in each executed line.  Lines that are not
executed <A HREF="diff.html#do">do</A> not <A HREF="intro.html#count">count</A>.  Thus a comment line is never counted.

The Count column shows how many times a line was executed.  Note that the
&quot;for&quot; command in line 7 is executed one more time <A HREF="motion.html#as">as</A> the following lines.
That is because the line is also executed to detect the end of the loop.

The time Vim spends waiting for user input isn't counted at all.  Thus how
long you take to respond to the <A HREF="eval.html#input()">input()</A> prompt is irrelevant.

Profiling should give a good indication of where time is spent, but keep in
mind there are various things that may clobber the results:

- The accuracy of the time measured depends on the gettimeofday() system
  function.  It may only be <A HREF="motion.html#as">as</A> accurate <A HREF="motion.html#as">as</A> 1/100 second, even though the times
  are displayed in micro seconds.

- Real elapsed time is measured, if other processes are busy they may cause
  delays at unpredictable moments.  You may want to run the <A HREF="#profiling">profiling</A> several
  times and use the lowest results.

- If you have several commands in one line you only get one time.  Split the
  line to see the time for the individual commands.

- The time of the lines added up is mostly <A HREF="various.html#less">less</A> than the time of the whole
  function.  There is some overhead in between.

- Functions that are deleted before Vim exits will not produce <A HREF="#profiling">profiling</A>
  information.  You can check the |<A HREF="eval.html#v:profiling">v:profiling</A>| variable if needed:
<B>	:if !v:profiling</B>
<B>	:   delfunc MyFunc</B>
<B>	:endif</B>
 
- Profiling may give weird results on multi-processor systems, when sleep
  mode kicks in or the processor frequency is reduced to save power.

- The &quot;<A HREF="eval.html#self">self</A>&quot; time is wrong when a function is used recursively.


<A HREF="#top">top</A> - <A HREF="index.html">main help file</A>
</PRE>
</BODY>


</HTML>