You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(Since this issue will likely not be addressed in the book itself due to #95, may it hopefully be informative to whomever happens to come across it...)
Now that we know how to get a fully-escaped version of the word under the cursor, it's time to concatenate it into our mapping! Run the following command:
Try it out. This mapping won't break if the word we're searching for happens to contain strange characters.
However, the above mapping breaks if there are special characters in the current WORD under the cursor. A couple examples of such WORDs are:
%-percent-char, which ends up invoking :grep -R '%-percent-char' and % expands to the current file name, and
<afile>-string, which errors out with E497: no autocommand match name to substitute for "<afile>".
A simple fix for this is to pass a non-zero {special} arg to shellescape({string} [, {special}]), which will escape special items as well. With this knowledge, the final mapping can be further refined as follows:
(Since this issue will likely not be addressed in the book itself due to #95, may it hopefully be informative to whomever happens to come across it...)
Chapter 32, section "Escaping Shell Command Arguments", ends with
However, the above mapping breaks if there are special characters in the current
WORD
under the cursor. A couple examples of suchWORD
s are:%-percent-char
, which ends up invoking:grep -R '%-percent-char'
and%
expands to the current file name, and<afile>-string
, which errors out withE497: no autocommand match name to substitute for "<afile>"
.A simple fix for this is to pass a non-zero
{special}
arg toshellescape({string} [, {special}])
, which will escape special items as well. With this knowledge, the final mapping can be further refined as follows:The text was updated successfully, but these errors were encountered: