Skip to main content
30 votes

What are the differences between :wq<cr> :x<cr> and ZZ when exiting vim?

As akshay pointed out, Vim's documentation explains, that :x and ZZ are equivalent and only save a file if the associated buffer has been changed. Whereas :wq saves the buffer to the corresponding ...
m4110c's user avatar
  • 451
21 votes

Why is Y a synonym for yy instead of y$?

Y was the yank command of the first vi version (ex-1.1, January 1, 1978). This version did not have the yy cammand. ex-2.2 (May 6, 1979) did have both yy and Y. So actually yy is a synonym for Y (Y ...
user3224237's user avatar
5 votes
Accepted

Why does vi sometimes use harder-to-reach keys?

Bill Joy (the original author of vi) explains this in An Introduction to Display Editing with Vi. The [[ and ]] operations require the operation character to be doubled because they can move the ...
Mass's user avatar
  • 14.2k
5 votes

What is the relation between vi, nvi and vim?

The roots of the family trees of vi clones seem to be: 1977: "Traditional vi", Bill Joy's original source, ported and free to use since 2002. 1985: microEmacs, from which the vi-alike "...
martinwguy's user avatar
4 votes

What are differences between POSIX vi and minimal vi implementations, if any?

is Vim minimal (i.e. the default vi on Cygwin) basically a POSIX compliant implementation of vi? No. The vi in Cygwin's vim-minimal package still has features not defined by POSIX. I've verified the ...
Warren Young's user avatar
4 votes

Biggest differences between Vim and vi

The Vim FAQ has a well formatted list: https://vimhelp.org/vim_faq.txt.html#faq-1.4 Excerpt from the FAQ: Multi-level undo Tabs, Multiple windows and buffers Flexible insert mode (can use arrow ...
wisbucky's user avatar
  • 960
4 votes

Biggest differences between Vim and vi

Most comparisons give more functionality to Vim than to vi, but there is one exception. There was an "open" mode in vi, and Vim doesn't really have this mode. Open mode is a single-line mode that was ...
gracious1's user avatar
  • 293
3 votes
Accepted

How do I map a key to search for a pattern and replace it with newline in ex/vi?

This will be a bit convoluted, but, try: :map q :%s/Name. /\^V^V^M&/g^M Each ^x is produced by pressing CtrlVCtrlx, so the actual sequence here is: CtrlV CtrlV for the first ^V, CtrlV CtrlV for ...
muru's user avatar
  • 25k
3 votes

Use ex-command to check whether two lines are identical?

Vim In Vim you can match any character including newline with \_.. You can use this to construct a pattern that matches a whole line, any amount of stuff, and then that same line: /\(^.*$\)\_.*\n\1$/...
Antony's user avatar
  • 2,590
3 votes

Why is ] used for tag navigation?

vi was designed for use with glass terminals, the protocols of which often use many of the control-x commands down at the low end of ASCII. Others were reassigned in the move from paper terminals, ...
Warren Young's user avatar
3 votes
Accepted

How to remap escape in *vi* (not vim)?

The key syntax with brackets, such as <Esc>, is specific to Vim. In plain vi, you need to enter an actual ESC character in your mapping. You can do so by pressing Ctrl+V, followed by ESC, ...
filbranden's user avatar
  • 29k
3 votes

what is the difference between calling vim by typing vi and typing vim

