6

I want to use ctrl+K ctrl+F in vscode to auto align my .cpp codes, but it doesn't work with hint "there is no selection formatter for 'cpp'-files installed", however, when I copy the code to Formatting part of Interactive Playground in vscode, it works. why? that's strange?

3
  • Similar to stackoverflow.com/q/71282125/1919793 Commented Oct 17, 2023 at 18:45
  • Indeed, on Mac version 1.99.1, it says the same thing on shift+alt+f, although clang-format is installed via brew (and you can run it from the terminal inside VScode), and the Microsoft C/C++ extension is installed. VSCode website says the extension comes with clang-format support. But no. And on clicking "install formatters" it lists the corresponding extensions: the C/C++ is at the top (and already installed), then clangd, etc. Commented May 10, 2025 at 18:54
  • yeah! in my case, intelliSenseEngine setting of the C/C++ extension was simply set to disabled. Commented May 10, 2025 at 19:00

2 Answers 2

3

try using

shift+alt+f

If it does not work Install Prettier format extension and set default formatter If still not work use Clang Formatter

Sign up to request clarification or add additional context in comments.

Comments

0

You need to install a beautifier extension that supports cpp. The best I've found is this: https://code.visualstudio.com/docs/languages/cpp Ctrl-Shift-X brings you to extensions, search for "beautify c++" and select "C/C++ 0.20.1" from the result list.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.