Is it possible to apply an ex command to something smaller than a line? For instance, I tried to define a mapping that would remove an \emph{} from the enclosed word. The best I could do was:
nnoremap dsi vaW:s/\\emph{//\|s/}//<cr>
It turns out that this does not operate on the selection but rather on the line.
PS. I am satisfied with the comments to the effect that :s
can operate on selections if \%V
is placed at the beginning of the pattern.
noremap dsi vaW:s/\%V\\emph{//\|s/}//<cr>
? See:h /\%V
. And, unless you have a special need, always usenoremap
, notnmap
, if you want to avoid surprises. Also your map won't like spaces (more than one emphasized/enclosed word).nmap dsf ds{dF\
(I meannmap
since I wantds{
to call the surround mapping.)\%V
atom specifically for the:s
command