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

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

问题描述

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

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

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

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代码中缩进一段特定的代码:

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 + K Ctrl + 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天全站免登陆