首页 > 解决方案 > 如何覆盖 Vim 中的默认缩进

问题描述

这似乎很简单。只需在 /home 文件夹中创建自定义 .vimrc 文件,然后粘贴如下内容:

filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab

但是还是有问题。在括号后按 ENTER 键,我仍然有 8 个空格而不是所需的 4 个。同时制表键给了我 4 个空格。

我还在 /etc/vim 中找到了一个默认的 vimrc 文件。有一个脚本:

" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
"  filetype plugin indent on
"endif

据此,如果我取消注释这些行,我最终会得到所需的四个空格,但我无法保存它,因为它是“只读的”。

我使用“没有 GUI 的巨大版本”版本 8.0,它应该支持开箱即用的 python3。我真的不知道如何绕过这么小的障碍。我已经杀死了一整天试图修复它。也许我作为初学者选择了错误的文本编辑器?但我喜欢 Vim 是因为它的极简主义,我想在掌握我的技能后获得它的力量。同时我需要一个工作工具——现在。不正确的缩进在我的路上是一个小但非常烦人的障碍。

标签: vimpython-3.6

解决方案


推荐阅读