0

Please Note: I know how to turn the automatic newlines at the end of files on and off -- generally -- in Visual Studio Code. What I want is very specific way to change this behavior on demand.

I have set the defaults in VS Code to put newlines at the end of all files on save following the instructions here. However there is one file where this automatic newline breaks how the file works. Worse still, the file is of a file-type where usually I do want a newline at the end of the file. (If you care: it is an HTML file that the Hugo SSG uses to modify the behavior of the Markdown processor.)

What I am looking for is a way to be able to save this one particular file, without an automatic newline, by some keyboard shortcut or other easy to do bypass. What I have to do currently is go into the settings and turn off what is the preferred behavior for all other files, save the problematic file, then turn the defaults back on.

This may be too much of an edge case to fix easily with a shortcut, but it seems like something similar could come up enough that someone may have fixed it.

Doctorambient
  • 356
  • 3
  • 5
  • 1
    Wait, Hugo breaks if there's an extra newline at the end of the file? Are you sure? – Hong Ooi May 13 '21 at 05:31
  • No not generally. When you make a specific file to alter how the markdown preprocessor does something it breaks. Every other file I have dealt with is fine! I was following this: https://agrimprasad.com/post/hugo-goldmark-markdown/ and when there is a newline at the end of their `render-link.html` code it breaks. Specifically it adds the newline to every location that a link is rendered in the output HTML and this makes the text have extra spaces in it after every link. Removing the newline in `render-link.html` fixes it. This is why I need an override, for these rare exceptions. – Doctorambient May 15 '21 at 04:38

0 Answers0