How to duplicate a whole line in Vim?

后端 未结 19 1013
北海茫月
北海茫月 2020-12-22 14:29

How do I duplicate a whole line in Vim in a similar way to Ctrl+D in IntelliJ IDEA/ Resharper or Ctrl+Alt+&

19条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-22 14:43

    I know I'm late to the party, but whatever; I have this in my .vimrc:

    nnoremap  :copy .
    vnoremap  :copy '>
    

    the :copy command just copies the selected line or the range (always whole lines) to below the line number given as its argument.

    In normal mode what this does is copy . copy this line to just below this line.

    And in visual mode it turns into '<,'> copy '> copy from start of selection to end of selection to the line below end of selection.

提交回复
热议问题