I came across a number of this syntax usages which I don't understand:
The first is in :help mapping:
:map <F2> a<C-R>=strftime("%c")<CR><Esc> This sequence really does insert the value of strftime into buffer though I don't understand how. Changing onto something different breaks it.
Another one is at wiki page which describes how to make omnicompletion popup menu work well:
inoremap <silent> <Esc> <C-r>=pumvisible() ? "\<C-y>" : "\<Esc>"<CR> The same thing here.
Can anybody explain how this "<C-r>=" thing works?...
The <CR> in vim mappings is the carriage return usually the Enter on your keyboard.
The CR command collects failure information and either displays it on the console or dumps the information to a floppy disk.
Short for carriage return, CR is often used to represent a carriage return done by pressing the Enter and Return key.
<C-r>=, or Ctrl+R= is used to insert the result of an expression at the cursor.
I use it a lot when editing CSS to insert values:
width: <C-r>=147-33<CR>px; width: 114px; EDIT
<C-r>, without =, allows you to insert the content of any register at the cursor while staying in insert mode: <C-r>+, for example, inserts the content of my system clipboard. see :help i_ctrl_r.
= is the "expression register". See :help "=.
ENDEDIT
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With