-
-
Notifications
You must be signed in to change notification settings - Fork 444
Expand file tree
/
Copy pathNERD_commenter.vim
More file actions
2940 lines (2544 loc) · 108 KB
/
NERD_commenter.vim
File metadata and controls
2940 lines (2544 loc) · 108 KB
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
" ============================================================================
" File: NERD_commenter.vim
" Description: vim global plugin that provides easy code commenting
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
" Version: 2.3.0
" Last Change: Wed Dec 14 08:00 AM 2011 EST
" License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
" Want To Public License, Version 2, as published by Sam Hocevar.
" See http://sam.zoy.org/wtfpl/COPYING for more details.
"
" ============================================================================
" Section: script init stuff {{{1
if exists("loaded_nerd_comments")
finish
endif
if v:version < 700
echoerr "NERDCommenter: this plugin requires vim >= 7. DOWNLOAD IT! You'll thank me later!"
finish
endif
let loaded_nerd_comments = 1
" Function: s:InitVariable() function {{{2
" This function is used to initialise a given variable to a given value. The
" variable is only initialised if it does not exist prior
"
" Args:
" -var: the name of the var to be initialised
" -value: the value to initialise var to
"
" Returns:
" 1 if the var is set, 0 otherwise
function s:InitVariable(var, value)
if !exists(a:var)
execute 'let ' . a:var . ' = ' . "'" . a:value . "'"
return 1
endif
return 0
endfunction
" Section: space string init{{{2
" When putting spaces after the left delim and before the right we use
" s:spaceStr for the space char. This way we can make it add anything after
" the left and before the right by modifying this variable
let s:spaceStr = ' '
let s:lenSpaceStr = strlen(s:spaceStr)
" Section: variable initialization {{{2
call s:InitVariable("g:NERDAllowAnyVisualDelims", 1)
call s:InitVariable("g:NERDBlockComIgnoreEmpty", 0)
call s:InitVariable("g:NERDCommentWholeLinesInVMode", 0)
call s:InitVariable("g:NERDCommentEmptyLines", 0)
call s:InitVariable("g:NERDCompactSexyComs", 0)
call s:InitVariable("g:NERDCreateDefaultMappings", 1)
call s:InitVariable("g:NERDDefaultNesting", 1)
call s:InitVariable("g:NERDMenuMode", 3)
call s:InitVariable("g:NERDLPlace", "[>")
call s:InitVariable("g:NERDUsePlaceHolders", 1)
call s:InitVariable("g:NERDRemoveAltComs", 1)
call s:InitVariable("g:NERDRemoveExtraSpaces", 0)
call s:InitVariable("g:NERDRPlace", "<]")
call s:InitVariable("g:NERDSpaceDelims", 0)
call s:InitVariable("g:NERDDefaultAlign", "none")
let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\"
let s:delimiterMap = {
\ 'aap': { 'left': '#' },
\ 'abc': { 'left': '%' },
\ 'acedb': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'actionscript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'ada': { 'left': '--', 'leftAlt': '-- ' },
\ 'ahdl': { 'left': '--' },
\ 'ahk': { 'left': ';', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'amiga': { 'left': ';' },
\ 'aml': { 'left': '/*' },
\ 'ampl': { 'left': '#' },
\ 'apache': { 'left': '#' },
\ 'apachestyle': { 'left': '#' },
\ 'asciidoc': { 'left': '//' },
\ 'applescript': { 'left': '--', 'leftAlt': '(*', 'rightAlt': '*)' },
\ 'armasm': { 'left': ';' },
\ 'asm68k': { 'left': ';' },
\ 'asm': { 'left': ';', 'leftAlt': '#' },
\ 'asn': { 'left': '--' },
\ 'aspvbs': { 'left': '''', 'leftAlt': '<!--', 'rightAlt': '-->' },
\ 'asterisk': { 'left': ';' },
\ 'asy': { 'left': '//' },
\ 'atlas': { 'left': 'C', 'right': '$' },
\ 'autohotkey': { 'left': ';' },
\ 'autoit': { 'left': ';' },
\ 'ave': { 'left': "'" },
\ 'awk': { 'left': '#' },
\ 'basic': { 'left': "'", 'leftAlt': 'REM ' },
\ 'bbx': { 'left': '%' },
\ 'bc': { 'left': '#' },
\ 'bib': { 'left': '//' },
\ 'bindzone': { 'left': ';' },
\ 'blade': { 'left': '{{--', 'right': '--}}' },
\ 'bst': { 'left': '%' },
\ 'btm': { 'left': '::' },
\ 'cabal': { 'left': '--' },
\ 'caos': { 'left': '*' },
\ 'calibre': { 'left': '//' },
\ 'catalog': { 'left': '--', 'right': '--' },
\ 'c': { 'left': '/*','right': '*/', 'leftAlt': '//' },
\ 'cf': { 'left': '<!---', 'right': '--->' },
\ 'cfg': { 'left': '#' },
\ 'cg': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'ch': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'cl': { 'left': '#' },
\ 'clean': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'clipper': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'clojure': { 'left': ';' },
\ 'cmake': { 'left': '#' },
\ 'coffee': { 'left': '#' },
\ 'conkyrc': { 'left': '#' },
\ 'context': { 'left': '%', 'leftAlt': '--' },
\ 'cpp': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'cuda': { 'left': '/*','right': '*/', 'leftAlt': '//' },
\ 'crontab': { 'left': '#' },
\ 'cs': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'csp': { 'left': '--' },
\ 'cterm': { 'left': '*' },
\ 'cucumber': { 'left': '#' },
\ 'cvs': { 'left': 'CVS:' },
\ 'd': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'dcl': { 'left': '$!' },
\ 'dakota': { 'left': '#' },
\ 'debcontrol': { 'left': '#' },
\ 'debsources': { 'left': '#' },
\ 'def': { 'left': ';' },
\ 'desktop': { 'left': '#' },
\ 'dhcpd': { 'left': '#' },
\ 'diff': { 'left': '#' },
\ 'django': { 'left': '<!--','right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
\ 'docbk': { 'left': '<!--', 'right': '-->' },
\ 'dns': { 'left': ';' },
\ 'dockerfile': { 'left': '#' },
\ 'dosbatch': { 'left': 'REM ', 'leftAlt': '::' },
\ 'dosini': { 'left': ';' },
\ 'dot': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'dracula': { 'left': ';' },
\ 'dsl': { 'left': ';' },
\ 'dtml': { 'left': '<dtml-comment>', 'right': '</dtml-comment>' },
\ 'dylan': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'ebuild': { 'left': '#' },
\ 'ecd': { 'left': '#' },
\ 'eclass': { 'left': '#' },
\ 'eiffel': { 'left': '--' },
\ 'elf': { 'left': "'" },
\ 'elixir': { 'left': '#' },
\ 'elm': { 'left': '--' },
\ 'elmfilt': { 'left': '#' },
\ 'ember-script': { 'left': '#' },
\ 'emblem': { 'left': '/' },
\ 'erlang': { 'left': '%', 'leftAlt': '%%' },
\ 'eruby': { 'left': '<%#', 'right': '%>', 'leftAlt': '<!--', 'rightAlt': '-->' },
\ 'expect': { 'left': '#' },
\ 'exports': { 'left': '#' },
\ 'fancy': { 'left': '#' },
\ 'factor': { 'left': '! ', 'leftAlt': '!# ' },
\ 'fgl': { 'left': '#' },
\ 'focexec': { 'left': '-*' },
\ 'form': { 'left': '*' },
\ 'fortran': { 'left': '!' },
\ 'foxpro': { 'left': '*' },
\ 'fsharp': { 'left': '(*', 'right': '*)', 'leftAlt': '//' },
\ 'fstab': { 'left': '#' },
\ 'fvwm': { 'left': '#' },
\ 'fx': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'gams': { 'left': '*' },
\ 'gdb': { 'left': '#' },
\ 'gdmo': { 'left': '--' },
\ 'geek': { 'left': 'GEEK_COMMENT:' },
\ 'genshi': { 'left': '<!--','right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
\ 'gentoo-conf-d': { 'left': '#' },
\ 'gentoo-env-d': { 'left': '#' },
\ 'gentoo-init-d': { 'left': '#' },
\ 'gentoo-make-conf': { 'left': '#' },
\ 'gentoo-package-keywords': { 'left': '#' },
\ 'gentoo-package-mask': { 'left': '#' },
\ 'gentoo-package-use': { 'left': '#' },
\ 'gitcommit': { 'left': '#' },
\ 'gitconfig': { 'left': ';' },
\ 'gitrebase': { 'left': '#' },
\ 'gnuplot': { 'left': '#' },
\ 'go': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'groovy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'gsp': { 'left': '<%--', 'right': '--%>', 'leftAlt': '<!--','rightAlt': '-->'},
\ 'gtkrc': { 'left': '#' },
\ 'haskell': { 'left': '{-','right': '-}', 'leftAlt': '--' },
\ 'hb': { 'left': '#' },
\ 'h': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'haml': { 'left': '-#', 'leftAlt': '/' },
\ 'haxe': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'handlebars': { 'left': '{{!-- ', 'right': ' --}}' },
\ 'hbs': { 'left': '{{!-- ', 'right': ' --}}' },
\ 'hercules': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'hog': { 'left': '#' },
\ 'hostsaccess': { 'left': '#' },
\ 'htmlcheetah': { 'left': '##' },
\ 'htmldjango': { 'left': '<!--','right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
\ 'htmlos': { 'left': '#', 'right': '/#' },
\ 'hxml': { 'left': '#' },
\ 'ia64': { 'left': '#' },
\ 'icon': { 'left': '#' },
\ 'idlang': { 'left': ';' },
\ 'idl': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'idris': { 'leftAlt': '--', 'left': '{-', 'right': '-}' },
\ 'inform': { 'left': '!' },
\ 'inittab': { 'left': '#' },
\ 'ishd': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'iss': { 'left': ';' },
\ 'ist': { 'left': '%' },
\ 'jade': { 'left': '//-', 'leftAlt': '//' },
\ 'java': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'javacc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'javascript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'javascript.jquery': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'jess': { 'left': ';' },
\ 'jgraph': { 'left': '(*', 'right': '*)' },
\ 'jinja': { 'left': '<!--','right': '-->', 'leftAlt': '{#', 'rightAlt': '#}' },
\ 'jproperties': { 'left': '#' },
\ 'jsp': { 'left': '<%--', 'right': '--%>' },
\ 'julia': { 'left': '#' },
\ 'kix': { 'left': ';' },
\ 'kscript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'lace': { 'left': '--' },
\ 'ldif': { 'left': '#' },
\ 'less': { 'left': '/*','right': '*/' },
\ 'lhaskell': { 'left': '>{-','right': '-}', 'leftAlt': '>-- ' },
\ 'lilo': { 'left': '#' },
\ 'lilypond': { 'left': '%' },
\ 'liquid': { 'left': '{% comment %}', 'right': '{% endcomment %}' },
\ 'lisp': { 'left': ';', 'leftAlt': '#|', 'rightAlt': '|#' },
\ 'llvm': { 'left': ';' },
\ 'lotos': { 'left': '(*', 'right': '*)' },
\ 'lout': { 'left': '#' },
\ 'lprolog': { 'left': '%' },
\ 'lscript': { 'left': "'" },
\ 'lss': { 'left': '#' },
\ 'lua': { 'left': '--', 'leftAlt': '--[[', 'rightAlt': ']]' },
\ 'lynx': { 'left': '#' },
\ 'lytex': { 'left': '%' },
\ 'mail': { 'left': '> ' },
\ 'mako': { 'left': '##' },
\ 'man': { 'left': '."' },
\ 'map': { 'left': '%' },
\ 'maple': { 'left': '#' },
\ 'markdown': { 'left': '<!--', 'right': '-->' },
\ 'masm': { 'left': ';' },
\ 'mason': { 'left': '<% #', 'right': '%>' },
\ 'master': { 'left': '$' },
\ 'matlab': { 'left': '%' },
\ 'mel': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'mib': { 'left': '--' },
\ 'mips': { 'left': '#'},
\ 'mirah': {'left': '#'},
\ 'mkd': { 'left': '<!---', 'right': '-->' },
\ 'mma': { 'left': '(*', 'right': '*)' },
\ 'model': { 'left': '$', 'right': '$' },
\ 'moduala.': { 'left': '(*', 'right': '*)' },
\ 'modula2': { 'left': '(*', 'right': '*)' },
\ 'modula3': { 'left': '(*', 'right': '*)' },
\ 'monk': { 'left': ';' },
\ 'mush': { 'left': '#' },
\ 'mustache': { 'left': '{{!', 'right': '}}' },
\ 'nagios': { 'left': ';' },
\ 'named': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'nasm': { 'left': ';' },
\ 'nastran': { 'left': '$' },
\ 'natural': { 'left': '/*' },
\ 'ncf': { 'left': ';' },
\ 'newlisp': { 'left': ';' },
\ 'nginx': { 'left': '#' },
\ 'nimrod': { 'left': '#' },
\ 'nroff': { 'left': '\"' },
\ 'nsis': { 'left': '#' },
\ 'ntp': { 'left': '#' },
\ 'objc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'objcpp': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'objj': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'ocaml': { 'left': '(*', 'right': '*)' },
\ 'occam': { 'left': '--' },
\ 'octave': { 'left': '%', 'leftAlt': '#' },
\ 'omlet': { 'left': '(*', 'right': '*)' },
\ 'omnimark': { 'left': ';' },
\ 'ooc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'openroad': { 'left': '//' },
\ 'opl': { 'left': "REM" },
\ 'ora': { 'left': '#' },
\ 'ox': { 'left': '//' },
\ 'pandoc': { 'left': '<!--', 'right': '-->' },
\ 'pascal': { 'left': '{','right': '}', 'leftAlt': '(*', 'rightAlt': '*)' },
\ 'patran': { 'left': '$', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'pcap': { 'left': '#' },
\ 'pccts': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'pdf': { 'left': '%' },
\ 'perl': { 'left': '#' },
\ 'pfmain': { 'left': '//' },
\ 'php': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'pic': { 'left': ';' },
\ 'pike': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'pilrc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'pine': { 'left': '#' },
\ 'plm': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'plsql': { 'left': '-- ', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'po': { 'left': '#' },
\ 'postscr': { 'left': '%' },
\ 'pov': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'povini': { 'left': ';' },
\ 'ppd': { 'left': '%' },
\ 'ppwiz': { 'left': ';;' },
\ 'processing': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'prolog': { 'left': '%', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'ps1': { 'left': '#' },
\ 'psf': { 'left': '#' },
\ 'ptcap': { 'left': '#' },
\ 'puppet': { 'left': '#' },
\ 'python': { 'left': '#' },
\ 'racket': { 'left': ';' },
\ 'radiance': { 'left': '#' },
\ 'ratpoison': { 'left': '#' },
\ 'r': { 'left': '#' },
\ 'rc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'rebol': { 'left': ';' },
\ 'registry': { 'left': ';' },
\ 'remind': { 'left': '#' },
\ 'resolv': { 'left': '#' },
\ 'rgb': { 'left': '!' },
\ 'rib': { 'left': '#' },
\ 'rmd': { 'left': '#' },
\ 'robots': { 'left': '#' },
\ 'rspec': { 'left': '#' },
\ 'ruby': { 'left': '#' },
\ 'rust': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'sa': { 'left': '--' },
\ 'samba': { 'left': ';', 'leftAlt': '#' },
\ 'sass': { 'left': '//', 'leftAlt': '/*' },
\ 'sather': { 'left': '--' },
\ 'scala': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'scons': { 'left': '#' },
\ 'scheme': { 'left': ';', 'leftAlt': '#|', 'rightAlt': '|#' },
\ 'scilab': { 'left': '//' },
\ 'scsh': { 'left': ';' },
\ 'scss': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/'},
\ 'sed': { 'left': '#' },
\ 'sgmldecl': { 'left': '--', 'right': '--' },
\ 'sgmllnx': { 'left': '<!--', 'right': '-->' },
\ 'sh': { 'left': '#' },
\ 'sicad': { 'left': '*' },
\ 'sile': { 'left': '%' },
\ 'simula': { 'left': '%', 'leftAlt': '--' },
\ 'sinda': { 'left': '$' },
\ 'skill': { 'left': ';' },
\ 'slang': { 'left': '%' },
\ 'slice': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'slim': { 'left': '/', 'leftAlt': '/!' },
\ 'slrnrc': { 'left': '%' },
\ 'sls': { 'left': '#' },
\ 'sm': { 'left': '#' },
\ 'smarty': { 'left': '{*', 'right': '*}' },
\ 'smil': { 'left': '<!', 'right': '>' },
\ 'smith': { 'left': ';' },
\ 'sml': { 'left': '(*', 'right': '*)' },
\ 'snnsnet': { 'left': '#' },
\ 'snnspat': { 'left': '#' },
\ 'snnsres': { 'left': '#' },
\ 'snobol4': { 'left': '*' },
\ 'spec': { 'left': '#' },
\ 'specman': { 'left': '//' },
\ 'spectre': { 'left': '//', 'leftAlt': '*' },
\ 'spice': { 'left': '$' },
\ 'sql': { 'left': '-- ' },
\ 'sqlforms': { 'left': '-- ' },
\ 'sqlj': { 'left': '-- ' },
\ 'sqr': { 'left': '!' },
\ 'squid': { 'left': '#' },
\ 'sshdconfig': { 'left': '#' },
\ 'st': { 'left': '"' },
\ 'stan': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'stp': { 'left': '/*','right': '*/', 'leftAlt': '//' },
\ 'swift': { 'left': '/*','right': '*/', 'leftAlt': '//' },
\ 'supercollider': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'tads': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'tags': { 'left': ';' },
\ 'tak': { 'left': '$' },
\ 'tasm': { 'left': ';' },
\ 'tcl': { 'left': '#' },
\ 'terraform': { 'left': '#', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'texinfo': { 'left': "@c " },
\ 'texmf': { 'left': '%' },
\ 'tf': { 'left': ';' },
\ 'tidy': { 'left': '#' },
\ 'tli': { 'left': '#' },
\ 'tmux': { 'left': '#' },
\ 'toml': { 'left': '#' },
\ 'trasys': { 'left': "$" },
\ 'tsalt': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'tsscl': { 'left': '#' },
\ 'tssgm': { 'left': "comment = '", 'right': "'" },
\ 'txt2tags': { 'left': '%' },
\ 'typescript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'twig': { 'left': '{#', 'right': '#}' },
\ 'uc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'uil': { 'left': '!' },
\ 'vala': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'vb': { 'left': "'" },
\ 'velocity': { 'left': "##", 'right': "", 'leftAlt': '#*', 'rightAlt': '*#' },
\ 'vera': { 'left': '/*','right': '*/', 'leftAlt': '//' },
\ 'verilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'verilog_systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'vgrindefs': { 'left': '#' },
\ 'vhdl': { 'left': '--' },
\ 'vimperator': { 'left': '"' },
\ 'virata': { 'left': '%' },
\ 'vrml': { 'left': '#' },
\ 'vsejcl': { 'left': '/*' },
\ 'webmacro': { 'left': '##' },
\ 'wget': { 'left': '#' },
\ 'Wikipedia': { 'left': '<!--', 'right': '-->' },
\ 'winbatch': { 'left': ';' },
\ 'wml': { 'left': '#' },
\ 'wvdial': { 'left': ';' },
\ 'xdefaults': { 'left': '!' },
\ 'xkb': { 'left': '//' },
\ 'xmath': { 'left': '#' },
\ 'xpm2': { 'left': '!' },
\ 'xquery': { 'left': '(:', 'right': ':)' },
\ 'yaml': { 'left': '#' },
\ 'z8a': { 'left': ';' }
\ }
let g:NERDDelimiterMap = s:delimiterMap
if exists("g:NERDCustomDelimiters")
call extend(s:delimiterMap, g:NERDCustomDelimiters)
endif
" Section: Comment mapping functions, autocommands and commands {{{1
" ============================================================================
" Section: Comment enabler autocommands {{{2
" ============================================================================
augroup NERDCommenter
"if the user enters a buffer or reads a buffer then we gotta set up
"the comment delimiters for that new filetype
autocmd BufEnter,BufRead * :call s:SetUpForNewFiletype(&filetype, 0)
"if the filetype of a buffer changes, force the script to reset the
"delims for the buffer
autocmd Filetype * :call s:SetUpForNewFiletype(&filetype, 1)
augroup END
" Function: s:SetUpForNewFiletype(filetype) function {{{2
" This function is responsible for setting up buffer scoped variables for the
" given filetype.
"
" Args:
" -filetype: the filetype to set delimiters for
" -forceReset: 1 if the delimiters should be reset if they have already be
" set for this buffer.
"
function s:SetUpForNewFiletype(filetype, forceReset)
let ft = a:filetype
"for compound filetypes, if we dont know how to handle the full filetype
"then break it down and use the first part that we know how to handle
if ft =~ '\.' && !has_key(s:delimiterMap, ft)
let filetypes = split(a:filetype, '\.')
for i in filetypes
if has_key(s:delimiterMap, i)
let ft = i
break
endif
endfor
endif
let b:NERDSexyComMarker = ''
if has_key(s:delimiterMap, ft)
let b:NERDCommenterDelims = s:delimiterMap[ft]
for i in ['left', 'leftAlt', 'right', 'rightAlt']
if !has_key(b:NERDCommenterDelims, i)
let b:NERDCommenterDelims[i] = ''
endif
endfor
else
let b:NERDCommenterDelims = s:CreateDelimMapFromCms()
endif
endfunction
function s:CreateDelimMapFromCms()
if &ft == '' && exists('g:NERDDefaultDelims')
let delims = g:NERDDefaultDelims
for i in ['left', 'leftAlt', 'right', 'rightAlt']
if !has_key(delims, i)
let delims[i] = ''
endif
endfor
return delims
endif
return {
\ 'left': substitute(&commentstring, '\([^ \t]*\)\s*%s.*', '\1', ''),
\ 'right': substitute(&commentstring, '.*%s\s*\(.*\)', '\1', 'g'),
\ 'leftAlt': '',
\ 'rightAlt': '' }
endfunction
" Function: s:SwitchToAlternativeDelimiters(printMsgs) function {{{2
" This function is used to swap the delimiters that are being used to the
" alternative delimiters for that filetype. For example, if a c++ file is
" being edited and // comments are being used, after this function is called
" /**/ comments will be used.
"
" Args:
" -printMsgs: if this is 1 then a message is echoed to the user telling them
" if this function changed the delimiters or not
function s:SwitchToAlternativeDelimiters(printMsgs)
"if both of the alternative delimiters are empty then there is no
"alternative comment style so bail out
if b:NERDCommenterDelims['leftAlt'] == '' && b:NERDCommenterDelims['rightAlt'] == ''
if a:printMsgs
call s:NerdEcho("Cannot use alternative delimiters, none are specified", 0)
endif
return 0
endif
"save the current delimiters
let tempLeft = s:Left()
let tempRight = s:Right()
"swap current delimiters for alternative
let b:NERDCommenterDelims['left'] = b:NERDCommenterDelims['leftAlt']
let b:NERDCommenterDelims['right'] = b:NERDCommenterDelims['rightAlt']
"set the previously current delimiters to be the new alternative ones
let b:NERDCommenterDelims['leftAlt'] = tempLeft
let b:NERDCommenterDelims['rightAlt'] = tempRight
"tell the user what comment delimiters they are now using
if a:printMsgs
call s:NerdEcho("Now using " . s:Left() . " " . s:Right() . " to delimit comments", 1)
endif
return 1
endfunction
" Section: Comment delimiter add/removal functions {{{1
" ============================================================================
" Function: s:AppendCommentToLine(){{{2
" This function appends comment delimiters at the EOL and places the cursor in
" position to start typing the comment
function s:AppendCommentToLine()
let left = s:Left({'space': 1})
let right = s:Right({'space': 1})
" get the len of the right delim
let lenRight = strlen(right)
let isLineEmpty = strlen(getline(".")) == 0
let insOrApp = (isLineEmpty==1 ? 'i' : 'A')
"stick the delimiters down at the end of the line. We have to format the
"comment with spaces as appropriate
execute ":normal! " . insOrApp . (isLineEmpty ? '' : ' ') . left . right
" if there is a right delimiter then we gotta move the cursor left
" by the len of the right delimiter so we insert between the delimiters
if lenRight > 0
let leftMoveAmount = lenRight - 1
execute ":normal! " . leftMoveAmount . "h"
endif
startinsert
endfunction
" Function: s:CommentBlock(top, bottom, lSide, rSide, forceNested ) {{{2
" This function is used to comment out a region of code. This region is
" specified as a bounding box by arguments to the function.
"
" Args:
" -top: the line number for the top line of code in the region
" -bottom: the line number for the bottom line of code in the region
" -lSide: the column number for the left most column in the region
" -rSide: the column number for the right most column in the region
" -forceNested: a flag indicating whether comments should be nested
function s:CommentBlock(top, bottom, lSide, rSide, forceNested )
" we need to create local copies of these arguments so we can modify them
let top = a:top
let bottom = a:bottom
let lSide = a:lSide
let rSide = a:rSide
"if the top or bottom line starts with tabs we have to adjust the left and
"right boundaries so that they are set as though the tabs were spaces
let topline = getline(top)
let bottomline = getline(bottom)
if s:HasLeadingTabs(topline, bottomline)
"find out how many tabs are in the top line and adjust the left
"boundary accordingly
let numTabs = s:NumberOfLeadingTabs(topline)
if lSide < numTabs
let lSide = &ts * lSide
else
let lSide = (lSide - numTabs) + (&ts * numTabs)
endif
"find out how many tabs are in the bottom line and adjust the right
"boundary accordingly
let numTabs = s:NumberOfLeadingTabs(bottomline)
let rSide = (rSide - numTabs) + (&ts * numTabs)
endif
"we must check that bottom IS actually below top, if it is not then we
"swap top and bottom. Similarly for left and right.
if bottom < top
let temp = top
let top = bottom
let bottom = top
endif
if rSide < lSide
let temp = lSide
let lSide = rSide
let rSide = temp
endif
"if the current delimiters arent multipart then we will switch to the
"alternative delims (if THEY are) as the comment will be better and more
"accurate with multipart delims
let switchedDelims = 0
if !s:Multipart() && g:NERDAllowAnyVisualDelims && s:AltMultipart()
let switchedDelims = 1
call s:SwitchToAlternativeDelimiters(0)
endif
"start the commenting from the top and keep commenting till we reach the
"bottom
let currentLine=top
while currentLine <= bottom
"check if we are allowed to comment this line
if s:CanCommentLine(a:forceNested, currentLine)
"convert the leading tabs into spaces
let theLine = getline(currentLine)
let lineHasLeadTabs = s:HasLeadingTabs(theLine)
if lineHasLeadTabs
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
endif
"dont comment lines that begin after the right boundary of the
"block unless the user has specified to do so
if theLine !~ '^ \{' . rSide . '\}' || !g:NERDBlockComIgnoreEmpty
"attempt to place the cursor in on the left of the boundary box,
"then check if we were successful, if not then we cant comment this
"line
call setline(currentLine, theLine)
if s:CanPlaceCursor(currentLine, lSide)
let leftSpaced = s:Left({'space': 1})
let rightSpaced = s:Right({'space': 1})
"stick the left delimiter down
let theLine = strpart(theLine, 0, lSide-1) . leftSpaced . strpart(theLine, lSide-1)
if s:Multipart()
"stick the right delimiter down
let theLine = strpart(theLine, 0, rSide+strlen(leftSpaced)) . rightSpaced . strpart(theLine, rSide+strlen(leftSpaced))
let firstLeftDelim = s:FindDelimiterIndex(s:Left(), theLine)
let lastRightDelim = s:LastIndexOfDelim(s:Right(), theLine)
if firstLeftDelim != -1 && lastRightDelim != -1
let searchStr = strpart(theLine, 0, lastRightDelim)
let searchStr = strpart(searchStr, firstLeftDelim+strlen(s:Left()))
"replace the outter most delims in searchStr with
"place-holders
let theLineWithPlaceHolders = s:ReplaceDelims(s:Left(), s:Right(), g:NERDLPlace, g:NERDRPlace, searchStr)
"add the right delimiter onto the line
let theLine = strpart(theLine, 0, firstLeftDelim+strlen(s:Left())) . theLineWithPlaceHolders . strpart(theLine, lastRightDelim)
endif
endif
endif
endif
"restore tabs if needed
if lineHasLeadTabs
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif
call setline(currentLine, theLine)
endif
let currentLine = currentLine + 1
endwhile
"if we switched delims then we gotta go back to what they were before
if switchedDelims == 1
call s:SwitchToAlternativeDelimiters(0)
endif
endfunction
" Function: s:CommentLines(forceNested, alignLeft, alignRight, firstLine, lastLine) {{{2
" This function comments a range of lines.
"
" Args:
" -forceNested: a flag indicating whether the called is requesting the comment
" to be nested if need be
" -align: should be "left", "start", "both" or "none"
" -firstLine/lastLine: the top and bottom lines to comment
function s:CommentLines(forceNested, align, firstLine, lastLine)
" we need to get the left and right indexes of the leftmost char in the
" block of of lines and the right most char so that we can do alignment of
" the delimiters if the user has specified
let leftAlignIndx = a:align == "start" ? 0 : s:LeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine)
let rightAlignIndx = s:RightMostIndx(a:forceNested, 0, a:firstLine, a:lastLine)
" gotta add the length of the left delimiter onto the rightAlignIndx cos
" we'll be adding a left delim to the line
let rightAlignIndx = rightAlignIndx + strlen(s:Left({'space': 1}))
" now we actually comment the lines. Do it line by line
let currentLine = a:firstLine
while currentLine <= a:lastLine
" get the next line, check commentability and convert spaces to tabs
let theLine = getline(currentLine)
let lineHasLeadingTabs = s:HasLeadingTabs(theLine)
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
if s:CanCommentLine(a:forceNested, currentLine)
"if the user has specified forceNesting then we check to see if we
"need to switch delimiters for place-holders
if a:forceNested && g:NERDUsePlaceHolders
let theLine = s:SwapOutterMultiPartDelimsForPlaceHolders(theLine)
endif
" find out if the line is commented using normal delims and/or
" alternate ones
let isCommented = s:IsCommented(s:Left(), s:Right(), theLine) || s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine)
" check if we can comment this line
if !isCommented || g:NERDUsePlaceHolders || s:Multipart()
if a:align == "left" || a:align == "start" || a:align == "both"
let theLine = s:AddLeftDelimAligned(s:Left({'space': 1}), theLine, leftAlignIndx)
else
let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine)
endif
if a:align == "both"
let theLine = s:AddRightDelimAligned(s:Right({'space': 1}), theLine, rightAlignIndx)
else
let theLine = s:AddRightDelim(s:Right({'space': 1}), theLine)
endif
endif
endif
" restore leading tabs if appropriate
if lineHasLeadingTabs
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif
" we are done with this line
call setline(currentLine, theLine)
let currentLine = currentLine + 1
endwhile
endfunction
" Function: s:CommentLinesMinimal(firstLine, lastLine) {{{2
" This function comments a range of lines in a minimal style. I
"
" Args:
" -firstLine/lastLine: the top and bottom lines to comment
function s:CommentLinesMinimal(firstLine, lastLine)
"check that minimal comments can be done on this filetype
if !s:HasMultipartDelims()
throw 'NERDCommenter.Delimiters exception: Minimal comments can only be used for filetypes that have multipart delimiters'
endif
"if we need to use place holders for the comment, make sure they are
"enabled for this filetype
if !g:NERDUsePlaceHolders && s:DoesBlockHaveMultipartDelim(a:firstLine, a:lastLine)
throw 'NERDCommenter.Settings exception: Place holders are required but disabled.'
endif
"get the left and right delims to smack on
let left = s:GetSexyComLeft(g:NERDSpaceDelims,0)
let right = s:GetSexyComRight(g:NERDSpaceDelims,0)
"make sure all multipart delims on the lines are replaced with
"placeholders to prevent illegal syntax
let currentLine = a:firstLine
while(currentLine <= a:lastLine)
let theLine = getline(currentLine)
let theLine = s:ReplaceDelims(left, right, g:NERDLPlace, g:NERDRPlace, theLine)
call setline(currentLine, theLine)
let currentLine = currentLine + 1
endwhile
"add the delim to the top line
let theLine = getline(a:firstLine)
let lineHasLeadingTabs = s:HasLeadingTabs(theLine)
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
let theLine = s:AddLeftDelim(left, theLine)
if lineHasLeadingTabs
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif
call setline(a:firstLine, theLine)
"add the delim to the bottom line
let theLine = getline(a:lastLine)
let lineHasLeadingTabs = s:HasLeadingTabs(theLine)
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
let theLine = s:AddRightDelim(right, theLine)
if lineHasLeadingTabs
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif
call setline(a:lastLine, theLine)
endfunction
" Function: s:CommentLinesSexy(topline, bottomline) function {{{2
" This function is used to comment lines in the 'Sexy' style. eg in c:
" /*
" * This is a sexy comment
" */
" Args:
" -topline: the line num of the top line in the sexy comment
" -bottomline: the line num of the bottom line in the sexy comment
function s:CommentLinesSexy(topline, bottomline)
let left = s:GetSexyComLeft(0, 0)
let right = s:GetSexyComRight(0, 0)
"check if we can do a sexy comment with the available delimiters
if left == -1 || right == -1
throw 'NERDCommenter.Delimiters exception: cannot perform sexy comments with available delimiters.'
endif
"make sure the lines arent already commented sexually
if !s:CanSexyCommentLines(a:topline, a:bottomline)
throw 'NERDCommenter.Nesting exception: cannot nest sexy comments'
endif
let sexyComMarker = s:GetSexyComMarker(0,0)
let sexyComMarkerSpaced = s:GetSexyComMarker(1,0)
" we jam the comment as far to the right as possible
let leftAlignIndx = s:LeftMostIndx(1, 1, a:topline, a:bottomline)
"check if we should use the compact style i.e that the left/right
"delimiters should appear on the first and last lines of the code and not
"on separate lines above/below the first/last lines of code
if g:NERDCompactSexyComs
let spaceString = (g:NERDSpaceDelims ? s:spaceStr : '')
"comment the top line
let theLine = getline(a:topline)
let lineHasTabs = s:HasLeadingTabs(theLine)
if lineHasTabs
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
endif
let theLine = s:SwapOutterMultiPartDelimsForPlaceHolders(theLine)
let theLine = s:AddLeftDelimAligned(left . spaceString, theLine, leftAlignIndx)
if lineHasTabs
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif
call setline(a:topline, theLine)
"comment the bottom line
if a:bottomline != a:topline
let theLine = getline(a:bottomline)
let lineHasTabs = s:HasLeadingTabs(theLine)
if lineHasTabs
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
endif
let theLine = s:SwapOutterMultiPartDelimsForPlaceHolders(theLine)
endif
let theLine = s:AddRightDelim(spaceString . right, theLine)
if lineHasTabs
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif
call setline(a:bottomline, theLine)
else
" add the left delimiter one line above the lines that are to be commented
call cursor(a:topline, 1)
execute 'normal! O'
let theLine = repeat(' ', leftAlignIndx) . left
" Make sure tabs are respected
if !&expandtab
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif
call setline(a:topline, theLine)
" add the right delimiter after bottom line (we have to add 1 cos we moved
" the lines down when we added the left delim
call cursor(a:bottomline+1, 1)
execute 'normal! o'
let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . right
" Make sure tabs are respected
if !&expandtab
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif
call setline(a:bottomline+2, theLine)
endif
" go thru each line adding the sexyComMarker marker to the start of each
" line in the appropriate place to align them with the comment delims
let currentLine = a:topline+1
while currentLine <= a:bottomline + !g:NERDCompactSexyComs
" get the line and convert the tabs to spaces
let theLine = getline(currentLine)
let lineHasTabs = s:HasLeadingTabs(theLine)
if lineHasTabs
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
endif
let theLine = s:SwapOutterMultiPartDelimsForPlaceHolders(theLine)
" add the sexyComMarker
let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . sexyComMarkerSpaced . strpart(theLine, leftAlignIndx)
if lineHasTabs
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif
" set the line and move onto the next one
call setline(currentLine, theLine)
let currentLine = currentLine + 1
endwhile
endfunction
" Function: s:CommentLinesToggle(forceNested, firstLine, lastLine) {{{2
" Applies "toggle" commenting to the given range of lines
"
" Args:
" -forceNested: a flag indicating whether the called is requesting the comment
" to be nested if need be
" -firstLine/lastLine: the top and bottom lines to comment
function s:CommentLinesToggle(forceNested, firstLine, lastLine)
let currentLine = a:firstLine
let align = g:NERDDefaultAlign
let leftAlignIndx = align == "start" ? 0 : s:LeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine)
let rightAlignIndx = s:RightMostIndx(a:forceNested, 0, a:firstLine, a:lastLine)
let rightAlignIndx = rightAlignIndx + strlen(s:Left({'space': 1}))
while currentLine <= a:lastLine
" get the next line, check commentability and convert spaces to tabs
let theLine = getline(currentLine)
let lineHasLeadingTabs = s:HasLeadingTabs(theLine)
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
if s:CanToggleCommentLine(a:forceNested, currentLine)
"if the user has specified forceNesting then we check to see if we
"need to switch delimiters for place-holders
if g:NERDUsePlaceHolders
let theLine = s:SwapOutterMultiPartDelimsForPlaceHolders(theLine)
endif
if align == 'left' || align == 'start' || align == 'both'
let theLine = s:AddLeftDelimAligned(s:Left({'space': 1}), theLine, leftAlignIndx)
else
let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine)
endif
if align == "both"
let theLine = s:AddRightDelimAligned(s:Right({'space': 1}), theLine, rightAlignIndx)
else
let theLine = s:AddRightDelim(s:Right({'space': 1}), theLine)
endif
endif
" restore leading tabs if appropriate
if lineHasLeadingTabs
let theLine = s:ConvertLeadingSpacesToTabs(theLine)
endif
" we are done with this line
call setline(currentLine, theLine)
let currentLine = currentLine + 1
endwhile
endfunction