开发者

A shortcut to add a line

开发者 https://www.devze.com 2023-01-17 01:59 出处:网络
In my current project I end up typing this line a lot Then show me the page How should I create a shortcut mapping 开发者_如何学Goso that if I am on a line and hit that shortcut then a new line jus

In my current project I end up typing this line a lot

Then show me the page

How should I create a shortcut mapping 开发者_如何学Goso that if I am on a line and hit that shortcut then a new line just below the current line is created and the above mentioned line is added.

It would be nice if the newly added line has the same indentation as the above line.

I am using MacVim.


From normal mode, you can type, or add this line to your vimrc:

:nmap Q oThen show me the page<cr><esc> 

This just plays back the keystrokes to open a new line below the current one (with correct indentation), type the characters, press enter for a linebreak, then exit insert mode.

I chose the keystroke Q, but this overwrites something else. You might choose a different keystroke instead...


yyp will copy the line (yy) and paste below the line (p)

yyP will paste a copy of the line above the present line (P)

0

精彩评论

暂无评论...
验证码 换一张
取 消