How do I duplicate a whole line in Vim in a similar way to Ctrl+D in IntelliJ IDEA/Resharper or Ctrl+Alt+↑/↓ in Eclipse?
相关问题
- Emacs shell: save commit message
- How to change the first two uppercase characters o
- Insert text into current buffer from function
- Hot reload on save
- Substituting zero-width match in vim script
相关文章
- 如何让 vim 支持 .cshtml 文件的代码高亮
- Auto-save in VIM as you type
- How can I use gcc's -I command to add recursiv
- NSMenuItem KeyEquivalent “ ”(space) bug
- Vim: overloaded mapping for multiple modes
- vi editor is not responding
- How to use relative line numbering universally in
- How to copy the value of a vim option to a registe
If you want another way :-)
"ayy
this will store the line in buffera
"ap
this will put the contents of buffera
at the cursor.There are many variations on this.
"a5yy
this will store the 5 lines in buffera
see http://www.vim.org/htmldoc/help.html for more fun
yy or Y to copy the line
or
dd to delete (cutting) the line
then
p to paste the copied or deleted text after the current line
or
P to paste the copied or deleted text before the current line
yyp - remember it with "yippee!"
Multiple lines with a number in between:
y7yp
Another option would be to go with:
gives you the advantage of preserving the cursor position.
For someone who doesn't know vi, some answers from above might mislead him with phrases like "paste ... after/before current line".
It's actually "paste ... after/before cursor".
yy or Y to copy the line
or
dd to delete the line
then
p to paste the copied or deleted text after the cursor
or
P to paste the copied or deleted text before the cursor
For more key bindings, you can visit this site: vi Complete Key Binding List
Default is yyp, but I've been using this rebinding for a year or so and love it:
" set Y to duplicate lines, works in visual mode as well. nnoremap Y yyp vnoremap Y y`>pgv