Skip to main content
add about macro insertion via assignment
Source Link
3N4N
  • 5.9k
  • 1
  • 21
  • 49

Edit

You can't use the literal string that you got when you inserted it with :h i_CTRL-R_CTRL-R to use as a recording. Because the literal string that the extended ASCII key-code spews out is not within one of :h key-codes. For example, if you want to insert <C-Right> into a register and use it, you need to do it in the following way:

:let @q = "\<C-Right>"

The backslash and double-quote is necessary to evaluate to special characters, see :h string and :h literal-string.

In other words, the weird character that the HEX value of <fd> evaluates to in extended ASCII chart is not going to be converted to special characters or key-codes in :h key-codes.

Edit

You can't use the literal string that you got when you inserted it with :h i_CTRL-R_CTRL-R to use as a recording. Because the literal string that the extended ASCII key-code spews out is not within one of :h key-codes. For example, if you want to insert <C-Right> into a register and use it, you need to do it in the following way:

:let @q = "\<C-Right>"

The backslash and double-quote is necessary to evaluate to special characters, see :h string and :h literal-string.

In other words, the weird character that the HEX value of <fd> evaluates to in extended ASCII chart is not going to be converted to special characters or key-codes in :h key-codes.

Source Link
3N4N
  • 5.9k
  • 1
  • 21
  • 49

There are several ways to insert the content of a registers. I'm going to briefly discuss some that are inserted when in :h Insert-mode:

  • :h i_CTRL-R : Insert the content of a register. Unlike, :h p or :h P i.e. "qp, how the texts are inserted will be affected by options like :h textwidth, :h formatoptions or :h autoindent.
  • :h i_CTRL-R_CTRL-R : Works like using a single CTRL-R, but the text is inserted literally, not as if typed. So, if you record hitting a backspace, e.g. type^Hing, would insert typing when inserted with single CTRL-R but will insert type^Hing when inserted with double CTRL-R. (^H is CTRL-H, used for <BS> in terminal emulators, i.e. they emit same code <U+0008). Still is affected by auto-indent options.
  • :h i_CTRL-R_CTRL-O : Insert text literally and isn't affected by auto-indent.
  • :h i_CTRL-R_CTRL-P : Insert the contents of a register literally and fix the indent.

Now, when you pressed <Ctrl-Right> after starting the recording, your terminal emulator emits some keycodes. I don't exactly know what they might be and most probably they even differ from computer to computer. So, it's a wildcard why the characters <80> <fd> (both hexadecimal values) and most confusingly why V is there! I have no answer to these. The only thing I have advanced on your observations is that both ý and <fd> are basically same character, i.e. they both have same HEX values which is 00FD. Double CTRL-R, i.e. i_CTRL-R_CTRL-R, inserts literal characters. That's why it inserted the literal value of <fd> and not the HEX value which is saved in its :h digraph.

So, to wrap it up:

  • Check out the documentations to know about various ways to insert content of a register and differences among them.
  • <fd> and ý are same character, former is HEX value and latter is ASCII value.
  • No idea why there is a literal V in the <C-Right> :h key-codes recording
  • No idea how to make sense of these nonsensical key-codes. And I suppose, in order to not have to think about these key-codes, vim provides us sensible :h key-codes for mappings and such.