I want to edit a LaTeX source file, using (g)vim and suitable names, to add 
\index{…} commands.

In particular, I want to be able to position the cursor anywhere on a word
or selection to be indexed, and then type something like \ind
to add an \index{…} command to the text, where … is the current word.

For example, if the text is

        The dog has a bone.

and (in normal mode) I position the cursor on “dog”, and type \ind, I want the 
text to become

        The dog\index{dog} has a bone.

If I then proceed to place the cursor on “bone” and type \ind, the text would 
become

        The dog\index{dog} has a bone\index{bone}.

*****

I’ve tried things like this (in my .gvimrc file)

nmap <Bslash>ind   yiwea\index{Pa}<ESC>

i.e., 

yiw     yank the internal word (current word) to the default buffer
e       move the cursor to the end of the word
a       go into insert mode

insert literal “\index{“                (SOMETHING IS GOING WRONG AT THIS STEP)

<ESC>   escape to normal mode
P               print the buffer contents
a               go into insert mode
insert literal “}”
<ESC>   escape to normal mode

But when I place the cursor on “dog” and invoke the command, I get

        The dog\indexdog}{ has a bone.

The left curly brace is appearing after the right curly brace.  
Where am I going wrong?

Thanks,

Ken



********************************
Kenneth R. Beesley, D.Phil.
PO Box 540475
North Salt Lake UT 84054
USA





-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to