从 Atom 推送到 Github 时代码缩进关闭
Code Indentation is Off When Pushing to Github from Atom
我正在使用 Atom 作为编辑器并将我的代码推送到 Github,但某些缩进是随机关闭的。这太尴尬了。有人知道解决方法吗?
例如,在 Atom 中,一行如下所示:
render() {
if (this.state.error)
return <p>Please enter a valid user.</p>
if (!this.state.userData) return <p>Loading</p>
在 Github 上,同一行看起来像:
render() {
if (this.state.error)
return <p>Please enter a valid user.</p>
if (!this.state.userData) return <p>Loading</p>
当我从 github 复制并粘贴第二个代码片段时,它粘贴正确,与第一个片段相同,但在 github 中看起来很难看。我最近将我的制表符从 4 个空格重置为默认的 2 个,如果该信息对解决此问题有任何帮助的话。
尽量不要使用标签按钮来执行自动 2-space 或 4-space 操作,返回代码,将所有标签更改为 space,然后再试一次。
这是交叉污染 Python 2 和 Python 3 代码与不匹配的工作 spaces、文本编辑器、IDE 等时常见的错误。
您可能需要一直使用制表符或一直使用 spaces。
我正在使用 Atom 作为编辑器并将我的代码推送到 Github,但某些缩进是随机关闭的。这太尴尬了。有人知道解决方法吗?
例如,在 Atom 中,一行如下所示:
render() {
if (this.state.error)
return <p>Please enter a valid user.</p>
if (!this.state.userData) return <p>Loading</p>
在 Github 上,同一行看起来像:
render() {
if (this.state.error)
return <p>Please enter a valid user.</p>
if (!this.state.userData) return <p>Loading</p>
当我从 github 复制并粘贴第二个代码片段时,它粘贴正确,与第一个片段相同,但在 github 中看起来很难看。我最近将我的制表符从 4 个空格重置为默认的 2 个,如果该信息对解决此问题有任何帮助的话。
尽量不要使用标签按钮来执行自动 2-space 或 4-space 操作,返回代码,将所有标签更改为 space,然后再试一次。 这是交叉污染 Python 2 和 Python 3 代码与不匹配的工作 spaces、文本编辑器、IDE 等时常见的错误。 您可能需要一直使用制表符或一直使用 spaces。