I wonder if there is a command to straight away copy a character or a word above the cursor and paste it at the current position?
Example:
sig1 : in std_logic;
sig2 : in std_logic;
sig3 : ^
Consider the situation above, and my cursor is at the ^ position, I would like to duplicate the in std_logic; and paste it at current position. A way that I know of that can work is:
1. Move cursor up
2. Go into visual mode and highlight
3. Yank
4. Move cursor down
5. Paste
Is there any easier way to do so? Or I’m left with the only option of writing a mapping in vimrc that execute the whole sequence for me?
Edit:
I found a mapping on the internet:
imap <F1> @<Esc>kyWjPA<BS>
nmap <F1> @<Esc>kyWjPA<BS>
imap <F2> @<Esc>kvyjPA<BS>
nmap <F2> @<Esc>kvyjPA<BS>
but it seems that Greg’s solution is easier!
In insert mode, you can use Ctrl+Y to copy characters from the corresponding character position on the previous line. Just hold down the key and wait for the keyboard repeat to get you to the end of the line.