# Formatting Plain Text Copies in Vim I prefer to read long passages in Vim. So, I copy and paste from the Web into Vim. Sometimes, the plain text copy of an online document is difficult to read in Vim. Below are some advanced Vim commands to address specific issues. If you get unexpected results from running multiple commands, try running the commands in the order they appear here. In Vim, you can paste at the command line by pressing Ctrl-r and then + So, it is possible to copy and paste these commands without typing. Take care to include only one leading colon : in your commands. ## Separate Headings ``` Vim :%s/\S\n\zs\(\S\)/\r\1 ``` Here, \r will add a carriage return to the output. The above Vim command will add a blank line before headings. We go from this: ``` Text ... and terminal.integrated.tabs.defaultColor. Extended PowerShell keybindings ``` to this: ``` Text ... and terminal.integrated.tabs.defaultColor. Extended PowerShell keybindings ``` ## Add Line Breaks to Paragraphs ``` Vim :g/^\w.\{79,}\|^ \w.\{75,}\|^ \w.\{71,}/normal gqgq ``` The Vim command above will add line breaks to long paragraphs. I find this helps if, later, I use a linewise visual select while reading. Turn this paragraph with no line breaks: ``` Text There are additional PowerShell keybindings, such as Ctrl+Space, thanks to shell integration. These weren't possible before due to the lack of VT encoding. Provided that shell integration is working in pwsh, the following keybindings should now work: ``` into this paragraph with a line break at the end of each line: ``` Text There are additional PowerShell keybindings, such as Ctrl+Space, thanks to shell integration. These weren't possible before due to the lack of VT encoding. Provided that shell integration is working in pwsh, the following keybindings should now work: ``` ## References => https://code.visualstudio.com/updates/v1_70 Example Source Document => https://vimhelp.org/intro.txt.html#vim-modes Basic Information About Vim Modes (e.g. Normal Mode) => https://vimhelp.org/usr_20.txt.html Introduction to the Vim Command Line => https://vimhelp.org/cmdline.txt.html Command Line Reference => https://vimhelp.org/pattern.txt.html Manual Page for Regular Expressions in Vim => https://vimhelp.org/cmdline.txt.html#%3Arange The meaning of % in :%s/ | Vim Range => https://vimhelp.org/change.txt.html#%3As :s Command => https://vimhelp.org/repeat.txt.html#%3Ag :g Command => https://vimhelp.org/various.txt.html#%3Anormal :normal | Using Normal Mode Commands in Command-line Mode => https://vimhelp.org/change.txt.html#gq gq Command in Normal Mode => https://vimhelp.org/cmdline.txt.html#c_CTRL-R Ctrl-r in Command-line Mode => https://vimhelp.org/change.txt.html#registers Vim Registers (Clipboards) => https://vimhelp.org/usr_04.txt.html#04.4 Selecting Lines | Linewise Visual Select | Vim User Manual Created: Monday, August 15, 2022 Updated: Saturday, October 8, 2022