如何使用 Ctrl + Shift + F 在 Visual Studio Code 中缩进/格式化所选代码 [英] How to indent/format a selection of code in Visual Studio Code with Ctrl + Shift + F

查看:32
本文介绍了如何使用 Ctrl + Shift + F 在 Visual Studio Code 中缩进/格式化所选代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Visual Studio Code 中缩进特定的代码部分.

I want to indent a specific section of code in Visual Studio Code.

我阅读了你如何在 Visual Studio Code 中格式化代码? 提供了缩进的快捷方式整个代码,但在选择特定代码部分时不起作用.

I read How do you format code in Visual Studio Code? that gives shortcuts to indent the whole code, but it doesn't work when selecting a specific section of code.

在选择代码中的某些行后,我尝试了 Ctrl + Shift + F,但整个文件都缩进了.我在 Windows 上使用 Visual Studio Code Insider 1.8.0.我该怎么做?

I tried Ctrl + Shift + F after selecting some line in my code, but the whole file is indented. I'm on Windows with Visual Studio Code Insider 1.8.0. How can I do it?

推荐答案

我想缩进 Visual Studio Code 中的特定代码部分:

I want to indent a specific section of code in Visual Studio Code:

  • 选择要缩进的行,然后
  • 使用 Ctrl + ] 来缩进它们.
    • Select the lines you want to indent, and
    • use Ctrl + ] to indent them.
    • 如果您想格式化一个部分(而不是缩进):

      If you want to format a section (instead of indent it):

      • 选择要格式化的行,
      • 使用 Ctrl + KCtrl + F 来格式化它们.
      • Select the lines you want to format,
      • use Ctrl + K, Ctrl + F to format them.

      这篇关于如何使用 Ctrl + Shift + F 在 Visual Studio Code 中缩进/格式化所选代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