“vim”标签相关文章 »

jul 31

平常在Unix(目前主要是FreeBSD)下主要是使用 Vim ,而Emacs由于在远程终端下没有Vim方便简洁,真正使用的时间不是很多。Vim,从名字也可以看出,应该是早期Unix下标配编辑器VI的进化物,所以,Vim的基本东西还是承袭自VI,如果你熟悉VI,使用Vim起来自然得心应手。

虽然很早就迁移到Vim了,但对基本的VI编辑器依然不能忘怀,从网上找了这篇VI参考手册,一来留存纪念,二则时常温习温习,必定受益颇多。

今天又重新学习了几个生僻的命令,多用多用,自然不生僻了,呵呵!

The vi is a text editor. It is small, powerful, and standard on most UNIX systems. The vi often frustrates new users with a unique distinction between its two modes: Command Mode and Insert/Overtype Mode. This distinction, although difficult to become accustomed to for many users, provides great power and ability to the editor. Insert/Overtype Mode is designed for inserting text only. All text manipulations and cursor moving should be done from with in Command Mode.

Entering the vi

  • prompt$ vi
  • prompt$ vi file1 file2 …
  • prompt$ vi -r file #Recover file from crash
  • prompt$ vi +string file #Execute ex command “string”
  • prompt$ vi @rcfile #Read commands from rcfile
Read more...»
dirk 发表于 2009-07-31 Friday
jul 31

Ubuntu 升级到7.04后发现一个很怪异的问题,在终端下执行 vi 或者 vim 并退出后,终端提示符以及后续输入的东西都会变成乱码,但使用 gvim 却没有问题。

刚开始以为是终端编码设置问题,倒腾了几次,失败;于是猜测是版本升级问题,当时也就不想花时间研究了,猜想估计下次升级就可以修正了。这样一直拖了半年的样子,在此期间,能用 Emacs 的就用 Emacs,实在简单的编辑就用一下 gvim。

今天想看看 vim 下语法高亮显示的问题,发现在 Ubuntu 下将符号链接用得很极致,大量命令都是通过 /etc/alternatives 下的符号链接来进行配置。然后就发现我的 vi 和 vim 都链接到了 /usr/bin/vim.python,看看 /usr/bin/ 目录,竟然基本的 vim 也是链接到此。我在想,应该有一个实现基本功能的 vim 吧。apt-cache 一把,发现我没有安装“vim”这个包,现有系统安装的都是额外的扩展程序,诸如 vim.python,vim.ruby,vim.gnome 等等。

OK,安装完“vim”这个包,多了一个 /usr/bin/vim.basic 这个程序,通过更改设置,将默认 vi 和 vim 链接到 vim.basic 此程序,解决 vi/vim 退出后终端乱码问题。

sudo update-alternatives --config vi
sudo update-alternatives --config vim

由此,编辑某些小东西不需要启动 gvim 和 emacs 这种大东西了。

dirk 发表于 2009-07-31 Friday