Difference between revisions of "Vi"

From FOG Project
Jump to: navigation, search
m (Quick reference for basic editing in Vi)
m (Quick reference for basic editing in Vi)
Line 11: Line 11:
  
  
go into insert mode, here you may use arrows to navigate text, and edit it with the keyboard as normal:
+
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>  
  
exit insert mode:
+
Exit insert mode:
 
<pre>Esc (the escape key)</pre>
 
<pre>Esc (the escape key)</pre>
  
Line 20: Line 20:
 
'''WHEN NOT''' in insert mode you may use:
 
'''WHEN NOT''' in insert mode you may use:
  
write changes:
+
Write changes:
 
<pre>:w  (then enter)</pre>  
 
<pre>:w  (then enter)</pre>  
  
exit vi:
+
Exit vi:
 
<pre>:q  (then enter)</pre>
 
<pre>:q  (then enter)</pre>
  
exit vi without saving changes:
+
Exit vi without saving changes:
 
<pre>:q!  (then enter)</pre>
 
<pre>:q!  (then enter)</pre>
  

Revision as of 13:24, 17 January 2016

Quick reference for basic editing in Vi

Vi is a very basic (yet incredibly powerful) text editor that comes with just about every single Linux Distribution. Using Vi allows you to avoid installing other text editors.


Basic Instructions:

Note: Avoid using the number pad in Vi.


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

i

Exit insert mode:

Esc (the escape key)


WHEN NOT in insert mode you may use:

Write changes:

:w   (then enter)

Exit vi:

:q   (then enter)

Exit vi without saving changes:

:q!   (then enter)


Example 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!