1

I want to use one editor which is available across all the system. Someone told me VIM is best and i tried on ubuntu and VIM was not there but vi is there.

SO which one should i use

1
  • 1
    If you know how to use vim you will almost certainly be able to handle basic editing tasks using vi/nvi when needed.
    – Zoredache
    Jun 28, 2010 at 7:38

4 Answers 4

11

vi will be more common, but theyre not 100% the same. The basics are, yet vim (vi improved) is as the name suggests more advanced when it comes to features.

If you want to use an editor that is available at most systems, use vi. If you want to use one with more functions, use vim, but be prepared to install it or fall back to vi on certain systems where it is not installed. That being said, the basics really are the same so it shouldnt be too much of a hassle to fall back to vi when the need occurs.

http://en.wikipedia.org/wiki/Vim_(text_editor)#Features_and_improvements_over_vi

2
  • 2
    About the only place you'll find vi without an easy way to install vim is on some ancient godforsaken distro like Slackware...
    – Andrew
    Jun 28, 2010 at 7:25
  • 12
    And for admins who know there is more than just Linux distro's in the world, about every commercial Unix (eg AIX, Solaris and HP-UX) comes with just plain old Vi.
    – basvdlei
    Jun 28, 2010 at 9:08
2

Vim is an extended version of the vi editor. Vim will better for coding/scripting as it is aware of coding syntax of many popular languages.

1

In my experience, most distros alias vi to vim (RHEL certainly does, as has Ubuntu in the past (not on a current release, but expect it has not changed)).

0

I suggest installing and using Vim on systems you use frequently, especially if you plan to use it for coding. Vim offers many useful features not available in Vi, but the basic text manipulation commands will be the same, so you'll have no problems falling back to Vi when necessary.

You should also note that although Vi is installed by default in most (if not all) Unix-based systems, Vim is available for all these platforms, and has in addition been ported to more non-Unix systems than its older counterpart.

As for why you should consider Vim over Vi at all, here are some features to consider:

  • Built-in help system (the command :help).
  • Syntax highlighting (:syntax enable).
  • Unicode support.
  • Support for third-party plugins.
  • Unlimited undo. While Vi only supports one undo, you can configure the number of changes to remember in Vim (default is 1000).
  • Diff mode. Vim can be used to view the differences between two files, and to thus interactively merge those files. Useful in combination with a version control system like Git.
  • Visual mode. You can visually select a region of text before performing a command on it; similar to holding Shift and moving the arrow keys in most graphical text editors.
  • Autocompletion. Similar to tab-completion in modern shells; you use Tab to autocomplete colon commands, Ctrl+N to complete a word in the text, Ctrl+L to complete an entire line. The two latter commands offer completion based on the contents of the rest of the document.
  • Builtin spellchecker (enable with :set spell)
  • Tabs and multiple views (try :tabnew and :vsplit).
  • Text objects. This allows you to quickly select regions of text based on certain delimiter characters. For instance, if we place the cursor on the contents of the html tag <i>some text</i> and run the command dit (d'elete i'nside t'ag), we're left with <i></i>. If we used dat instead (d'elete a t'ag), the <i></i> tags would have been deleted as well. Similarly, you can delete the contents between double-quotes (di"), brackets (di[), or even entire paragraphs (dip).

For a more comprehensive list of differences, start up Vim in a terminal and run :help vi_diff.

You must log in to answer this question.