为什么vi在Ubuntu中的行为与在CentOS中不同?

时间:2021-10-08 19:01:06

I've been getting more and more comfortable using vi on a daily basis, but one thing that bothers me is that when I use it on Ubuntu it behaves differently than when I use it on CentOS (and probably other places). I actually prefer the way it works in CentOS.

我每天都越来越习惯使用vi,但有一件困扰我的事情是,当我在Ubuntu上使用它时,它的行为与我在CentOS(以及其他地方)上使用时的行为不同。我实际上更喜欢它在CentOS中的工作方式。

Here are three things that are really bothering me on Ubuntu:

以下是在Ubuntu上困扰我的三件事:

  1. In CentOS insert mode there is a big bold notice at the bottom that I'm in INSERT mode, but in Ubuntu there is no notice so I can never tell which mode I'm in.

    在CentOS插入模式下,底部有一个大胆的通知,我处于INSERT模式,但在Ubuntu中没有通知,所以我永远不知道我在哪个模式。

  2. In CentOS insert mode I can press the up/down keys and the cursor will move up and down. But when I'm in Ubuntu pressing up and down inserts the letters A and B respectively on new lines.

    在CentOS插入模式下,我可以按向上/向下键,光标将上下移动。但是当我在Ubuntu上下按下时,分别在新行上插入字母A和B.

  3. In CentOS insert mode I can use the backspace key and it will delete the character that is before the cursor, but in Ubuntu I just hear a beep sound and nothing happens. I can press the delete key in command mode, but I'd rather be able to press the backspace key.

    在CentOS插入模式中,我可以使用退格键,它将删除光标前的字符,但在Ubuntu中,我只听到一声哔声,没有任何反应。我可以在命令模式下按删除键,但我宁愿能按退格键。

Are these differences something that I have to live with or is it an easy fix?

这些差异是我必须要忍受的还是一个简单的解决方案?

9 个解决方案

#1


In ubuntu, the default vim install comes from the package vim-tiny, which isn't the whole thing.

在ubuntu中,默认的vim安装来自vim-tiny包,这不是全部。

You probably want to:

你可能想:

apt-get install vim

or

apt-get install vim-full

Some of your other problems sound like issues with the backspace key and other things. Once you get the full version of vim, try adding these to your .vimrc:

您的一些其他问题听起来像退格键和其他问题。获得vim的完整版本后,请尝试将这些添加到.vimrc:

set nocompatible

set t_kb=^H
fixdel

