Marcin Szamotulski wrote:
> On 07:57 Wed 11 Apr , Jürgen Krämer wrote:
>>
>> vnoremap <c-j> @='jojo'<cr>
>> vnoremap <c-k> @='koko'<cr>
>
> Can you explain (or give :help hint) how @= works here that makes the trick.
@ executes the contents of a register and can be prefixed with a count.
So if you for example record a macro with
qqddjq
to delete one line and jump over the next line, you can execute this
macro 50 times by issuing
50@q
afterwards. Of 100 lines every other line will get deleted.
The = after the @ is the name of a special register, the Expression
register. You can learn about it at ":help @=". In short, if executed
interactively @= opens a prompt where you can input an expression. After
you press Enter the expression is evaluated and the result is executed
as Vim commands.
The difference between
vnoremap <c-j> jojo
and
vnoremap <c-j> @='jojo'<cr>
when used with a count is that
50<c-j>
with the first mapping expands to
50jojo
which first moves the last line of your visual selection 50 lines down,
but the first line will only be moved down one line, thus increasing
the size of your block by 49 lines.
The second mapping will expand to
50@='jojo'<cr>
which executes jojo 50 times.
Regards,
Jürgen
--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment