kuzyn
kuzyn

Reputation: 1995

vim/nvim line spacing when printing

I'm trying to use nvim for everything, including writing, and all is great but the text is too crammed when I print it out.

Is it possible to adjust the line spacing when printing with :hardcopy?

My idea of a kludge fix would be to insert a second newline character for every carriage return, including those automatically inserted by line wrapping. Is this possible?

Upvotes: 1

Views: 654

Answers (1)

herrbischoff
herrbischoff

Reputation: 3326

One of the least frustrating ways to do it would be to use a tool like pandoc to convert the text (for example Markdown) to whatever format you need — preferably PDF. However, pandoc uses LaTeX to create the resulting PDF, so regarding the styling you would have to tinker with supplying it a template or other options.

You can do it even easier with (for example) a Node.js tool called mdpdf. After installation, just run

mdpdf file.md --style styles.css

to supply it with a CSS stylesheet in which you can modify the resulting text output with every feature CSS permits. Using larger line spacing would be something like this:

body { line-spacing: 150%; }

This results in a 1.5x line spacing for everything in the document.

Of course, you can also set up a custom Vim command to automate this for you, putting something like the following into your .vimrc:

command MdToPDF !mdpdf %:t --style /full/path/to/styles.css

Calling :MdToPDF in Vim will then run that command for you.

Finally, if you're happy with the output, just print the PDF.

Upvotes: 1

Related Questions