Difference between revisions of "Vi"

From FOG Project
Jump to: navigation, search
Line 1: Line 1:
 
Quick reference for basic editing in vi
 
Quick reference for basic editing in vi
  
 +
go into insert mode, here you may use arrows to navigate text, and edit it with the keyboard as normal.
 +
<pre>i</pre>
  
<pre>i</pre> = go into insert mode, here you may use arrows to navigate text, and edit it with the keyboard as normal.
+
Esc (the escape key) = exit insert mode
  
Esc (the escape key) = exit insert mode
 
  
 
WHEN NOT in insert mode you may use:
 
WHEN NOT in insert mode you may use:
<pre:w</pre> (then enter) = write changes.
+
 
<pre>:q</pre> (then enter) = exit vi
+
write changes.
<pre>:q!</pre> (then enter) = exit vi without saving changes.
+
<pre:w   (then enter)</pre>  
 +
 
 +
exit vi
 +
<pre>:q   (then enter)</pre>
 +
 
 +
exit vi without saving changes.
 +
<pre>:q!   (then enter)</pre>
  
  
Line 18: Line 25:
 
<pre>i
 
<pre>i
 
This is my first readme file, wrote with vi!
 
This is my first readme file, wrote with vi!
Esc
+
(Esc key)
 
:w
 
:w
 
:q</pre>
 
:q</pre>

Revision as of 22:54, 10 April 2015

Quick reference for basic editing in vi

go into insert mode, here you may use arrows to navigate text, and edit it with the keyboard as normal.

i

Esc (the escape key) = exit insert mode


WHEN NOT in insert mode you may use:

write changes. <pre:w (then enter)</pre>

exit vi

:q   (then enter)

exit vi without saving changes.

:q!   (then enter)


Examples of usage...

[root@localhost ~]# vi /README.txt
i
This is my first readme file, wrote with vi!
(Esc key)
:w
:q
[root@localhost ~]# cat /README.txt
this is my first readme file, wrote with vi!