[vox-tech] vim question: making mapping atomic w.r.t the '.'
command
Matt Roper
matt at mattrope.com
Tue Nov 30 13:03:31 PST 2004
On Tue, Nov 30, 2004 at 02:00:10AM -0500, Peter Jay Salzman wrote:
> On Mon 29 Nov 04, 6:27 PM, Henry House <hajhouse at houseag.com> said:
> > I have a nice mapping in Vim 6:
> >
> > :nmap gfe cw\empf{^[pa}^[
> >
> > which emphasises a word when the buffer contains LaTeX source.
>
>
> This macro works, but you have to position the cursor on the beginning of the
> word, otherwise, you end up with only a part of the word emphasized. Another
> strategy would be:
>
> 1. Find the previous space character.
> 2. Move the cursor right by one.
> 3. Then change the word.
>
> Here would be that strategy expressed as a macro:
>
> :nmap gfe F lcw\empf{<esc>pa}<esc>
>
> The deficiency with my macro is that it doesn't work on the first word of
> each line since there's no space before it.
>
> The benefit is that you can be "anywhere" in the word (provided the word
> doesn't start a new line) and it'll work.
>
> Depends on which you find is the bigger annoyance. ;-)
I believe an easier solution to this problem would be:
:nmap gfe ciw\empf{^[pa}^[
Changing 'cw' to 'ciw' tells vim to change the word the cursor is inside
of so this should work anywhere, including the start of a new line.
Matt
--
*************************************************
* Matt Roper <matt at mattrope.com> *
* http://www.mattrope.com *
* PGP Key: http://www.mattrope.com/mattrope.asc *
*************************************************
More information about the vox-tech
mailing list