(IMPORTANT NOTE: that ^H is a literal ctrl-H character, which you'll get by doing Ctrl-V Ctrl-H in insert mode)

(重要说明:^ H是一个文字ctrl-H字符,您可以通过在插入模式下按Ctrl-V Ctrl-H获得)

#2


The previously offered answers did not work for me.

之前提供的答案对我不起作用。

I tend to prefer leaving OS installations as stock as possible and keeping config files as simple as possible. In order to fix these three issues in Ubuntu 12.04, I did the following:

我倾向于将操作系统安装尽可能保留为库存并尽可能简化配置文件。为了解决Ubuntu 12.04中的这三个问题,我做了以下事情:

In "~/.vimrc", insert the lines -
set nocp
set bs=2

在“〜/ .vimrc”中,插入行 - 设置nocp set bs = 2

#3


In addition to installing vim-full, if you do not already hava a ~/.vimrc:

除了安装vim-full之外,如果你还没有使用〜/ .vimrc:

$ cp /usr/share/vim/vimcurrent/vimrc_example.vim ~/.vimrc

This example .vimrc already makes the most important settings and is a good start for customization.

此示例.vimrc已经成为最重要的设置,并且是自定义的良好开端。

#4


I'll assume you mean VIM when you say VI? And at least, the 2nd point seems to be a console/terminal issue with VIM/term combo. The page below suggests some fixes, but none that I could make work (I use vim over putty to an Ubuntu dev box)

当你说VI时,我会假设你的意思是VIM?至少,第二点似乎是VIM /术语组合的控制台/终端问题。下面的页面提供了一些修复,但没有一个我可以工作(我使用vim over putty到Ubuntu开发盒)

http://vim.wikia.com/wiki/Fix_broken_arrow_key_navigation_in_insert_mode

3rd point can be overwritten by using the following in your .vimrc

在.vimrc中使用以下内容可以覆盖第3个点

set backspace=indent,eol,start

#5


I personally like vim tiny and its controls -- much closer to the real vi. In some distributions you ONLY get 'vim' -- vim-tiny not available. In these I have found similar solutions -- to basic ones are -- steal vim-tiny from another distro or compile the real vi (code still available).

我个人喜欢vim tiny及其控件 - 更接近真正的vi。在某些发行版中,你只能得到'vim' - vim-tiny不可用。在这些我发现类似的解决方案 - 基本的 - 从另一个发行版窃取vim-tiny或编译真正的vi(代码仍然可用)。

Some of my issues with vim are its coloring -- most of which can be turned off but not all. The big issue is not reporting the line number on Ctrl-G for me this make full vim unusable -- I have not found a way around this one.

我对vim的一些问题是它的着色 - 其中大部分可以关闭但不是全部。最大的问题是没有报告Ctrl-G上的行号对我来说这使得完全vim无法使用 - 我还没有找到解决这个问题的方法。

Nearly all vim/vi issues could be addressed if both versions can were available with a vim install. If only vim-tiny is installed you can always up the install to the full vim -- however, for some unknown reason if the full vim is installed (Slackware versions) the vim-tiny is not available at all.

如果两个版本都可以通过vim安装获得,那么几乎所有的vim / vi问题都可以得到解决。如果只安装了vim-tiny,你可以随时安装到完整的vim - 但是,由于某些未知的原因如果安装了完整的vim(Slackware版本),vim-tiny根本不可用。

The full 'vim' should have a simple switch to drop to 'vim-tiny' the vi compatibility switch does NOT do this. This attitude by the vim developers has persisted for years -- their goal is to effectively a 'market share' concept i.e. to take over and direct the users options -- I'm NOT impressed.

完整的'vim'应该有一个简单的开关,可以放到'vim-tiny',vi兼容开关不会这样做。 vim开发人员的态度持续多年 - 他们的目标是有效地实现“市场份额”概念,即接管和指导用户选择 - 我没有留下深刻印象。

#6


(1) Check if showmode setting is different on both.

(1)检查两者的showmode设置是否不同。

(2) Don't know about this one, I think this has more to do with the terminal than Vi itself.

(2)不知道这个,我认为这与终端有关,而不是Vi本身。

(3) Maybe try using :map <BS> :normal d ?

(3)也许尝试使用:map :normal d?

#7


In CentOS, vi is an alias for a different program, vim, but in recent versions of Ubuntu, vi means just vi, not vim. The difference you see if the difference between two different programs, vi and vim.

在CentOS中,vi是不同程序的别名,vim,但在最新版本的Ubuntu中,vi仅表示vi,而不是vim。如果两个不同的程序vi和vim之间存在差异,你会看到差异。

If you like vim, just run vim, not vi. This works in Ubuntu too

如果你喜欢vim,只需运行vim,而不是vi。这也适用于Ubuntu

#8


Setting this in my .vimrc worked for me..

在我的.vimrc中设置这个对我有用..

set term=builtin_ansi

#9


I Have WDMyCLoud with Debian 7 inside, im using like:

我在内部使用Debian 7进行WDMyCLoud,即使用:

cp /usr/share/vim/vimcurrent/debian.vim ~/.vimrc

#1


In ubuntu, the default vim install comes from the package vim-tiny, which isn't the whole thing.

在ubuntu中,默认的vim安装来自vim-tiny包,这不是全部。

You probably want to:

你可能想:

apt-get install vim

or

apt-get install vim-full

Some of your other problems sound like issues with the backspace key and other things. Once you get the full version of vim, try adding these to your .vimrc:

您的一些其他问题听起来像退格键和其他问题。获得vim的完整版本后,请尝试将这些添加到.vimrc:

set nocompatible

set t_kb=^H
fixdel

(IMPORTANT NOTE: that ^H is a literal ctrl-H character, which you'll get by doing Ctrl-V Ctrl-H in insert mode)

(重要说明:^ H是一个文字ctrl-H字符,您可以通过在插入模式下按Ctrl-V Ctrl-H获得)

#2


The previously offered answers did not work for me.

之前提供的答案对我不起作用。

I tend to prefer leaving OS installations as stock as possible and keeping config files as simple as possible. In order to fix these three issues in Ubuntu 12.04, I did the following:

我倾向于将操作系统安装尽可能保留为库存并尽可能简化配置文件。为了解决Ubuntu 12.04中的这三个问题,我做了以下事情:

In "~/.vimrc", insert the lines -
set nocp
set bs=2

在“〜/ .vimrc”中,插入行 - 设置nocp set bs = 2

#3


In addition to installing vim-full, if you do not already hava a ~/.vimrc:

除了安装vim-full之外,如果你还没有使用〜/ .vimrc:

$ cp /usr/share/vim/vimcurrent/vimrc_example.vim ~/.vimrc

This example .vimrc already makes the most important settings and is a good start for customization.

此示例.vimrc已经成为最重要的设置,并且是自定义的良好开端。

#4


I'll assume you mean VIM when you say VI? And at least, the 2nd point seems to be a console/terminal issue with VIM/term combo. The page below suggests some fixes, but none that I could make work (I use vim over putty to an Ubuntu dev box)

当你说VI时,我会假设你的意思是VIM?至少,第二点似乎是VIM /术语组合的控制台/终端问题。下面的页面提供了一些修复,但没有一个我可以工作(我使用vim over putty到Ubuntu开发盒)

http://vim.wikia.com/wiki/Fix_broken_arrow_key_navigation_in_insert_mode

3rd point can be overwritten by using the following in your .vimrc

在.vimrc中使用以下内容可以覆盖第3个点

set backspace=indent,eol,start

#5


I personally like vim tiny and its controls -- much closer to the real vi. In some distributions you ONLY get 'vim' -- vim-tiny not available. In these I have found similar solutions -- to basic ones are -- steal vim-tiny from another distro or compile the real vi (code still available).

我个人喜欢vim tiny及其控件 - 更接近真正的vi。在某些发行版中,你只能得到'vim' - vim-tiny不可用。在这些我发现类似的解决方案 - 基本的 - 从另一个发行版窃取vim-tiny或编译真正的vi(代码仍然可用)。

Some of my issues with vim are its coloring -- most of which can be turned off but not all. The big issue is not reporting the line number on Ctrl-G for me this make full vim unusable -- I have not found a way around this one.

我对vim的一些问题是它的着色 - 其中大部分可以关闭但不是全部。最大的问题是没有报告Ctrl-G上的行号对我来说这使得完全vim无法使用 - 我还没有找到解决这个问题的方法。

Nearly all vim/vi issues could be addressed if both versions can were available with a vim install. If only vim-tiny is installed you can always up the install to the full vim -- however, for some unknown reason if the full vim is installed (Slackware versions) the vim-tiny is not available at all.

如果两个版本都可以通过vim安装获得,那么几乎所有的vim / vi问题都可以得到解决。如果只安装了vim-tiny,你可以随时安装到完整的vim - 但是,由于某些未知的原因如果安装了完整的vim(Slackware版本),vim-tiny根本不可用。

The full 'vim' should have a simple switch to drop to 'vim-tiny' the vi compatibility switch does NOT do this. This attitude by the vim developers has persisted for years -- their goal is to effectively a 'market share' concept i.e. to take over and direct the users options -- I'm NOT impressed.

完整的'vim'应该有一个简单的开关,可以放到'vim-tiny',vi兼容开关不会这样做。 vim开发人员的态度持续多年 - 他们的目标是有效地实现“市场份额”概念,即接管和指导用户选择 - 我没有留下深刻印象。

#6


(1) Check if showmode setting is different on both.

(1)检查两者的showmode设置是否不同。

(2) Don't know about this one, I think this has more to do with the terminal than Vi itself.

(2)不知道这个,我认为这与终端有关,而不是Vi本身。

(3) Maybe try using :map <BS> :normal d ?

(3)也许尝试使用:map :normal d?

#7


In CentOS, vi is an alias for a different program, vim, but in recent versions of Ubuntu, vi means just vi, not vim. The difference you see if the difference between two different programs, vi and vim.

在CentOS中,vi是不同程序的别名,vim,但在最新版本的Ubuntu中,vi仅表示vi,而不是vim。如果两个不同的程序vi和vim之间存在差异,你会看到差异。

If you like vim, just run vim, not vi. This works in Ubuntu too

如果你喜欢vim,只需运行vim,而不是vi。这也适用于Ubuntu

#8


Setting this in my .vimrc worked for me..

在我的.vimrc中设置这个对我有用..

set term=builtin_ansi

#9


I Have WDMyCLoud with Debian 7 inside, im using like:

我在内部使用Debian 7进行WDMyCLoud,即使用:

cp /usr/share/vim/vimcurrent/debian.vim ~/.vimrc