If you want to run Vim, then type vim. ☺ On a more serious note, most of the Linux distributions provide different builds of Vim, with varying feature levels (i.e., the --with-features=... argument ...
jamessan's user avatar
  • 11.1k
3 votes
Accepted

What are the compatibility differences between the two modelines?

The original Vi does support modelines of the second form, however, modelines has to be set before the file is read. The manpage of ex says: modelines, ml default: nomodelines If modelines ...
muru's user avatar
  • 25k
3 votes
Accepted

Original vi (version 1.1): Copy lines to alternate file without using named buffer

When I used to use a real vi, I'd write to and read from a file, like you mention in your comment. I had something like this in my .exrc: ab wtemp w !/bin/cat > ~/temp ab rtemp r !/bin/cat ~/temp ...
Antony's user avatar
  • 2,590
3 votes
Accepted

How to search for a pattern that starts at newline in ex/vi

In original vi, and in tools with POSIX BRE or ERE, there's no way to look for strings not at the beginning of the line. However, in all of these, you can use regex groups to match any character ...
muru's user avatar
  • 25k
2 votes

What are differences between POSIX vi and minimal vi implementations, if any?

What other common 'minimal' vi's exist? There is also xvi.sf.net mantained at github.com/martinwguy/xvi which is a different implementation based on STEVIE. It's the smallest full-featured vi clone ...
martinwguy's user avatar
2 votes

Fix arrow keys displaying A, B, C, D in vi (not in vim)

You could create an alias that sets your $TERM variable alias vi='TERM=rxvt-unicode-256color vi' Add that to your shell's rc file and it should be defined for every terminal you launch.
jecxjo's user avatar
  • 2,700
2 votes

How to search for a pattern that starts at newline in ex/vi

You could use a negative lookbehind: \(^\)\@<!Name\d \( \) Are special matching parentheses ^ Is beginning of line, of course \@<! is a negative lookbehind. Essentially, if it finds what's ...
Tumbler41's user avatar
  • 7,756
2 votes
Accepted

How to clear a vim register (vi/ex buffer)?

So it turns out that all Vi clones are, well, different. For example, 0"ayh clears register "a" in Vim, but not in Elvis; while 0"ad0 works in Elvis, but not in Vim. As Busybox seems to ship "Vi" of ...
Matt's user avatar
  • 20.8k
2 votes

why wont vi recognize html?

As mentioned by Christian Brabandt, the OP has small vim. The solution is to install the vim package. One can usually tell the difference with vim --version.
2 votes
Accepted

vi Specification

One such standard is the POSIX standard for vi and for ex which are too long to include here.
D. Ben Knoble's user avatar
  • 26.6k
1 vote
Accepted

Automate Enumeration in vi

Vi didn't have Vim's <C-a> or g<C-a> or \= or expressions or any kind of scripting, etc. so all the slick Vim methods are basically irrelevant. The "Improved" in "Vi ...
romainl's user avatar
  • 41.2k
1 vote
Accepted

Removing a line that ends with a " : " with vi (on AIX)

Unless the character is special, the command :g/:$/d (abbreviated from :global/:$/delete) should do it. Perhaps you meant the line ends with ":", in which case simply change /:$/ to /":&...
D. Ben Knoble's user avatar
  • 26.6k
1 vote

Why is the cursor not visually positioned on the first column when it is on the first column of an indented line?

Hard tab is a single character. Eight spaces are displayed on screen but they are not a part of a buffer. Just like those trailing spaces after line ends. In Vim if you want the cursor to move through ...
Matt's user avatar
  • 20.8k
1 vote
Accepted

What is the correct cursor position when a } (forward paragraph motion) reaches the last line of the buffer?

POSIX has this to say on the matter (emphasis added by me): Return to Previous (Context or Section) The [[, ]], (, ), {, and } commands are all affected by "section boundaries", but in some ...
Mass's user avatar
  • 14.2k
1 vote

Why is ] used for tag navigation?

I can't speak to the history of the command, but I think of [ and ] as previous and next. It's used for many motions. See help various-motions for several examples of square bracket motions. ...
ddrscott's user avatar
  • 441
1 vote

Fix arrow keys displaying A, B, C, D in vi (not in vim)

Sometimes such behaviour can result from unusual key mappings setup in your .vimrc - so for example if you have something that maps two ESC key presses: nmap <Esc><Esc> ...
Pierz's user avatar
  • 111
1 vote

Can I undo multiple times in nvi and/or the original vi?

The closest thing the original vi has to multiple undo (aside from U which can revert multiple changes within a single line) is the numbered registers, which hold the nine most recent changes or ...
Antony's user avatar
  • 2,590

Only top scored, non community-wiki answers of a minimum length are eligible