Difference between revisions of "Introduction to Linux in HPC/The vim text editor"

From HPC Wiki
Introduction to Linux in HPC/The vim text editor
Jump to navigation Jump to search
Line 38: Line 38:
  
 
{{hidden begin  
 
{{hidden begin  
|title = 1. How to enter the insert mode of vim?
+
|title = 1. How to enter the insert mode of <code>vim</code>?
 
}}
 
}}
 
<quiz display=simple>
 
<quiz display=simple>
 
{
 
{
 
|type="()"}
 
|type="()"}
- press enter key
+
- press <code>enter</code> key
 
||  
 
||  
+ press i key
+
+ press <code>i</code> key
|| Explanation: If you are not in the insert mode, the i key means insert and by pressing it you can enter the insert mode. On the other hand, the Esc key brings you out of the insert mode. The behavior of   the enter key depends on in which mode of vim you are. If you are in the normal mode, you navigate to the next line. If you are in the insert mode already, you start a new line.
+
|| Explanation: If you are not in the insert mode, the <code>i</code> key means insert and by pressing it you can enter the insert mode. On the other hand, the <code>Esc</code> key brings you out of the insert mode. The behavior of the enter key depends on in which mode of vim you are. If you are in the normal mode, you navigate to the next line. If you are in the insert mode already, you start a new line.
- press Esc key
+
- press <code>Esc</code> key
 
||  
 
||  
 
</quiz>
 
</quiz>
Line 54: Line 54:
  
 
{{hidden begin  
 
{{hidden begin  
|title = 2. How would you open a file in read-only mode using the vim editor ? </br>
+
|title = 2. How would you open a file in read-only mode using the <code>vim</code> editor? </br>
 
Hint: In terminal <code>man vim</code>  
 
Hint: In terminal <code>man vim</code>  
 
}}
 
}}

Revision as of 11:41, 2 October 2020

Video

Linux Introduction Slides 91 - 99 (9 pages)


Slide Layout

   page 1: 
       vi and vim are terminal based text editors.
       Advantages vs. disadvantages
   page 2 - 6: 
       animation
           normal mode -> insert mode
           insert mode -> normal mode
           normal mode -> command mode
           command mode -> normal mode
   page 7: 
       arrow keys or h, j, k, l for navigation
       undo
       quit with/without saving
       search for text
       yank
   page 8: 
       If you forget which mode you are in, keep pressing Esc.
       You may need a lot of time to learn vim.
   page 9:
       Knowing vim basics is important for Linux users.
       However there are also many GUI-based text editors.


Quiz

1. How to enter the insert mode of vim?

press enter key
press i key
press Esc key


2. How would you open a file in read-only mode using the vim editor?
Hint: In terminal man vim

Click and submit to see the answer


Info:  If you forget which mode you are in while using vim, just keep pressing Esc.


Warning:  no warnings in this section

Exercises in Terminal (slide 100)

1.  Create a vim file and write some text in it with insert (pressing i) and than undo and redo the changes.