(Move categories to tip template) |
(Remove html character entities) |
||
Line 12: | Line 12: | ||
|category2= |
|category2= |
||
}} |
}} |
||
− | The |
+ | The <CTRL-R>= things evaluates the expression. For example: |
+ | <pre> |
||
− | <CTRL-R>=12+34<cr> |
||
+ | <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. |
|
− | I have this in my |
+ | I have this in my [[vimrc]]: |
+ | <pre> |
||
− | + | map <CTRL-R>= :echo |
|
+ | </pre> |
||
− | Now |
+ | 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 |
+ | 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 37: | ||
==Comments== |
==Comments== |
||
− | To get the behavior like i_CTRL-r in normal mode, use @=. For example, in normal mode, @='dd' |
+ | 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, 29 September 2008
created August 3, 2003 · complexity basic · author Yakov Lerner · version 6.0
The <CTRL-R>= things evaluates the expression. For example:
<CTRL-R>=12+34<CR>
<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:
map <CTRL-R>= :echo
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.
This is an expansion of Using Vim as calculator.
References[]
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.
For more information. You can also do things like
:let @a = 'dd'
and then press @a in normal mode. This does the same thing.