Vim,缩进不保存

标签 vim github

我只是仔细查看了我在 Vim 中编写的一些文件,并从本地 Git 存储库推送到了 Github。 Vim 中出现的大部分缩进并未转移到 Github。我需要更改 .vimrc 中的设置以确保保存 Vim 中的缩进吗?

最佳答案

听起来您可能正在使用制表符。制表符可以根据您使用的编辑器进行不同的解释,尽管看起来很奇怪,但它们根本不显示在 Github View 中。

我建议将制表符更改为空格。在 Vim 中,您可以使用“:”指定设置。

要让它们在 session 之间持续存在,您需要将其存储在名为 .vimrc 的文件中(只需使用“set”而不是“:”)。

To insert space characters whenever the tab key is pressed, set the 'expandtab' option:

:set expandtab

然后您可以指定制表符插入的空白字符数量:

To control the number of space characters that will be inserted when the tab key is pressed, set the 'tabstop' option. For example, to insert 4 spaces for a tab, use:

:set tabstop=4

我个人使用 tabstop=2

如果这不起作用,您是否可以发布包含您拥有的任何插件/配置的 .vimrc,以及 github 上该文件的链接,以便我们查看:)?

让我们知道你进展如何!

还重新;在文件上使用 cat - 尝试:

cat -A [filename]

这应该列出可能不是预期的隐藏字符。

关于Vim,缩进不保存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35442511/

相关文章:

git - 重启后的 Jenkins 在删除的分支上运行规范

用于更新 package.json 的 github 操作

windows - Git Fetch 在 windows 中返回 'fatal: I don' t handle protocol https'

vim脚本: can't echo newline after input and if statement

git - 如何在 Github Desktop 中将 fork 的仓库与原始仓库同步

java - 无法使用 IntelliJ 从 github 拉取项目

Vim 错误格式和 Spectrum lint

windows - VIM : How to map command according to buffer type?

vim - 在 Vim 中搜索并替换所有项目文件

vim - 在 GVIM 中,我们如何在保持先前搜索突出显示的同时进行搜索和突出显示