Given the following strings each on a separate line (which I indicate by prefixing line numbers) with syntax specific indendation:1 Standard string with only text or code from some programming language.2          Standard string with only text or code from some programming language.3          Standard string with only text or code from some programming language.4          Standard string with only text or code from some programming language.5 Standard string with only text or code from some programming language.These are of course hard-wrapped lines. But sometimes* I would have such paragraphs as the one in the example displayed as one line while preserving the e.g. syntax specific indendation I got using Vim's = operator. Hence, I would like the paragraph to be visually wrapped with the same structure as the originally hard wrapped one:Standard string with only text or code from some programming language.         Standard string with only text or code from some programming language.         Standard string with only text or code from some programming language.         Standard string with only text or code from some programming language.Standard string with only text or code from some programming language.Is there a way to do this in Vim. I would prefer a simple command akin to {visual}gq.* The reason is mainly that I use Vim to send lines or paragraphs of code to a repl session (Python, R what have you).
Vim command to turn hard wrapped lines into visually wrapped lines with preserved formatting
vim;vimrc
In recent Vim 7.4 builds, you can:set wrap breakindentand have the soft-wrapped lines indented (controlled by the 'breakindentopt' option). However, that is a simple, fixed indent; you cannot dynamically influence this (as would be necessary to maintain the syntax).Alternatively, you can reformat (i.e. hard wrapping) with gq, and then :join or :undo that before sending it to the REPL.