[英].vimrc file not working as expected
If I open a python file with vim, and set it to have a ruler and auto-line break with this command: 如果我用vim打开一个python文件,并使用此命令将其设置为具有标尺和自动换行符:
:set textwidth=109 colorcolumn=110
It works like a charm! 它就像一个魅力! However ... if I edit
~/.vimrc
and add this line at the bottom 但是......如果我编辑
~/.vimrc
并在底部添加此行
autocmd FileType py set textwidth=109 colorcolumn=110
exit the python file, and open it again, nothing happens. 退出python文件,再次打开它,没有任何反应。 Seems like something is overriding my setting, but can't figure out what is doing that (because I'm fairly new to vim).
似乎某些东西覆盖了我的设置,但无法弄清楚这是做什么的(因为我对vim相当新)。 My basic vimrc file is this: https://github.com/amix/vimrc/blob/master/vimrcs/basic.vim
我的基本vimrc文件是这样的: https : //github.com/amix/vimrc/blob/master/vimrcs/basic.vim
Can someone point me in the right direction on what am I doing wrong? 有人能指出我正确的方向,我做错了什么?
Note: the same thing is happening for Javascript files when I try to "replace" Tabs with 2 spaces in indentation: 注意:当我尝试在缩进中“替换”带有2个空格的Tabs时,Javascript文件也会发生同样的事情:
autocmd FileType js setlocal sw=2 sts=2 et
The issue is that the correct filetypes are python
and javascript
(or similar, like javascript.jsx
if you have additional syntax files), not py
and js
. 问题是正确的文件类型是
python
和javascript
(或类似的,如果你有其他语法文件,如javascript.jsx
),而不是py
和js
。 You can check the filetype used for a file by :set ft?
您可以通过以下方式检查用于文件的文件类型
:set ft?
. 。
Also, you may prefer setlocal
(to affect only the current buffer) instead of set
. 此外,您可能更喜欢
setlocal
(仅影响当前缓冲区)而不是set
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.