vim - vim 没有使用我的 ~/.vimrc 设置并在 python 代码中使用空格
问题描述
我在Windows 10上使用vim 8.1。这个 vim 带有git bash。
当我键入一个制表键时,我实际上得到了一个正确的制表符,8 宽,这就是我想要的。
但是,如果我编辑一个.py文件,而不是制表符,我得到 4 个空格。啊。为什么?
无论如何......我有我的 ~/.vimrc 说:
set tabstop=8
set ts=8
set shiftwidth=8
set gfn=Courier_New:h14:cANSI:qDRAFT
但是为什么不使用这个呢?
$ vi -V1
not found in 'runtimepath': "ftdetect/*.vim"
not found in 'packpath': "pack/*/start/*"
not found in 'packpath': "pack/*/start/*"
not found in 'runtimepath': "plugin/**/*.vim"
Reading viminfo file "/c/Users/abrahamstolk/.viminfo" info oldfiles
Press ENTER or type command to continue
当我使用时vi --version
,我看到 vim 声称正在阅读$HOME/.vimrc
,但它似乎没有这样做?
$ vi --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct 1 2019 05:31:13)
Included patches: 1-2104
Compiled by <alexpux@gmail.com>
Huge version without GUI. Features included (+) or not (-):
+acl -farsi -mouse_sysmouse -tag_any_white
+arabic +file_in_path +mouse_urxvt -tcl
+autocmd +find_in_path +mouse_xterm +termguicolors
+autochdir +float +multi_byte +terminal
-autoservername +folding +multi_lang +terminfo
-balloon_eval -footer -mzscheme +termresponse
+balloon_eval_term +fork() +netbeans_intg +textobjects
-browse +gettext +num64 +textprop
++builtin_terms -hangul_input +packages +timers
+byte_offset +iconv +path_extra +title
+channel +insert_expand +perl/dyn -toolbar
+cindent +job +persistent_undo +user_commands
-clientserver +jumplist +postscript +vartabs
+clipboard +keymap +printer +vertsplit
+cmdline_compl +lambda +profile +virtualedit
+cmdline_hist +langmap +python/dyn +visual
+cmdline_info +libcall +python3/dyn +visualextra
+comments +linebreak +quickfix +viminfo
+conceal +lispindent +reltime +vreplace
+cryptv +listcmds +rightleft +wildignore
+cscope +localmap +ruby/dyn +wildmenu
+cursorbind -lua +scrollbind +windows
+cursorshape +menu +signs +writebackup
+dialog_con +mksession +smartindent -X11
+diff +modify_fname -sound -xfontset
+digraphs +mouse +spell -xim
-dnd -mouseshape +startuptime -xpm
-ebcdic +mouse_dec +statusline -xsmp
+emacs_tags -mouse_gpm -sun_workshop -xterm_clipboard
+eval -mouse_jsbterm +syntax -xterm_save
+ex_extra +mouse_netterm +tag_binary
+extra_search +mouse_sgr -tag_old_static
system vimrc file: "/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/etc"
f-b for $VIMRUNTIME: "/usr/share/vim/vim81"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -I/usr/include/ncursesw -march=x86-64 -mtune=generic -O2 -pipe -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -pipe -fstack-protector-strong -pipe -Wl,--as-needed -o vim.exe -lm -lelf -lncursesw -liconv -lacl -lintl -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base -fstack-protector-strong -L/usr/lib/perl5/core_perl/CORE -lperl -lpthread -ldl -lcrypt
解决方案
在 Python 世界中,空间是首选,因此vim
编辑 Python 文件被配置为展开选项卡。
从技术上讲,这是通过这种方式完成的。Installedvim
有一个巨大的运行时库,其中包括文件类型插件。Python ftplugin设置expandtab
. 每次vim
检测到 Python 文件时都会加载 ft 插件。
推荐阅读
- c# - 静态 HttpClient 和 CookieContainer
- c - 如何在c中将指针分配给数组[]?
- c# - cefsharp 子进程退出或崩溃时的事件或通知
- c# - 通过MvvmCross的IoC给类的构造函数传参
- ssl - TLS 超时仅适用于 HTTP/2 时缺少 shutdown() 回溯
- dart - Future 在 Flutter 中结合 FutureBuilder 返回 null
- json - 创建单个 IAM 用户以仅访问特定的 S3 存储桶
- php - 为每个语句设置无序列表的样式
- visual-studio - 我可以或不可以在 Visual Studio 2017 中使用插件管理器吗?
- python - 计算与 Intel Realsense R200 深度摄像头的距离