2

I know I can apply changes to multiple lines by selecting the lines in visual mode (I use ctrl-v) and defining the set of actions and the mode to start in (e.g. norma A, will add a comma at the end of all selected lines).

I was wondering how can I go back to normal mode after using something like A (which goes to insert mode). I'm not familiar with the terminology enough to google it properly.

I want to add a comma at the end of each line and then join all lines together. I assumed something like the following (not correct, obviously) should do it:

ctrl-v, G, :, normal A, normal J RET

But obviously this appends , normal J to each line.

I know there are plenty of other ways to do it (regular expressions, macros ...) so I don't need alternatives, that's not my question.

1
  • 1
    In this particular case, you don't need to use the blockwise selection. Thus you can do the following sequence: vG:norm! A,^]I+ (where ^] is the escape character as explained by @Nobe4). Apr 26, 2016 at 11:15

1 Answer 1

3

Well actually you can use a litteral <ESC> character to chain commands like you would do normally:

:'<,'>norm! A,^II+

This will insert a , at the end of each line, and a + at the start.

To add the special ^I char, press C-v and ESC.

1
  • 5
    You should use norm! instead of norm, in order to use standard mappings instead of user defined mappings (if there are conflicts). Apr 26, 2016 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.