m (moved Path with backslash search command to Command for searching a paths wich includes backslash.) |
No edit summary |
||
Line 1: | Line 1: | ||
This trick explain how to search a path of the form /path/to/ without leading slash. |
This trick explain how to search a path of the form /path/to/ without leading slash. |
||
It is based on magic and on the function escape: |
It is based on magic and on the function escape: |
||
+ | |||
<code> |
<code> |
||
:help escape() |
:help escape() |
||
Line 8: | Line 9: | ||
==Ss command== |
==Ss command== |
||
Inserting in your vimrc the following line: |
Inserting in your vimrc the following line: |
||
+ | |||
<code> |
<code> |
||
command! -nargs=1 Ss let @/ = escape('<args>', '/') |
command! -nargs=1 Ss let @/ = escape('<args>', '/') |
||
</code> |
</code> |
||
+ | gives you the new command Ss which search for expressions in which backslashes are automatically escaped: / -> \/ |
||
− | Write the first section of your article here. |
||
+ | |||
+ | |||
+ | ==SS command== |
||
+ | Inserting in your vimrc the following line: |
||
+ | |||
+ | <code> |
||
+ | command! -nargs=1 SS let @/ = '\V'.escape("<args>",'/') |
||
+ | </code> |
||
+ | |||
+ | gives you the new command SS which search for expressions in which all magic characters and the backslashes are automatically escaped: / -> \/; $ -> \$ ... |
||
+ | |||
==References== |
==References== |
||
<!-- Put any help links you want here in a list as follows: --> |
<!-- Put any help links you want here in a list as follows: --> |
||
− | *{{help| |
+ | *{{help|magic}} |
+ | *{{help|escape()}} |
||
==Comments== |
==Comments== |
Revision as of 10:06, 29 March 2011
This trick explain how to search a path of the form /path/to/ without leading slash. It is based on magic and on the function escape:
- help escape()
- help magic
Ss command
Inserting in your vimrc the following line:
command! -nargs=1 Ss let @/ = escape('<args>', '/')
gives you the new command Ss which search for expressions in which backslashes are automatically escaped: / -> \/
SS command
Inserting in your vimrc the following line:
command! -nargs=1 SS let @/ = '\V'.escape("<args>",'/')
gives you the new command SS which search for expressions in which all magic characters and the backslashes are automatically escaped: / -> \/; $ -> \$ ...