Shift alt f vs code не работает

v 0.19.0 Code Formatting (Shift + Alt + F) doesn’t work. #2668

Comments

8059542577066 commented Oct 15, 2018

Type: LanguageService

Describe the bug

  • OS and Version: Windows 7 Ultimate SP1 64-bit
  • VS Code Version: 1.28.1
  • C/C++ Extension Version: 0.19.0
  • Other extensions you installed (and if the issue persists after disabling them): None
  • Code Formatting (Shift + Alt + F) that worked in version 0.18 doesn’t work at all. After updating to 0.19, pressing the key combination or and Click Format Document, both don’t work. No Error message shows up. Nothing happens.
  • I liked the VS style formatting so i never attempted to alter any parameters myself, and I just used the auto formatting which came with cpptools by default.

To Reproduce

  1. Install cpptools v 0.19.0 from extensions.
  2. Click (Shift + Alt + F) combination to auto format the file.
  3. Nothing happens.

The text was updated successfully, but these errors were encountered:

greennerve commented Oct 16, 2018

Same problem here on linux

Describe the bug

OS and Version: Ubuntu 18.04
VS Code Version: 1.28.1
C/C++ Extension Version: 0.19.0
Other extensions you installed (and if the issue persists after disabling them): Python

Install cpptools v 0.19.0 from extensions.
Click (Shift + Alt + F, Ctr + Shift + i, Ctr + K then F on selection) combination to auto format the file.
Nothing happens.

8059542577066 commented Oct 17, 2018

I had to roll back to version 0.18.1 in which auto formatting still worked. While testing with the functionality I found a workaround for auto formatting.

I noticed when this extension is installed clang-format 6.0 program was installed with it.
C:\Users\YOUR_USERNAME\.vscode\extensions\ms-vscode.cpptools-0.18.1\LLVM\bin\clang-format.exe
Apparently this clang-format.exe is run when Shift + Alt + F keys are pressed from VS Code.

