粘贴代码时 Sublime text 3 错误解释缩进

Sublime text 3 misinterpreting indentation when code is pasted

喜欢 Sublime 文本,尽管我在复制代码时遇到了一个似乎不一致的问题。我使用 tab 进行缩进,当我需要复制代码时,它似乎试图将制表符解释为 spaces,但导致发送的缩进不稳定。

我知道您可以进入设置,我也这么做了,并更改 tab_sizetranslate_tabs_to_spaces 等属性的值,但似乎没有什么可以阻止它发生。这些行不是缩进 4 space,而是只有一个 space,当我点击 tab 时,它移动了一个 space。

问题

如何强制 Sublime 每次创建新文档时仅使用 tab 缩进,当前设置为 4 spaces?

你没有告诉我们你是如何粘贴代码的,所以我假设你正在做一个简单的粘贴,而不是使用 Shift 的 Sublime Text 方式:

Sublime’s Paste and Indent command fixes this by automatically adjusting the indentation of your pasted code to match the surrounding lines.

This command is bound to Ctrl+Shift+V on Windows and Linux or Shift+Cmd+V on Mac. Give it a try—it’s magical.

我知道现在回答为时已晚,但对于@jwpfox 的回答,您可以像这样在键绑定中切换它:

{ "keys": ["super+shift+v"], "command": "paste" },
{ "keys": ["super+v"], "command": "paste_and_indent" },

如果您想默认使用 paste and indent,您可以切换这 2 个键绑定。