combining the gq command

2018-05-01 16:35:30

I was wondering if it is possible to combine the gq operation with other commands, as one might do with the | operator. For example, it would be nice to be able to write a command like :'<,'>left4 |gq. However, vim says that gq in this context is not an editor command, because it is interpreting it as :gq. Is there any workaround?

You can run normal mode commands from the command-line with the :normal command.

In this instance, we want to first reselect the visual selection, and then run the gq command:

:'<,'>left4 | norm! gvgq

See :help :normal and :help gv for more details.

  • You can run normal mode commands from the command-line with the :normal command.

    In this instance, we want to first reselect the visual selection, and then run the gq command:

    :'<,'>left4 | norm! gvgq

    See :help :normal and :help gv for more details.

    2018-05-01 19:19:32