Friday, October 20, 2017

Re: how to apply a given map, written for a line, to a block of lines?

On Friday, October 20, 2017 at 5:29:53 PM UTC-5, Jose Caballero wrote:
> Hi,
>
> I would only need to know which key words I need to search in google... :)
> I have a few remaps (and iremaps) that modify the current line. For
> example, to add # at the beginning, and stuff like that.
> I would like to know how to re-use those mappings for a block of
> lines, not line by line.
> I am wondering if there is a way, for example, to apply it to a
> visually select block, or similar.
>
> Any clue, or link, where I can educate myself on this topic, would be
> appreciated.
> As I said, at this point, I don't even know which key to search with :help
>
> Thanks a lot in advance.
> Jose

Easy way (no extra effort): visually select the lines you want, and type ":normal " and then your mapping. You should see ":'<,'>normal ". Press enter to run the command on every line.

Harder way would be to create a visual mode mapping that somehow invokes the behavior you want on each line. Then for bonus points consider an operator-pending mapping.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: