The <CTRL-R>= things evaluates the expression. For example:
+
The <CTRL-R>= things evaluates the expression. For example:
−
<CTRL-R>=12+34<cr>
+
<pre>
+
<CTRL-R>=12+34<CR>
+
</pre>
−
<CTRL-R>= works in insert mode and in command mode. I felt it more convenient if <CTRL-R>= did the same thing in normal mode too.
+
<CTRL-R>= works in insert mode and in command mode. I felt it more convenient if <CTRL-R>= did the same thing in normal mode too.
−
I have this in my .vimrc:
+
I have this in my [[vimrc]]:
−
map <CTRL-R>= :echo
+
<pre>
+
map <CTRL-R>= :echo
+
</pre>
−
Now <CTRL-R>=123*456<CR> evaluates expressions for me in all 3 modes: normal mode, insert mode, and command mode. In fact I found it much more convenient to do casual calculations using <CTRl-R>= in normal mode than in any other mode.
+
Now <CTRL-R>=123*456<CR> evaluates expressions for me in all 3 modes: normal mode, insert mode, and command mode. In fact I found it much more convenient to do casual calculations using <CTRl-R>= in normal mode than in any other mode.
−
Be warned: when typing <CTRL-R>= in normal mode, don't make long pause before '='. <CTRL-R> alone means 'redo' in normal mode. Vim is very smart, and figures the difference between single <CTRL-R> (which is 'redo') and the mapped sequence <CTRL-R>= (which is remapped). The 'timeoutlen' option controls this difference. The default value of 'timeoutlen' option is very convenient.
+
Be warned: when typing <CTRL-R>= in normal mode, don't make long pause before '='. <CTRL-R> alone means 'redo' in normal mode. Vim is very smart, and figures the difference between single <CTRL-R> (which is 'redo') and the mapped sequence <CTRL-R>= (which is remapped). The 'timeoutlen' option controls this difference. The default value of 'timeoutlen' option is very convenient.
This is an expansion of [[VimTip73|Using Vim as calculator]].
This is an expansion of [[VimTip73|Using Vim as calculator]].
Line 33:
Line 33:
==Comments==
==Comments==
−
To get the behavior like i_CTRL-r in normal mode, use @=. For example, in normal mode, @='dd'<cr> will delete the current line just as if you had pressed dd in normal mode.
+
To get the behavior like i_CTRL-r in normal mode, use @=. For example, in normal mode, @='dd'<CR> will delete the current line just as if you had pressed dd in normal mode.
*{{help|@}}
*{{help|@}}
Latest revision as of 08:52, September 29, 2008
Please review this tip:
This tip was imported from vim.org and needs general review.
Now <CTRL-R>=123*456<CR> evaluates expressions for me in all 3 modes: normal mode, insert mode, and command mode. In fact I found it much more convenient to do casual calculations using <CTRl-R>= in normal mode than in any other mode.
Be warned: when typing <CTRL-R>= in normal mode, don't make long pause before '='. <CTRL-R> alone means 'redo' in normal mode. Vim is very smart, and figures the difference between single <CTRL-R> (which is 'redo') and the mapped sequence <CTRL-R>= (which is remapped). The 'timeoutlen' option controls this difference. The default value of 'timeoutlen' option is very convenient.
To get the behavior like i_CTRL-r in normal mode, use @=. For example, in normal mode, @='dd'<CR> will delete the current line just as if you had pressed dd in normal mode.