2015-10-07 18:10 GMT+03:00 Tony Mechelynck <antoine.mechelynck@gmail.com>:
> On Wed, Oct 7, 2015 at 6:39 AM, Kenneth Reid Beesley
> <krbeesley@gmail.com> wrote:
>> 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
>
>
> Maybe your curly braces are mapped to something?
Just type the example (do not forget about <Esc> which is in
"disambiguation" section of the original message, but not in the
`nmap` command) and you will see the same behaviour. I have explained
why just before the message I am replying to here.
>
> Make sure your cursor is in a LaTex source file, then
> :map! {
> :map! }
>
> If the braces don't appear correctly even here, you may use
> Ctrl-V x 7b
> for the opening brace, and
> Ctrl-V x 7d
> for the closing brace (with no spaces; and if your Ctrl-V is mapped to
> the paste operation, use Ctrl-Q instead).
>
> These ^Vx codes can be used also in Insert mode (not only in
> Command-line mode), to enter characters by hex value while
> disregarding mappings up to 0xFF (for higher codepoints, and if
> 'encoding' is UTF-8, ^Vu followed by 1 to 4 hex digits can be used up
> to U+FFFF, or ^VU followed by 1 to 8 hex digits for the whole Unicode
> range even outside the BMP: Vim accepts up to ^VU7FFFFFFF but the
> Unicode Consortium has decided that nothing above U+10FFFD will ever
> be a valid codepoint).
>
> see
> :h map-listing
> :h i_CTRL-V_digit
>
>
> Best regards,
> Tony.
>
> --
> --
> 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