-
Notifications
You must be signed in to change notification settings - Fork 0
/
slides.vroom
1013 lines (636 loc) · 22.1 KB
/
slides.vroom
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
# This is a sample Vroom input file. It should help you get started.
#
# Edit this file with your content. Then run `vroom vroom` to start
# the show!
#
# See `perldoc Vroom` for complete details.
#
---- config
# Basic config options.
title: JavaScript on Vim
indent: 5
auto_size: 0
height: 25
width: 78
vim_opts: '-u NONE'
skip: 0
vimrc: |
set nowrap
map Q <Nop>
map <CR> :N<CR>:<CR>gg
set guicolors
colors jellybeans
autocmd BufEnter * redraw!
autocmd VimEnter,BufRead *.help set ft=help
autocmd VimEnter,BufRead \d\+\l\= syntax match slideLink "http[^ ]\+"
autocmd VimEnter,BufRead \d\+\l\= syntax match slideStar "^\s*\zs\*"
autocmd VimEnter,BufRead \d\+\l\= syntax match slideStar "^\s*\zs•"
autocmd VimEnter,BufRead \d\+\l\= syntax match slideStar "★"
autocmd VimEnter,BufRead \d\+\l\= syntax match slideVimTag "<.\{-}>"
autocmd VimEnter,BufRead \d\+\l\= syntax match slideVimCommand " :[a-zA-Z-]\+\>" skipwhite nextgroup=slideVimCommandArg
autocmd VimEnter,BufRead \d\+\l\= syntax match slideVimCommandArg "[.:0-9a-z_-]\+" contained
autocmd VimEnter,BufRead \d\+\l\= syntax match slideCommand "`.\{-}`"
autocmd VimEnter,BufRead \d\+\l\= syntax match slideStringQuote "'.\{-}'" contains=slideString
autocmd VimEnter,BufRead \d\+\l\= syntax match slideStringQuote '".\{-}"' contains=slideString
autocmd VimEnter,BufRead \d\+\l\= syntax match slideString '[^'"]*' contained
autocmd VimEnter,BufRead \d\+\l\= syntax match slideEnhanced "\*\w\+\*" transparent
autocmd VimEnter,BufRead \d\+\l\= syntax match slideShipName "\(*\s\|\.\s\+\|^\s*\|•\s\|^\s•\|:\)\@<!\zs\<\u\h\+"
autocmd VimEnter,BufRead \d\+\l\= syntax match slideShipName "\(\u\l\+\)\{2,}"
autocmd VimEnter,BufRead \d\+\l\= syntax match slideShipName "\<\u[A-Z0-9_]\+\>"
autocmd VimEnter,BufRead \d\+\l\= syntax match slideShipName "Tern\|Vimball\|Vim [0-9.]\+\|Vim\|\.vimrc\|Language"
autocmd VimEnter,BufRead \d\+\l\= syntax match slideShipName "Learn Vimscript the Hard Way"
autocmd VimEnter,BufRead \d\+\l\= syntax match slideVimPlugin "\<[a-zA-Z]\+\/[a-zA-Z-.]\+\>"
autocmd VimEnter,BufRead \d\+\l\= syntax match slideVimPlugin "\<[A-Za-z-0-9]\+\.vim\>"
autocmd VimEnter,BufRead \d\+\l\= syntax match slideVimPlugin "\<vim-[a-z-0-9]\+\>"
autocmd VimEnter,BufRead \d\+\l\= syntax match slideVimPlugin "Syntastic\|neocomplcache\|AutoComplPop\|SuperTab\|Vundle\|NeoBundle"
autocmd VimEnter,BufRead \d\+\l\= syntax match slideTitle "\%^\_[ ]* \{10,}\S.*" contains=slideTitleFix
autocmd VimEnter,BufRead \d\+\l\= syntax match slideTitleFix "_"
autocmd VimEnter,BufRead \d\+\l\= syntax keyword slideWord Gentlemen
autocmd VimEnter,BufRead \d\+\l\= syntax match slideVimComplete "[a-z0-9]\{3,}\zecomplete"
hi Normal ctermfg=231 guifg=#fffffc
hi slideTitle ctermfg=172 guifg=#FFA319
hi slideVimPlugin ctermfg=82 guifg=#6df567
hi slideLink cterm=underline ctermfg=33 guifg=#48f5f1
hi slideString cterm=underline
hi slideStar ctermfg=226 guifg=#f1ea5f
hi slideEnhanced cterm=bold ctermfg=231 guifg=#1f9ef4
hi slideShipName cterm=bold ctermfg=123 guifg=#1f9ef4
hi slideVimTag ctermfg=4 guifg=#1dbffd
hi slideVimCommand ctermfg=33 guifg=#1f9ef4
hi slideVimCommandArg ctermfg=39 guifg=#1dbffd
hi slideCommand ctermfg=4 guifg=#1f9ef4
hi slideTitleFix ctermfg=16 guifg=#1b1b1b
hi slideVimComplete ctermfg=33 guifg=#1dbffd
---- center
JavaScript on Vim
othree@COSCUP
---- center
This is a Vim Talk
----
== Slide Source
• https://github.com/othree/javascript-on-vim-slide/
----
== me
• othree
+• @ Github, Flickr, Twitter
+• F2E at HTC
+• Maintains some Vim plugin
----
== My Vim Repos
• https://github.com/search?q=%40othree&type=Repositories&l=VimL
+• html5.vim
+• javascript-libraries-syntax.vim
+• vim-javascript-syntax
+• jslint.vim
• coffee-check.vim
+• eregex.vim
• AutoComplPop
----
== html5.vim
• 300 ★
• Build this for personal need
• But no more need when I alomost complete it
+• Not dead
+ Looking for contributor add more new Web Standards
---- center
Let's Begin
----
== I Will Talk About
+• Plugins I am using as a F2E
+• Big problem about JavaScript syntax
+• The eco system of Vim user community
+• Get familiar with Vim Document
----
----
1st
---- center
Syntax
----
== Syntax File for JavaScript
• Have built in version
• Vim 7.3 introduce SyntaxComplete
+• Not work with JavaScript... Why?
---- center
Look Into SyntaxComplete
---- viml,i4
while ftindex > -1
let ft_part_name = matchstr( &filetype, '\w\+', ftindex )
" Syntax rules can contain items for more than just the current
" filetype. They can contain additional items added by the user
" via autocmds or their vimrc.
" Some syntax files can be combined (html, php, jsp).
" We want only items that begin with the filetype we are interested in.
let next_group_regex = '\n' .
\ '\zs'.ft_part_name.'\w\+\ze'.
\ '\s\+xxx\s\+'
let index = 0
let index = match(syntax_full, next_group_regex, index)
if index == -1 && exists('b:current_syntax') && ft_part_name != b:current_syntax
" There appears to be two standards when writing syntax files.
" Either items begin as:
" syn keyword {filetype}Keyword values ...
" let b:current_syntax = "sql"
" let b:current_syntax = "sqlanywhere"
" Or
" syn keyword {syntax_filename}Keyword values ...
" let b:current_syntax = "mysql"
" So, we will make the format of finding the syntax group names
" a bit more flexible and look for both if the first fails to
" find a match.
let next_group_regex = '\n' .
\ '\zs'.b:current_syntax.'\w\+\ze'.
\ '\s\+xxx\s\+'
let index = 0
let index = match(syntax_full, next_group_regex, index)
endif
---- center
How About JavaScript Syntax
---- viml,i4
if version >= 508 || !exists("did_javascript_syn_inits")
if version < 508
let did_javascript_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink javaScriptComment Comment
HiLink javaScriptLineComment Comment
HiLink javaScriptCommentTodo Todo
HiLink javaScriptSpecial Special
HiLink javaScriptStringS String
HiLink javaScriptStringD String
HiLink javaScriptCharacter Character
HiLink javaScriptSpecialCharacter javaScriptSpecial
HiLink javaScriptNumber javaScriptValue
HiLink javaScriptConditional Conditional
HiLink javaScriptRepeat Repeat
HiLink javaScriptBranch Conditional
HiLink javaScriptOperator Operator
HiLink javaScriptType Type
HiLink javaScriptStatement Statement
HiLink javaScriptFunction Function
HiLink javaScriptBraces Function
HiLink javaScriptError Error
HiLink javaScrParenError javaScriptError
HiLink javaScriptNull Keyword
HiLink javaScriptBoolean Boolean
HiLink javaScriptRegexpString String
---- center
'javaScript' vs 'javascript'
---- javascript
// Are they the same?
print('javascript' === 'javaScript');
---- i-4
== Which One is Correct?
• :help 44.12
---- help,i0
Choose a good, descriptive name for your syntax file. Use lowercase letters
and digits. Don't make it too long, it is used in many places: The name of
the syntax file "name.vim", 'filetype', b:current_syntax and the start of each
syntax group (nameType, nameStatement, nameString, etc).
---- center
( #`Д´)........
----
== _______上樑不正下梁歪
+• Almost all other JavaScript syntax use 'javaScript'
+• TypeScript syntax use 'typeScript'
----
== More Worse
+• I'm writing javascript-libraries-syntax.vim
+• Hard use automation to port my syntax to CoffeeScript and LiveScript
Language FileType Group Name Prefix
-------------------------------------------------------
CoffeeScript 'coffee' 'coffee'
LiveScript 'ls' 'ls'
JavaScript 'javascript' 'javaScript'
----
== To Solve This
+• Contact to author of SyntaxComplete
+• Contact to author of TypeScript syntax file
+• Ask on vimdev mailing-list
+• Walk around for my libraries syntax
---- center
The Walk Around Solution
---- sh,i4
> ls javascript-libraries-syntax.vim/autoload/syntax/*
+
angularjs.coffee.vim
angularjs.javascript.vim
angularjs.ls.vim
angularjs.typescript.vim
jquery.coffee.vim
jquery.javascript.vim
jquery.ls.vim
jquery.typescript.vim
postprocess.coffee.vim
postprocess.javascript.vim
postprocess.ls.vim
postprocess.typescript.vim
prelude.coffee.vim
prelude.javascript.vim
prelude.ls.vim
prelude.typescript.vim
update.sh
----
== Responses
+• SyntaxComplete author David Fishburn build a new version (13)
+• User can assign custom rule for syntax group name
Great for my libraries syntax project
+• TypeScript syntax author say he will take a look
+ Not fix until present day
+• Response from vimdev:
+ • Report to the author of the syntax file
+ • No response from the author
+• So I start host my vim-javascript-syntax
----
== othree/vim-javascript-syntax
• Fix group name issue
+• Add new HTML5 features
+• Better JSDoc support
+• Fix lots of bugs
---- center
CoffeeScript?
----
• kchmck/vim-coffee-script
+ :echo b:current_syntax
+ 'javascript'
---- viml,i4
" This is used instead of TOP to keep things coffee-specific for good
" embedding. `contained` groups aren't included.
syn cluster coffeeAll contains=coffeeStatement,coffeeRepeat,coffeeConditional,
\ coffeeException,coffeeKeyword,coffeeOperator,
\ coffeeExtendedOp,coffeeSpecialOp,coffeeBoolean,
\ coffeeGlobal,coffeeSpecialVar,coffeeSpecialIdent,
\ coffeeObject,coffeeConstant,coffeeString,
\ coffeeNumber,coffeeFloat,coffeeReservedError,
\ coffeeObjAssign,coffeeComment,coffeeBlockComment,
\ coffeeEmbed,coffeeRegex,coffeeHeregex,
\ coffeeHeredoc,coffeeSpaceError,
\ coffeeSemicolonError,coffeeDotAccess,
\ coffeeProtoAccess,coffeeCurlies,coffeeBrackets,
\ coffeeParens
if !exists('b:current_syntax')
let b:current_syntax = 'coffee'
endif
---- center
(ノ`Д´)ノ彡┻━┻
---- viml,i4
" Language: CoffeeScript
" Maintainer: Mick Koch <kchmck@gmail.com>
" URL: http://github.com/kchmck/vim-coffee-script
" License: WTFPL
" Bail if our syntax is already loaded.
if exists('b:current_syntax') && b:current_syntax == 'coffee'
finish
endif
" Include JavaScript for coffeeEmbed.
syn include @coffeeJS syntax/javascript.vim
----
• So....?
+• I'm writing javascript-libraries-syntax.vim
+• Supports JavaScript, CoffeeScript...etc
+• I should be able to know what is current syntax
----
• I fork one repo and fix this bug
+• Sent pull request
+• No response.....
+• https://github.com/othree/vim-coffee-script/
+• To serve muggles, use `&filetype` instead. ( ̄ー ̄)
----
----
2nd
---- center
Complete
----
== OmniComplete
• Vim 7
• <CTRL-X><CTRL-O>
• But also require a little configure
---- viml,i4
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
----
• Then press <CTRL-X><CTRL-O>
----
== Default, Built-in
• htmlcomplete
• javascriptcomplete
• phpcomplete
• pythoncomplete
• python3complete
• rubycomplete
• sqlcomplete
• syntaxcomplete
• xmlcomplete
----
== Default JS Complete Function
+• Out of date
+• I use jscomplete.vim
---- viml,i4
autocmd FileType javascript set omnifunc=jscomplete#CompleteJS
----
• Difficult to press <CTRL-X><CTRL-O>
+• Alternative, you can use:
+ • SuperTab
+ • AutoComplPop
+ • neocomplcache
----
== AutoComplPop
• Automatically trigger <CTRL-X><CTRL-O>
+• Author not maintains anymore
+• Don't have default setting for JavaScript
---- viml,i4
let behavs = { 'javascript': [], 'html': [] }
call add(behavs.javascript, {
\ 'command' : "\<C-x>\<C-u>",
\ 'completefunc' : 'acp#completeSnipmate',
\ 'meets' : 'acp#meetsForSnipmate',
\ 'onPopupClose' : 'acp#onPopupCloseSnipmate',
\ 'repeat' : 0,
\})
call add(behavs.javascript, {
\ 'command' : g:acp_behaviorKeywordCommand,
\ 'meets' : 'acp#meetsForKeyword',
\ 'repeat' : 0,
\ })
call add(behavs.javascript, {
\ 'command' : "\<C-x>\<C-o>",
\ 'meets' : 'AcpMeetsForJavaScript',
\ 'repeat' : 0,
\})
let g:acp_behavior = {}
call extend(g:acp_behavior, behavs, 'keep')
---- center
( #`Д´)........
---- center
Maintain my own AutoComplPop
----
== My AutoComplPop
+• Add more filetype support by default
+• Supports latest snipmate
----
== What Happened with Snipmate
+• Author don't maintains....
----
== But
+• A new fork on Github by Rok Garbas, Marc Weber, and Adnan Zafar
+• Breaks old way to work with AutoComplPop
+• So I fixed it
+• https://blog.othree.net/log/2013/06/25/autocomplpop-and-snipmate/
----
== garbas/vim-snipmate
• https://github.com/garbas/vim-snipmate
+• Only on Github, not on Vim Scripts
----
== The Old Vim Way for Plugins
+• Vim Scripts
+• Move file by hand
+• Vimball file
----
== Problems
+• Hard to remove plugin
+• File conflict
+• Mess in `.vim` folder
----
== The Vim EcoSystem Changes
+• pathogen.vim by Tim Pope
----
== The pathogen Way
+• Separate all plugins
+• No more mess in `.vim` folder
+• Uninstall plugins never hard
+• Update all plugins automatically
+• Dependency is not hard anymore
----
• Not depends on Git, HG ...etc
But work very well with them
+• I use Vundle, it depends on Github
https://blog.othree.net/log/2011/06/05/vundle/
+• More and more Vim plugin lives on Github or other repo sites
+ • ex: garbas/vim-snipmates
+ othree/vim-autocomplpop
+ bling/vim-airline
----
== Related Manager
• pathogen.vim
+• Vundle
+• NeoBundle
---- center
Thanks You, Tim Pope !!
----
== Last Slide for Complete
• Imaging the complete funcion in IDE
+• Tern: http://ternjs.net/
+• But I am writing CoffeeScript now.....
+• Tell us if you have experience on Tern
----
----
3rd
---- center
Lint
----
== JSLint and Vim
• JSLint.vim
+• Not update JSLint often
+• Host my own to fix this issue
+• Also make it possible to use JSHint
+• Then I starts write CoffeeScript...
----
== CoffeeCheck.vim
+• Based on JSLint.vim
+• Use CoffeeScript compiler to do syntax check
+• Only one error per check
+• Only syntax check, not linter
+• CoffeeLint borns....
----
== CoffeeLint.vim ?
+ Ladies and Gentlemen,
+ let me introduce ...
---- html,i-8
/ \,,_ .'|
,{{| /}}}}/_.' _____________________________________________
}}}}` '{{' '. / \
{{{{{ _ ;, \ / Ladies and Gentlemen, \
,}}}}}} /o`\ ` ;) | |
{{{{{{ / ( | this is ... |
}}}}}} | \ | |
{{{{{{{{ \ \ | |
}}}}}}}}} '.__ _ | | _____ __ __ _ |
{{{{{{{{ /`._ (_\ / | / ___/__ ______ / /_____ ______/ /_(_)____ |
}}}}}}' | //___/ --=: \__ \/ / / / __ \/ __/ __ `/ ___/ __/ / ___/ |
jgs `{{{{` | '--' | ___/ / /_/ / / / / /_/ /_/ (__ ) /_/ / /__ |
}}}` | /____/\__, /_/ /_/\__/\__,_/____/\__/_/\___/ |
| /____/ |
| /
\_____________________________________________/
----
== Syntastic
+• General syntax checker interface
+• filetype vs multiple checker
+• Supports JavaScript, CoffeeScript...etc
+• CoffeeScript supports CoffeeScript Compiler and CoffeeLint ...
+ by default
+• https://blog.othree.net/log/2013/06/21/syntastic-coffeelint/
----
== Syntastic for JavaScript
+• Supports JSLint, JSHint, Closure Linter,
JavaScript Lint, Closure Compiler
+• For other filetypes:
https://github.com/scrooloose/syntastic/tree/master/syntax_checkers
----
== JSLint in 10secs
+• Hurts your feeling
+• But it worth!!
+• For the errors you don't understand
http://jslinterrors.com/
----
----
One more thing
---- center
Regular Expression
----
• Find command `/`
+• It supports regular expression
+• Vim's Regular Expression
----
== Vim's Regular Expression
+• http://vimdoc.sourceforge.net/htmldoc/pattern.html
+• Very different from other RegExp
+• Very different from JavaScript's RegExp
----
== For Example
+• Do you know `\zs` ?
+• Do you know `\w` still works ?
+• Do you know `[\w]` is not what you think ?
+• How about `\_.`, `\%^`, `\@<!`, `\{-}`, `\_[]`
+• What if I want to use familiar RegExp format, like Perl or JavaScript
+ • Ack.vim
+ • eregex.vim
----
== eregex.vim
• Translate Perl style RegExp to Vim's format
+• Author: 安久津
+• Disappeared...
+• I start to host my own...
----
== Bugs
+• Do you know how to find third item
+ use `3/`
+• Do you know when count > 1, highlight will enable
+• Do you know there is a backword search `?`
+• eregex.vim can't do every thing above...
----
== The Count Parameter
• :help command-count
---- help
Range handling *E177* *E178* *:command-range*
*:command-count*
By default, user-defined commands do not accept a line number range. However,
it is possible to specify that the command does take a range (the -range
attribute), or that it takes an arbitrary count value, either in the line
number position (-range=N, like the |:split| command) or as a "count"
argument (-count=N, like the |:Next| command). The count will then be
available in the argument with |<count>|.
Possible attributes are:
-range Range allowed, default is current line
-range=% Range allowed, default is whole file (1,$)
-range=N A count (default N) which is specified in the line
number position (like |:split|); allows for zero line
number.
-count=N A count (default N) which is specified either in the line
number position, or as an initial argument (like |:Next|).
Specifying -count (without a default) acts like -count=0
Note that -range=N and -count=N are mutually exclusive - only one should be
specified.
----
== Easy~~~
+• How about the backward search and highlight
+ • backword `?`
• highlight `hlsearch`
---- viml,i1
- if delim !=# '/'
++ if delim !=# '/' && delim !=# '?'
---- center,replace
Piece of Cake ~~
+Not Work !!!!
----
• `n` after a backward search still goes forward
---- center
Don't Know Why
---- center
20 months later...
----
• :help function-search-undo
---- help
*function-search-undo*
The last used search pattern and the redo command "."
will not be changed by the function. This also
implies that the effect of |:nohlsearch| is undone
when the function returns.
----
+• Both search direction and highlight will been reset
----
+• OK
+• Impossible to fix
+• Close issue
---- center
One Month Later
----
• Something *wrong* on me
+• Keep looking at Vim resource and document
+• I found `v:searchforward`
----
• :help v:searchforward
---- help
v:searchforward *v:searchforward* *searchforward-variable*
Search direction: 1 after a forward search, 0 after a
backward search. It is reset to forward when directly setting
the last search pattern, see |quote/|.
Note that the value is restored when returning from a
function. |function-search-undo|.
Read-write.
----
• `v:searchforward` is what been reset when leave function
• `hlsearch` is another one been reset
• How could I set it on my custom command
---- viml,i1
-command! -nargs=? M :call <SID>Ematch(<q-args>)
++command! -nargs=? -count M :let v:searchforward = <SID>Ematch(<q-args>)
---- center
Highlight ?
---- viml,i1
-command! -nargs=? -count=0 M :let v:searchforward = <SID>Ematch(<count>, <q-args>)
++command! -nargs=? -count=1 M :let v:searchforward =
\ <SID>Ematch(<count>, <q-args>) | if <count> > 1 | set hlsearch on | endif
----
== So...
• Vim have great document
+• It documents almost every detail in Vim
+• If you want write Vim Script or Plugin
+• You must learn how to read & search in the document
----
== Problems
+• Bad SEO, hard to see it in search results
+• You need know the correct keyword
----
== Suggestion
+• Use `:help keyword` first
+• Add 'vim', 'doc' to your keywords when search on web
ex: 'vim doc ctrl-l'
+• Search in vim doc directly
http://vimdoc.sourceforge.net/htmldoc/help.html
+• Find the right keyword, and back to Vim
+• Use <CTRL-]> and <CTRL-O>
----
== Reading, Refs
• Vim Doc
http://vimdoc.sourceforge.net/htmldoc/help.html
• Learn Vimscript the Hard Way