Loading ...
Sorry, an error occurred while loading the content.
 

Re: Get last normal mode command?

Expand Messages
  • Andy Wokula
    ... No, your function is called only once. ... Nice use case for tinymode.vim, btw. http://vim.sourceforge.net/scripts/script.php?script_id=2223 call
    Message 1 of 3 , May 28, 2008
      Tim Weber schrieb:
      > Hi,
      >
      > I'm currently trying to write a script that sets 'cursorline' after
      > jumping with, say, gg or G. It should then reset 'cursorline' as soon
      > as the cursor continues to move. The effect should be some kind of
      > "you are _here_ now" mark that goes out of your way as soon as you
      > continue editing.
      >
      > However, in my current approach I have found several problems.
      >
      > 1. I can't seem to get the last normal mode command from inside a
      > function that is being called from a mapping. The only thing close to
      > it is "v:operator", but for example...
      > :nmap G :echo v:operator<CR>
      > ... does not lead to the desired result. What I want is something like
      > the ":" register, but for normal mode. That way I don't have to pass
      > the mapping that led to the function as a parameter or something and
      > can use the same call for a map of G, gg and the like.
      >
      > 2. I can't map "gg": Something like
      > :nmap gg G
      > is silently ignored (i.e. "gg" does what it always does). If you know
      > why that is or what I can do against it, please tell me. Pointers to
      > documentation I'm currently too blind to see are okay as well, just
      > throw some keywords at me.
      >
      > 3. Will I get into trouble with count prefixes? When I map "G" to my
      > groovy function, I guess I can read the count via "v:count" and use
      > that to jump to the correct place, but will "1000G" call my function a
      > thousand times?

      No, your function is called only once.

      > Thanks in advance,
      >
      > Tim.

      Nice use case for tinymode.vim, btw.
      http://vim.sourceforge.net/scripts/script.php?script_id=2223

      call tinymode#EnterMap("movecul", "gg", "gg")
      call tinymode#EnterMap("movecul", "G", "G")
      call tinymode#Map("movecul", "gg", 'norm! [N]gg')
      call tinymode#Map("movecul", "G", 'norm! [N]G')
      call tinymode#ModeArg("movecul", "entercmd", 'setl cursorline')
      call tinymode#ModeArg("movecul", "leavecmd", 'setl nocursorline')
      call tinymode#ModeArg("movecul", "owncount")


      'cursorline' is reset after one second, but I think you might even
      appreciate that. You can make it stay longer by increasing 'timeoutlen'.
      Be sure to have 'nolazyredraw' set (it's the default value).

      What further keys do you want to map?

      --
      Andy






      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.