vi,重新安装后得到多个“对不起,该命令在此版本中不可用...”

Mic*_*ant 73 vim vi vimrc

从我的 .vimrc,得到:

line   16:
E319: Sorry, the command is not available in this version: filetype on
line   17:
E319: Sorry, the command is not available in this version: filetype plugin on
line   18:
E319: Sorry, the command is not available in this version: filetype indent on
line   21:
E319: Sorry, the command is not available in this version: syntax on
line   45:
E319: Sorry, the command is not available in this version: match ExtraWhitespace /\s\+$/
line   46:
E319: Sorry, the command is not available in this version: autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
line   47:
E319: Sorry, the command is not available in this version: autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
line   48:
E319: Sorry, the command is not available in this version: autocmd InsertLeave * match ExtraWhitespace /\s\+$/
line   49:
E319: Sorry, the command is not available in this version: autocmd BufWinLeave * call clearmatches()
Run Code Online (Sandbox Code Playgroud)

我可以删除这些行,但我宁愿知道我真正缺少什么或需要升级导致此问题的原因,因为该文件以前对我有用。

Rin*_*ind 104

从内部尝试vim...

:version
Run Code Online (Sandbox Code Playgroud)

如果你得到...

Small version without GUI.
Run Code Online (Sandbox Code Playgroud)

你缺少包vim-gui-common。也可能建议安装vim-runtime. 安装命令:

sudo apt-get install vim-gui-common
sudo apt-get install vim-runtime
Run Code Online (Sandbox Code Playgroud)

另一个原因可能是替代方案指向错误的:

update-alternatives --display vim
Run Code Online (Sandbox Code Playgroud)

显示使用的内容和...

update-alternatives --config vim
Run Code Online (Sandbox Code Playgroud)

更改为另一个 vim。它可能/usr/bin/vim.gnome是使用的,你需要/usr/bin/vim


编辑:迈克尔·杜兰特 (Michael Durrant) 用 #1 修复了它,以防万一有人想知道。

  • 如果你不想要 GUI,你可以只需要 `sudo apt-get install vim-nox`(然后 :version 会报告 `Huge version without GUI.`) (3认同)

wis*_*cky 19

你可能没有安装完整版的 VIM。要检查,请尝试执行vim或:

readlink -f `which vi`
Run Code Online (Sandbox Code Playgroud)

例如,Ubuntu 16.04 LTS 只附带 /usr/bin/vim.tiny

安装完整的 VIM:

sudo apt update
sudo apt install vim
Run Code Online (Sandbox Code Playgroud)

现在您应该拥有/usr/bin/vim.basic,并且.vimrc命令应该会成功。


Dan*_*iel 8

如果这是在您更新到 16.04 之后开始的,则可能是 @luka5z 指出的将 python 3 更改为默认解释器的 b/c。

为了解决,我从https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/clang-format.py更新到最新的 clang-format.py 文件

并编辑了以下内容的 .vimrc 行:

" Add hook for clang-format
map <C-K> ggVG :pyf /usr/local/bin/clang-format.py<cr>
imap <C-K> <c-o>:pyf /usr/local/bin/clang-format.py<cr>
Run Code Online (Sandbox Code Playgroud)

到:

" Add hook for clang-format
map <C-K> ggVG :py3f /usr/local/bin/clang-format.py<cr>
imap <C-K> <c-o>:py3f /usr/local/bin/clang-format.py<cr>
Run Code Online (Sandbox Code Playgroud)


小智 5

如果您通过运行其他命令(如crontab -e )出现错误,原因是您需要选择 vim 作为编辑器。将使用默认的 nano。所以只要运行select-editor,然后选择 vim ,问题就解决了。