So I tried below testing method to find out the parameters passed to clang-format:

  1. In the clang-format directory given above move clang-format.exe so some other location
  2. Open .c file with VS Code
  3. Open Terminal by pressing Ctrl + Shift + `
  4. When terminal window opens on the bottom, select OUTPUT tab, and select C/C++ from the drop down menu
  5. Click anywhere in the code editor and press Shift + Alt + F to format
  6. Formatting won’t work but it produces the error message like this:
  7. We can modify the command shown in the error message output and use it to format the document ourselves.
  8. Try this command: clang-format.exe -style=»< BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Allman, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0 >» -fallback-style=»LLVM» -sort-includes=0 «Input File.c» > «Output File.c»

Although in this method you can’t format while working within VS code, but the formatted results are the same. I hope this helped.

Читайте также:  Как настроить электронные часы китайского производства

Источник

Как вы форматируете код в Visual Studio Code (VSCode)

Что эквивалентно Ctrl + K + F и Ctrl + K + D в Windows в Visual Studio для форматирования или «украшения» кода в редакторе кода Visual Studio?

Форматирование кода доступно в Visual Studio Code с помощью следующих ярлыков:

  • В Windows Shift + Alt + F
  • На Mac Shift + Option + F
  • В Linux Ctrl + Shift + I

Кроме того, вы можете найти ярлык, а также другие ярлыки, с помощью «Палитры команд», предоставленной в редакторе с помощью Ctrl + Shift + P (или Command + Shift + P на Mac), а затем выполнить поиск формата документа .

Ярлык форматирования кода:

Visual Studio Code для Windows — Shift + Alt + F

Код Visual Studio на MacOS — Shift + Option + F

Код Visual Studio в Ubuntu — Ctrl + Shift + I

Вы также можете настроить этот ярлык, используя настройки предпочтений, если это необходимо.

Форматирование кода при сохранении файла:

Visual Studio Code позволяет пользователю настраивать параметры по умолчанию.

Если вы хотите автоматически отформатировать содержимое во время сохранения, добавьте приведенный ниже фрагмент кода в настройках рабочего пространства кода Visual Studio.

Файл меню → Настройки → Настройки рабочего пространства

Примечание: теперь вы можете автоматически форматировать файлы TypeScript. Проверьте мое обновление.

Источник

Как форматировать код в Visual Studio Code (VSCode)

что эквивалентно Ctrl + K + F и Ctrl + K + D в Windows в Visual Studio для форматирования или» украшения » кода в редакторе кода Visual Studio?

30 ответов

форматирование кода доступно в VS Code через следующие ярлыки:

  • На Windows Shift + Alt + F
  • На Mac Shift + опции + F
  • На Ubuntu Ctrl + Shift + Я

кроме того, вы можете найти ярлык, а также другие ярлыки, через поиск функциональность, предоставляемая в редакторе с Ctrl + Shift + P (или команда + Shift + P на Mac), а затем поиск документ в формате.

Ярлык Форматирования Кода:

Читайте также:  Капельный полив не работает какова причина

VSCode в Windows — Shift + Alt + F

VSCode на MacOS — Shift + опции + F

VSCode на Ubuntu — Ctrl + Shift + Я

вы также можете настроить этот ярлык через настройки, если это необходимо.

Форматирование Кода Сохранение файла:

Visual Studio code позволяет пользователю настраивать параметры по умолчанию.

Если вы хотите автоматически форматировать содержимое при сохранении, добавьте этот фрагмент кода ниже в параметры рабочего пространства кода visual studio.

Файл —> Настройки — > Настройки Рабочего Пространства

Примечание: теперь вы можете автоматически форматировать файлы typescript проверить мое обновление

вы можете добавить привязку клавиш в Файл —> Настройки —> Клавиатура ярлыков.

Источник

Как форматировать код в Visual Studio Code (VSCode)

что эквивалентно Ctrl + K + F и Ctrl + K + D в Windows в Visual Studio для форматирования или» украшения » кода в редакторе кода Visual Studio?

30 ответов:

форматирование кода доступно в VS Code с помощью следующих ярлыков:

  • На Windows Shift + Alt + F
  • На Mac Shift + опции + F
  • На Ubuntu Ctrl + Shift + Я

кроме того, вы можете найти ярлык, а также другие ярлыки, через поиск функциональность, предоставляемая в редакторе с Ctrl + Shift + P (или команда + Shift + P на Mac), а затем поиск документ в формате.

Контекстное Форматирование Кода:

VSCode на Windows — Shift + Alt + F

VSCode на MacOS — Shift + опции + F

VSCode на Ubuntu — Ctrl + Shift + Я

вы также можете настроить этот ярлык через настройки, если это необходимо.

Форматирование Кода В То Время Как Сохранение файла:

Visual Studio code позволяет пользователю настраивать параметры по умолчанию.

Если вы хотите автоматически форматировать содержимое при сохранении, добавьте этот фрагмент кода ниже в настройках рабочего пространства visual studio code.

File — > Preferences —> Workspace Settings

Примечание: теперь вы можете автоматически форматировать файлы typescript проверить мое обновление

вы можете добавить привязку клавиш в Файл —> Настройки —> Клавиатура ярлыков.

или Visual Studio как:

правильная комбинация клавиш shift + alt + f

также обратите внимание, что на сегодняшний день форматирование доступно для этих языков:

VS Code 1.6.1 поддерживает «Формат При Сохранении » который будет автоматически подбирать соответствующие установленные расширения форматирования и форматировать весь документ на каждом сохранении.

включить «формат при сохранении», установив

Читайте также:  Как настроить каналы sky vision

и есть доступные сочетания клавиш (VS Code 1.7 и выше):

форматировать весь документ: Shift + Alt + F

только выбор формата: Ctrl K + Ctrl F

На Linux Ctrl + Shift + Я . На Windows Alt + Shift + F . Протестировано с HTML / CSS / JS и VsCode 1.18.0.

для других языков может потребоваться установить определенный языковой пакет.

  1. щелкните правой кнопкой мыши на файл
  2. Выберите Формат Документа ( Alt + shift + f ) из меню.

на ubuntu это Ctrl + Shift + Я

Источник

VS code Format Code command and shortcut Shift+Alt+F doesn’t work

Any clues on why my VS Code «Format Code» command doesn’t work? I used Shift+Ctrl+P and entered Format Code or used the shortcut Shift + Alt + F . None seem to be working. Any clue?

9 Answers 9

I guess you are asking for MacOs because by default shortcut for code formatting is different for different Os. Now there might be an issue with the keyboard layout. For example Option+Shift+F does not work in ABC-Indian layout, you need to change that. Go to System-prefrences->Keyboard->Input Sources-> Add layout «ABC» and delete the old one.

For me, CTRL SHIFT i worked on Ubuntu 20.04

i’m having the same issue — it’s looks like a bug.

If you have an error in your code, the formatting will not allow you to change the layout. Fix any bugs you have (if you have any of course) then try shift + alt + f .

The bug is partially fixed in v1.6.0.

You may still face this issue as the patch is not for all keyboard layouts. Switching keyboard layout to English(US) solved the problem for me.

The issue is open on github.

You need to set the default formatter in your VS Code.

Click Cmd+Shift+P, and choose «Format Document With. «

Then, instead of choosing a formatter, choose «Configure Default Formatter. «

And then choose your default formatter that works for you

It will now work and format the document when you click SHIFT+OPTION+F (or Shift+Alt+F in Windows). My default formatter was configured to Prettier ESlint instead of Prettier — Code Formatter and it didn’t work. The shortcut worked only after changing the default formatter to Prettier — Code Formatter .

Источник

Оцените статью