2015-10-07 7:39 GMT+03:00 Kenneth Reid Beesley <krbeesley@gmail.com>:
> 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 would highly suggest to *never* use nmap. When you need mappings use
nnoremap so that other mappings do not interfere.
Specifically if you are using vim-latex-suite it has loads of annoying
insert-mode mappings which I was always disabling.
>
> 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
… and move cursor one character back (BTW, this <Esc> is not present above).
> P print the buffer contents
… before the current character
> 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?
When creating mappings try to type them. You must not use `P` if you
need to paste *after* curly brace, `P` pastes *before* the cursor and
<Esc> moves cursor just at the curly brace. You need `p` here. Though
better use `<C-r>`, specifically in your case it would be `<C-r>"`.
Christian Brabandt has another example.
>
> 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 vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
--
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Wednesday, October 7, 2015
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment