vim"语法开启"不起作用

Jac*_*kWM 13 vi vim opensuse

这是我的 .vimrc

  1 syntax on
  2 set ts=4
  3 set number
  4 set smartindent
  5 set shiftwidth=4
Run Code Online (Sandbox Code Playgroud)

但是,我试着编辑HelloWorld.javaHelloWorld.c.两者都有纯正的黑色字体.没有任何突出显示!

:syntax onvim打开后我也试过了,但没有运气.

\>vim -version
VIM - Vi IMproved 7.3 (2010 Aug 15)

\>cat /etc/*-release
openSUSE 11.4 (x86_64)
VERSION = 11.4
CODENAME = Celadon
Run Code Online (Sandbox Code Playgroud)

mso*_*uth 15

编辑文件时,您使用的是

vim filename
Run Code Online (Sandbox Code Playgroud)

这很重要.在某些服务器配置中,如果你vi filename得到vim,但它是一个非常简化的vim版本,它与原始的vi非常相似.如果您改为输入vim filename,则会获得全功能的vim.

我刚刚与一个安装了vim-minimal软件包的服务器以及另一个vim软件包的人一起完成了这项工作.我怀疑(但没有验证)vim-minimal软件包安装了它的可执行文件/bin/vi.

当你查看实际文件(即ls -l /bin/vivs ls -l /usr/bin/vim)时,差异非常明显- 一个是大小的十倍.它们实际上都是vim,相同的版本号和所有内容,但/ bin/vi编译时启用了很少的功能.

使它更令人困惑:

vi existing.pl
Run Code Online (Sandbox Code Playgroud)

打开.pl文件,没有给出语法着色

vi [enter]
Run Code Online (Sandbox Code Playgroud)

给了vim启动画面,并从那里

:e existing.pl
Run Code Online (Sandbox Code Playgroud)

用语法着色打开文件.


小智 5

您需要vim-data在openSUSE 上安装软件包才能使用vim语法着色.听起来很奇怪,我知道默认情况下这不是vim包,而是AFAIK,它适用于想要创建微小基础安装的人.包vim-data包含运行时文件.

还要确保你的远程环境有一个合适的TERM变量设置TERM = screen-256color,TERM = xterm,TERM = xterm-256color应该可以正常使用ssh和ssh与screen/tmux.


Ken*_*ent 2

在你的中.vimrc,我没有看到filetype设置。你可以尝试添加:

filetype plugin indent on 
Run Code Online (Sandbox Code Playgroud)

到你的 vimrc.

如果没有set nocp,也添加此行。

如果你读过:h filetype

:filetype on

Each time a new or existing file is edited, Vim will try to recognize the type
of the file and set the 'filetype' option.  This will trigger the FileType
event, which can be used to set the syntax highlighting, set options, etc.
Run Code Online (Sandbox Code Playgroud)