在_vimrc中 set noexpandtab python 不起效果
2016-11-16 16:43
344 查看
我ctm,今天配置不让tab转为空格,在_vimrc中set noexpandtab 不起效果。
set ts=4也不起效果。
但是在命令行中其效果。
我都不知道咋办了。
问人说我有可能使用的不是那个目录下的_vimrc
检查了,没问题。
后来在网上搜了半天都没找到原因。
最后,机智的我用英文搜了一下,
windows _vimrc set noexpandtab do not work
居然找到答案了。
大意就是使用了python插件,里面有一个什么标准,会在加载_vimrc之后去加载,所以就把它覆盖了。
就这么简单,下面是网址。
http://stackoverflow.com/questions/21073496/why-does-vim-not-obey-my-expandtab-in-python-files
set ts=4也不起效果。
但是在命令行中其效果。
我都不知道咋办了。
问人说我有可能使用的不是那个目录下的_vimrc
检查了,没问题。
后来在网上搜了半天都没找到原因。
最后,机智的我用英文搜了一下,
windows _vimrc set noexpandtab do not work
居然找到答案了。
大意就是使用了python插件,里面有一个什么标准,会在加载_vimrc之后去加载,所以就把它覆盖了。
就这么简单,下面是网址。
http://stackoverflow.com/questions/21073496/why-does-vim-not-obey-my-expandtab-in-python-files
11down voteaccepted | The problem is that your settings are being overridden by a filetype plugin that's part of Vim. The issue is in ftplugin/python.vim: " As suggested by PEP8. setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8 The python plugin attempts to setup your source code to be PEP8 compliant by default, so it's adjusting the tabstop. You'll want some of what these plugins have to offer, but you may need to setup your own autocommands to fixup anything you don't like. There are two ways to go about doing this. If you have a ~/.vimfolder, the easiest way is to add the file ~/.vim/after/ftplugin/python.vim: " Here, you can set the setting directly, or call a command or function " to help you. We'll call a command, and then implement that command in " your top-level vimrc to help keep things in one place. SetupPython In your .vimrc, add: function! SetupPython() " Here, you can have the final say on what is set. So " fixup any settings you don't like. setlocal softtabstop=2 setlocal tabstop=2 setlocal shiftwidth=2 endfunction command! -bar SetupPython call SetupPython() The latter bit just allows you to call the function as SetupPythonrather than call SetupPython()in the after file. The other way, is to keep everything in your .vimrc, but you use the VimEnterautocommand to setup a FileType autocommand for python to set your preferences. By waiting until VimEnteris triggered, all the other plugins will have had time to setup their autocommands, so your's will be added to the end of the list. This allows you to run after the python plugin's FileTypeautocommand and set your own settings. This is a bit of a mess though, and the after/mechanism above is the preferred way of doing this. FWIW, many common settings I keep in a SetupSource()function to be called from a number of different FileTypes. Then I'd have SetupPython()call SetupSource(). This helps to keep the specific functions a little cleaner and reduce some duplication. If it helps, take a look at the functions in my vimfiles here: https://github.com/jszakmeister/vimfiles/blob/master/vimrc#L5328 |
相关文章推荐
- python2 实现的LED大数字效果
- 贴一下我的 vimrc 以及 vim 效果
- 完整版本 .vimrc for python env
- 使用python实现省市三级菜单效果
- python实现基于两张图片生成圆角图标效果的方法
- 尝试自己的Perl语言的包 TCP协议的再包装起到类似python语言装饰器的效果
- debian下vim设置调试python 以及我的.vimrc
- 飘逸的python - 实现控制台进度条效果
- python tkinter用Treeview实现ListView效果
- Python中实现乒乓球效果
- /etc/vimrc for python
- vimrc配置-中文编码和python中的中文注释
- python vimrc
- python3.2 实现在同一行打印,实现进度条效果
- Linux环境.vimrc 设置,自动添加Python源文件头信息
- use python in vim script of ~/.vimrc
- 怎样用Vi 编程3 附有 自己主写python的VIMRC :)
- 基于KNN算法的约会网站配对效果 python3.2
- python通过pil将图片转换成黑白效果的方法
- python_numpy,在命令窗口python.exe和python shell中的效果不一样?