OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

Starting And Stopping vi

To start vi, we simply enter the following:


[me@linuxbox ~]$ vi

[me@linuxbox ~]$ vi


image

VIM - Vi Improved


version 7.1.138

by Bram Moolenaar et al.

Vim is open source and freely distributable


Sponsor Vim development!

VIM - Vi Improved


version 7.1.138

by Bram Moolenaar et al.

Vim is open source and freely distributable


Sponsor Vim development!

type

type

:help sponsor<Enter>

:help sponsor<Enter>

for information

for information

type

type type

type

type type

:q<Enter>

:help<Enter>

:q<Enter>

:help<Enter>

or <F1>

or <F1>

:help version7<Enter>

:help version7<Enter>

to exit

for on-line help for version info

to exit

for on-line help for version info

Running in Vi compatible mode

Running in Vi compatible mode

type

type

:set nocp<Enter>

:set nocp<Enter>

for Vim defaults

for Vim defaults

And a screen like this should appear:


~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~

~


~

~

~

~

type :help cp-default<Enter> for info on this

~

~

~

~


image

Just as we did with nano earlier, the first thing to learn is how to exit. To exit, we enter the following command (note that the colon character is part of the command):



:q

:q


The shell prompt should return. If, for some reason, vi will not quit (usually because we made a change to a file that has not yet been saved), we can tell vi that we really mean it by adding an exclamation point to the command:



:q!

:q!


image

Tip: If you get “lost” in vi, try pressing the Esc key twice to find your way again.


image


image

Compatibility Mode

In the example startup screen above, we see the text “Running in Vi compatible mode.” This means that vim will run in a mode that is closer to the normal be- havior of vi rather than the enhanced behavior of vim. For purposes of this chapter, we will want to run vim with its enhanced behavior. To do this, you have a few options: Try running vim instead of vi. If that works, consider adding alias vi='vim' to your .bashrc file. Alternatively, use this command to add a line to your vim configuration file:

echo "set nocp" >> ~/.vimrc

Different Linux distributions package vim in different ways. Some distributions install a minimal version of vim by default that only supports a limited set of vim features. While preforming the lessons that follow, you may encounter miss- ing features. If this is the case, install the full version of vim.


Top OS Cloud Computing at OnWorks: