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

map the _ key to move the line up

Expand Messages
  • cyboman
    I have a - key mapped to move the line down. Here it is map - ddp I want to have a command opposite to it, _ to move the line up. I tried map _ ddkP but it
    Message 1 of 4 , Nov 17, 2012
    • 0 Attachment
      I have a - key mapped to move the line down. Here it is
      map - ddp

      I want to have a command opposite to it, _ to move the line up.
      I tried map _ ddkP but it doesn't work. If I'm on the last line of text it will move the text two lines up and if I'm on the first line it simply deletes the lines, which makes sense why.

      I know this is a simple task for most of you, but I have never fiddled with Vim mappings. I would appreciate if anyone could help me out.

      Thanks.

      --
      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
    • Tony Mechelynck
      ... Try kddp instead. This should work correctly even on the last line. On the first line it will beep, and it may (or it may not) move the line down instead.
      Message 2 of 4 , Nov 17, 2012
      • 0 Attachment
        On 17/11/12 15:31, cyboman wrote:
        > I have a - key mapped to move the line down. Here it is
        > map - ddp
        >
        > I want to have a command opposite to it, _ to move the line up.
        > I tried map _ ddkP but it doesn't work. If I'm on the last line of text it will move the text two lines up and if I'm on the first line it simply deletes the lines, which makes sense why.
        >
        > I know this is a simple task for most of you, but I have never fiddled with Vim mappings. I would appreciate if anyone could help me out.
        >
        > Thanks.
        >

        Try kddp instead. This should work correctly even on the last line. On
        the first line it will beep, and it may (or it may not) move the line
        down instead. I haven't checked, but I think that on the first line it
        will do nothing, which makes sense (you can't move the first line up,
        can you?)


        Best regards,
        Tony.
        --
        ROBIN: The what?
        ARTHUR: The Holy Hand Grenade of Antioch. 'Tis one of the sacred relics
        Brother Maynard always carries with him.
        ALL: Yes. Of course.
        ARTHUR: (shouting) Bring up the Holy Hand Grenade!
        "Monty Python and the Holy Grail" PYTHON (MONTY)
        PICTURES LTD

        --
        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
      • rail shafigulin
        Thanks Tony it worked, but I also added a k to the command so I could move one line up. nnoremap _ kddpk On Sat, Nov 17, 2012 at 9:57 AM, Tony Mechelynck
        Message 3 of 4 , Nov 17, 2012
        • 0 Attachment
          Thanks Tony it worked, but I also added a k to the command so I could move one line up.

          nnoremap _ kddpk


          On Sat, Nov 17, 2012 at 9:57 AM, Tony Mechelynck <antoine.mechelynck@...> wrote:
          On 17/11/12 15:31, cyboman wrote:
          I have a - key mapped to move the line down. Here it is
          map - ddp

          I want to have a command opposite to it, _ to move the line up.
          I tried map _ ddkP but it doesn't work. If I'm on the last line of text it will move the text two lines up and if I'm on the first line it simply deletes the lines, which makes sense why.

          I know this is a simple task for most of you, but I have never fiddled with Vim mappings. I would appreciate if anyone could help me out.

          Thanks.


          Try kddp instead. This should work correctly even on the last line. On the first line it will beep, and it may (or it may not) move the line down instead. I haven't checked, but I think that on the first line it will do nothing, which makes sense (you can't move the first line up, can you?)


          Best regards,
          Tony.
          --
          ROBIN:  The what?
          ARTHUR: The Holy Hand Grenade of Antioch.  'Tis one of the sacred relics
                  Brother Maynard always carries with him.
          ALL:    Yes. Of course.
          ARTHUR: (shouting) Bring up the Holy Hand Grenade!
                           "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD


          --
          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
        • Paul
          ... Try fiddling with searching the list. If you had read a recent thread titled “move a range of text to address”, you d see that this is [probably] the
          Message 4 of 4 , Nov 17, 2012
          • 0 Attachment
            On Saturday, 17 November, 2012 at 14:31:23 GMT, cyboman wrote:
            >I have a - key mapped to move the line down. Here it is
            >map - ddp
            >
            >I want to have a command opposite to it, _ to move the line up.
            >I tried map _ ddkP but it doesn't work. If I'm on the last line of text it will move the text two lines up and if I'm on the first line it simply deletes the lines, which makes sense why.
            >
            >I know this is a simple task for most of you, but I have never fiddled with Vim mappings. I would appreciate if anyone could help me out.

            Try fiddling with searching the list. If you had read a recent thread titled “move a range of text to address”, you'd see that this is [probably] the preferred solution:

            nnoremap _ :m-2<cr>
            nnoremap - :m+<cr>

            --

            .

            --
            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
          Your message has been successfully submitted and would be delivered to recipients shortly.