CarCrazyBen
CarCrazyBen

Reputation: 1136

UNIX vi parameters

A co-worker passed me a snippet of his ".bashrc" file, which includes these 2 lines:

alias vi='vi -b -i NONE'
alias view='vi -b -i NONE -R'

I have searched for "UNIX vi parameters", "UNIX vi command line", and "vi arguments" but have not been successful.

What effect do the parameters -b, -i, -R, and NONE have on executing vi? Can anyone direct me to an online resource discussing these?

Thank you!

Upvotes: 1

Views: 993

Answers (1)

user812786
user812786

Reputation: 4430

Your coworker has set up some handy shortcuts for editing (vi) and reading (view) files.

Check man vi for the manual. https://linux.die.net/man/1/vi mirrors this info:

-b
Binary mode. A few options will be set that makes it possible to edit a binary or executable file.

-i {viminfo}
When using the viminfo file is enabled, this option sets the filename to use, instead of the default "~/.viminfo". This can also be used to skip the use of the .viminfo file, by giving the name "NONE".

-R
Read-only mode. The 'readonly' option will be set. You can still edit the buffer, but will be prevented from accidently overwriting a file. If you do want to overwrite a file, add an exclamation mark to the Ex command, as in ":w!". The -R option also implies the -n option (see below). The 'readonly' option can be reset with ":set noro". See ":help 'readonly'".

So: alias vi='vi -b -i NONE' will open vi, ready to edit binary files, and with no viminfo file. alias view='vi -b -i NONE -R' will do the same, but in read-only mode.

Upvotes: 2

Related Questions