[VS Code] remove trailing whitespaces upon save
Problem
You use VS Code. When you save a file, you want to remove trailing whitespaces automatically. In addition, you also want to see the trailing whitespaces, for instance in red.
Solution
For this purpose, I’ve used the extension Trailing Spaces by Shardul Mahadik for years. However, it stopped working correctly, so I looked after an alternative solution.
It turned out that VS Code can indeed remove trailing whitespaces (this feature was missing some years ago). However, it cannot visualize the trailing whitespaces, thus you still need an extension for that. The extension Trailing Whitespace by jkiviluoto can do that.
Thus, follow these steps:
- Install Trailing Whitespace by jkiviluoto (extension ID:
jkiviluoto.tws
) - Add these lines to your
settings.json
:
"files.trimTrailingWhitespace": true,
"tws.highlightTrailingWhiteSpace": true,
"tws.trimOnSave": false,
We’ll use tws just for highlighting the trailing whitespaces in red. The removal will be done by VS Code, using its built-in ability.
Edit your PDF files
Problem #1
You have a PDF file and you want to remove some pages from it. You want to do this job via a GUI interface.
Solution #1
You can use PDF Mod for this task.
“PDF Mod is a simple application for modifying PDF documents. You can reorder, rotate, and remove pages, export images from a document, edit the title, subject, author, and keywords, and combine documents via drag and drop.” (source)
It exists in the repositories, but if you want the latest version, install it from PPA:
sudo add-apt-repository ppa:pdfmod-team/ppa sudo apt-get update sudo apt-get install pdfmod
The PPA tip is from Ubuntu Geek.
Problem #2
You want to modify your PDF files from the command line.
Solution #2
Check out my post on pdftk.
Related links
- PyPdf module (Python)