Difference between revisions of "Introduction to Linux in HPC/The vim text editor"
Introduction to Linux in HPC/The vim text editor
Jump to navigation
Jump to search
m (intro) |
m |
||
Line 4: | Line 4: | ||
__TOC__ | __TOC__ | ||
− | This part of the Linux tutorials introduces the vim text editor and describes its main features and use cases. A short explanation of the most important commands paired with examples on how to use them allow the user to delve right in. The tutorial demonstrates the basics, like opening/writing files or moving within the text as well as the most often employed tasks like search&replace or copy&paste which makes it interesting both | + | This part of the Linux tutorials introduces the vim text editor and describes its main features and use cases. A short explanation of the most important commands paired with examples on how to use them allow the user to delve right in. The tutorial demonstrates the basics, like opening/writing files or moving within the text as well as the most often employed tasks like search&replace or copy&paste which makes it interesting to both complete beginners and more intermediate users. The vim text editor's main advantage is that it's present in most unix operational systems, futhermore it's highly configurable and provides an extensive plugin system. |
=== Video === <!--T:5--> | === Video === <!--T:5--> | ||
Line 14: | Line 14: | ||
=== Quiz === <!--T:5--> | === Quiz === <!--T:5--> | ||
+ | {{hidden begin | ||
+ | |title = How many modes does vim have? | ||
+ | }} | ||
+ | <quiz display=simple> | ||
+ | { | ||
+ | |type="()"} | ||
+ | - it has only one mode | ||
+ | || | ||
+ | - it has two modes | ||
+ | || | ||
+ | + it has at least three modes | ||
+ | || Explanation: <code>vi</code> has the modes normal, insert and command. In addition, <code>vim</code> hast the modes visual, select und ex-mode, not covered in this tutorial. | ||
+ | </quiz> | ||
+ | {{hidden end}} | ||
{{hidden begin | {{hidden begin | ||
− | |title = | + | |title = How to enter the insert mode of <code>vim</code>? |
}} | }} | ||
<quiz display=simple> | <quiz display=simple> | ||
Line 26: | Line 40: | ||
|| 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. | || 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 <code>Esc</code> key | - press <code>Esc</code> key | ||
+ | || | ||
+ | </quiz> | ||
+ | {{hidden end}} | ||
+ | |||
+ | {{hidden begin | ||
+ | |title = How to save a file and exit during normal mode? | ||
+ | }} | ||
+ | <quiz display=simple> | ||
+ | { | ||
+ | |type="()"} | ||
+ | - press <code>:q!</code> keys | ||
+ | || | ||
+ | + press <code>:wq</code> or <code>:X</code> or <code>ZZ</code> keys | ||
+ | || Explanation: Any of the pressed key combinations will trigger a save and exit when in normal mode. | ||
+ | - press <code>Ctrl-x Ctrl-s</code> key | ||
|| | || | ||
</quiz> | </quiz> | ||
Line 32: | Line 61: | ||
{{hidden begin | {{hidden begin | ||
− | |title = | + | |title = 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 19:53, 25 November 2020
Tutorial | |
---|---|
Title: | Introduction to Linux in HPC |
Provider: | HPC.NRW
|
Contact: | tutorials@hpc.nrw |
Type: | Multi-part video |
Topic Area: | HPC Platforms |
License: | CC-BY-SA |
Syllabus
| |
1. Background and History | |
2. The Command Line | |
3. Linux Directory Structure | |
4. Files | |
5. Text display and search | |
6. Users and permissions | |
7. Processes | |
8. The vim text editor | |
9. Shell scripting | |
10. Environment variables | |
11. System configuration | |
12. SSH Connections | |
13. SSH: Graphics and File Transfer | |
14. Various tips |
This part of the Linux tutorials introduces the vim text editor and describes its main features and use cases. A short explanation of the most important commands paired with examples on how to use them allow the user to delve right in. The tutorial demonstrates the basics, like opening/writing files or moving within the text as well as the most often employed tasks like search&replace or copy&paste which makes it interesting to both complete beginners and more intermediate users. The vim text editor's main advantage is that it's present in most unix operational systems, futhermore it's highly configurable and provides an extensive plugin system.
Video
Quiz
How many modes does vim have?
How to enter the insert mode of
vim
?
How to save a file and exit during normal mode?
How would you open a file in read-only mode using the
Hint: In terminal
vim
editor? Hint: In terminal
man vim
Info: | If you forget in which mode you are in while using vim, just keep pressing Esc. |
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.
Answer: |
|