Tuesday, March 11, 2014

Re: basic question on vim scripting


On Mar 11, 2014 7:00 PM, "Matteo Cavalleri" <cvlmtg@gmail.com> wrote:
>
> I'm playing a bit with a vim script, and I'm stuck on this problem:
>
>         if exists('b:current_line')
>             echom "normal! ".b:current_line."G"
>             exe "normal! ".b:current_line."G"
>             echom 'line is '.line('.')
>         endif
>
> If I run the script

When and how? It may appear that you do this too late, too early, on wrong buffer or in wrong context (after running code in a specific context cursor is restored. I do not remember what context though: some autocmd maybe? Or &*expr, though they usually use textlock).

> and then do :messages, the output is this one:
>
> normal! 6G
> line is 1
>
> and I can't understand why the cursor doesn't move... (I'm not even sure this is the correct way to move, as google isn't helping me much)

Since you have a variable cursor() mentioned above is better.

>
> --
> --
> 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.

No comments:

Post a Comment