Move entire line up and down in Vim

后端 未结 19 1148
无人及你
无人及你 2020-11-29 14:27

In Notepad++, I can use Ctrl + Shift + Up / Down to move the current line up and down. Is there a similar command to this in Vim?

19条回答
  •  误落风尘
    2020-11-29 15:08

    If I want to swap one line with the line above I usually do the following

    ddkP
    

    Explanation

    • dd will delete the line and add it to the default register.
    • k will move up a line (j would move down a line)
    • P will paste above the current line

提交回复
热议问题