On Vim, I try to record a key sequence macro to surround a selected text in double-quotes.
First, I select a string of text and press key q
followed by a register key to associate the macro, here I chose d
.
The line recording @d
appears in the footer line, indicating that the recording is on. Then I press the command x
to remove (and automatically copy) the selected text.
Then where I have problem is when I press on the key i
to insert two double quotes at the current position, it's not working.
I typed :verbose map i
in normal mode but I got nothing.
I have Ubuntu installed on my raspberry Pi. I look in this file /etc/vim/vimrc to see if I can find why the i
command is not working, I found nothing.
I have the Vi IMproved version 8.2.
Any key sequence can be recorded as a macro for future execution. A macro can be recorded, for example, to surround a selected text in double-quotes. First, a string of text is selected and the key q is pressed, followed by a register key to associate the macro with, like d. The line recording @d will appear in the footer line, indicating that the recording is on. It is assumed that some text is already selected, so the first command is x to remove (and automatically copy) the selected text. The key i is pressed to insert two double quotes at the current position, then Esc returns to normal mode. The last command is P, to re-insert the deleted selection just before the last double-quote. Pressing q again will end the recording. Now, a macro consisting of key sequence x, i, "", Esc and P will execute every time keys @d are pressed in normal mode, where d is the register key associated with the macro.
Source: Learning materials LPI-1 (101)
vim --clean
i
. In the tutorial I'm following, it's written, thei
is supposed to add double quote"
. I will add the extract of the LPI content I'm talking about in my question.i
key simply switches to insert mode. It does in particular not insert double quotes at the current position. For that, you have to first enter insert mode, and then type the double quote"
(if your"
is a dead key, you may have to press space afterwards). In this regards, the LPI description is simply wrongi
to enter insert mode, it is up to you to press""
.