Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
elearning:workbooks:redhat:rh124en:l101 [2024/11/04 13:30] – admin | elearning:workbooks:redhat:rh124en:l101 [2024/11/23 13:34] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 3: | Ligne 3: | ||
Version : **2024.01** | Version : **2024.01** | ||
- | Last update | + | Updated: ~~LASTMOD~~ |
- | ======RH12402 - The VI Editor====== | + | ======RH12402 - The VIsual |
- | =====Module content===== | + | =====Contents===== |
- | * **RH12402 - The VI Editor** | + | * **RH12402 - The VIsual |
- | * Module content | + | * Contents |
* Presentation | * Presentation | ||
- | * LAB #1 - Creating, | + | * LAB #1 - Creating, |
* 1.1 - Commands | * 1.1 - Commands | ||
* 1.2 - Creating a new file with VI | * 1.2 - Creating a new file with VI | ||
- | * 1.3 - Open a file in read-only mode with the view command | + | * 1.3 - Opening |
- | * 1.4 - Opening a file in read-write mode with the vi command | + | * 1.4 - Opening a file in read-write mode using VI |
- | * LAB #2 - The set command | + | * LAB #2 - The set Command |
* 2.1 - Commands | * 2.1 - Commands | ||
- | * 2.2 - Enabling | + | * 2.2 - Turning on line numbering |
- | * LAB #3 - Moving within | + | * LAB #3 - Moving |
* 3.1 - Commands | * 3.1 - Commands | ||
* LAB #4 - Inserting Text | * LAB #4 - Inserting Text | ||
* 4.1 - Commands | * 4.1 - Commands | ||
* 4.2 - Inserting text | * 4.2 - Inserting text | ||
- | * LAB #5 - Text Search | + | * LAB #5 - Searching for Text |
* 5.1 - Commands | * 5.1 - Commands | ||
- | * 5.2 - Finding | + | * 5.2 - Searching for and replacing text |
* LAB #6 - Deleting Text | * LAB #6 - Deleting Text | ||
* 6.1 - Commands | * 6.1 - Commands | ||
- | * 6.2 - Deleting | + | * 6.2 - Deleting |
* LAB #7 - Copy, Cut and Paste | * LAB #7 - Copy, Cut and Paste | ||
* 7.1 - Commands | * 7.1 - Commands | ||
- | * 7.2 - Copying, Cutting and Pasting Text | + | * 7.2 - Copying, Cutting and pasting text |
- | * LAB #8 - Configuring a Personal VI Interface | + | * LAB #8 - Configuring a Personalised |
- | =====Présentation===== | + | =====Presentation===== |
- | VI is a powerful text editor | + | The **VI**sual Editor (a.k.a. **VI**) |
* //Command// | * //Command// | ||
Ligne 44: | Ligne 44: | ||
* //Insert// | * //Insert// | ||
- | In command | + | In // |
- | In Ex-Mode, most VI commands | + | In //Ex-mode// mode, all commands |
- | In insert | + | In // |
* edit text, | * edit text, | ||
- | * add text | + | * add text, |
- | * search for text | + | * search for text, |
- | * copy text | + | * copy text, |
- | * paste text | + | * paste text, |
* cut text, | * cut text, | ||
- | * replace text. | + | * replace |
- | =====LAB #1 - Create, open and close files===== | + | =====LAB #1 - Creating, Opening |
- | ====1.1 - Commands=== | + | ====1.1 - Commands==== |
^ Command ^ Description^ | ^ Command ^ Description^ | ||
- | | **vi** //fileName// | Open or create a file | | + | | **vi** //filename// | Edit // |
- | | **vi** | Opening | + | | **vi** | Edit a new file starting at line 1 | |
- | | **vi -r** // | + | | **vi -r** // |
- | | **view** // | + | | **view** // |
- | | **:wq** | Exit by saving | + | | **:wq** | Quit vi, writing out modified file to file named in original invocation |
- | | **ZZ** | The same as :wq | | + | | **:x** | Quit vi, writing out modified file to file named in original invocation |
- | | **:x** | Exit by saving | + | | **:q** | Quit (or exit) vi if the file was not modified or quit view | |
- | | **:q** | Exit if the file has not been modified or if the **view** command has been used | | + | |
| **u** | Undo last command | | | **u** | Undo last command | | ||
- | | **U** | Undo changes made to current line. | | + | | **U** | Undo the modifications |
- | | **:q!** | Exit without saving | + | | **:q!** | Quit VI even though latest changes have not been saved | |
====1.2 - Creating a new file with VI==== | ====1.2 - Creating a new file with VI==== | ||
- | Copy the 25 lines below: | + | Copy lines 1 through 25 below: |
< | < | ||
Ligne 107: | Ligne 107: | ||
</ | </ | ||
- | Create a new file called **vitext** using the vi command: | + | Create a new file called **vitext** using vi: |
< | < | ||
Ligne 116: | Ligne 116: | ||
</ | </ | ||
- | <WRAP center round todo 60%> | + | <WRAP center round important |
- | **To do** - Press the **i** key on your keyboard | + | **To do** - Use the **i** key to change |
</ | </ | ||
- | ====1.3 - Opening a file in read-only mode with the view command==== | + | ====1.3 - Opening a file in read-only mode using view==== |
- | Now open the file **/ | + | Now open **/ |
< | < | ||
Ligne 128: | Ligne 128: | ||
</ | </ | ||
- | You will get a result similar to this one: | + | You will obtain |
< | < | ||
Ligne 156: | Ligne 156: | ||
This is line 24 | This is line 24 | ||
This is line 25 | This is line 25 | ||
- | ~ | + | ~ |
- | ‘vitext [readonly] 25L, 391B 1,14 All | + | "vitext" |
</ | </ | ||
- | <WRAP center round alert 60%> | + | <WRAP center round important |
- | **Warning**: Make sure you only see the first 25 lines of this file. | + | **To do** - Re-size your window so that you can see just the 25 numbered |
</ | </ | ||
<WRAP center round important 60%> | <WRAP center round important 60%> | ||
- | **Important**: Note that the last line is marked | + | **Important** |
</ | </ | ||
- | ====1.4 - Opening a file in read-write mode with the vi command==== | + | ====1.4 - Opening a file in read-write mode using VI==== |
- | Exit view with the **:q** command and open the **/ | + | Quit using the **:q** command and open the file in read-write mode : |
< | < | ||
Ligne 176: | Ligne 176: | ||
</ | </ | ||
- | You will get a result similar to this one: | + | You will obtain |
< | < | ||
Ligne 204: | Ligne 204: | ||
This is line 24 | This is line 24 | ||
This is line 25 | This is line 25 | ||
- | ~ | + | "vitext" |
- | ‘vitext 25L, 391B 1,14 All | + | |
</ | </ | ||
<WRAP center round important 60%> | <WRAP center round important 60%> | ||
- | **Important**: Note that vi is run in Command mode. | + | **Important** |
</ | </ | ||
- | =====LAB #2 - The set command===== | + | =====LAB #2 - The set Command===== |
====2.1 - Commands==== | ====2.1 - Commands==== | ||
^ Command ^ Description^ | ^ Command ^ Description^ | ||
- | | **:set nu** | Display | + | | **:set nu** | Turns on line numbering | |
- | | **:set number** | Display | + | | **:set number** | Turns on line numbering | |
- | | **:set nonu** | Suppress | + | | **:set nonu** | Turns off line numbering | |
- | | **:set nonumber** | Suppress | + | | **:set nonumber** | Turns off line numbering | |
- | | **:set ic** | Search without regard to case | | + | | **:set ic** | Turns on independent |
- | | **:set noic** | Search | + | | **:set noic** | Turns on case dependent searching |
- | ====2.2 - Enable | + | ====2.2 - Turning on line numbering |
- | Activate | + | Turn on line numbering with the command |
< | < | ||
- | 1 This is line 1 | + | |
- | 2 This is line 2 | + | 2 This is line 2 |
- | 3 This is line 3 | + | 3 This is line 3 |
- | 4 This is line 4 | + | 4 This is line 4 |
- | 5 This is line 5 | + | 5 This is line 5 |
- | 6 This is line 6 | + | 6 This is line 6 |
- | 7 This is line 7 | + | 7 This is line 7 |
- | 8 This is line 8 | + | 8 This is line 8 |
- | 9 This is line 9 | + | 9 This is line 9 |
- | 10 This is line 10 | + | 10 This is line 10 |
- | 11 This is line 11 | + | 11 This is line 11 |
- | 12 This is line 12 | + | 12 This is line 12 |
- | 13 This is line 13 | + | 13 This is line 13 |
- | 14 This is line 14 | + | 14 This is line 14 |
- | 15 This is line 15 | + | 15 This is line 15 |
- | 16 This is line 16 | + | 16 This is line 16 |
- | 17 This is line 17 | + | 17 This is line 17 |
- | 18 This is line 18 | + | 18 This is line 18 |
- | 19 This is line 19 | + | 19 This is line 19 |
- | 20 This is line 20 | + | 20 This is line 20 |
- | 21 This is line 21 | + | 21 This is line 21 |
- | 22 This is line 22 | + | 22 This is line 22 |
- | 23 This is line 23 | + | 23 This is line 23 |
- | 24 This is line 24 | + | 24 This is line 24 |
- | 25 This is line 25 | + | 25 This is line 25 |
- | ~ | + | :set nu 25,1 All |
- | :set nu 1,14 All | + | |
</ | </ | ||
- | =====LAB #3 - Moving within | + | < |
+ | 1 This is line 1 | ||
+ | 2 This is line 2 | ||
+ | 3 This is line 3 | ||
+ | 4 This is line 4 | ||
+ | 5 This is line 5 | ||
+ | 6 This is line 6 | ||
+ | 7 This is line 7 | ||
+ | 8 This is line 8 | ||
+ | 9 This is line 9 | ||
+ | 10 This is line 10 | ||
+ | 11 This is line 11 | ||
+ | 12 This is line 12 | ||
+ | 13 This is line 13 | ||
+ | 14 This is line 14 | ||
+ | 15 This is line 15 | ||
+ | 16 This is line 16 | ||
+ | 17 This is line 17 | ||
+ | 18 This is line 18 | ||
+ | 19 This is line 19 | ||
+ | 20 This is line 20 | ||
+ | 21 This is line 21 | ||
+ | 22 This is line 22 | ||
+ | 23 This is line 23 | ||
+ | 24 This is line 24 | ||
+ | 25 This is line 25 | ||
+ | :set number | ||
+ | </ | ||
+ | |||
+ | =====LAB #3 - Moving | ||
====3.1 - Commands==== | ====3.1 - Commands==== | ||
^ Command ^ Description^ | ^ Command ^ Description^ | ||
- | | **h** or < | + | | **h** or < |
- | | **j** or < | + | | **j** or < |
- | | **k** or < | + | | **k** or < |
- | | **l** or < | + | | **l** or < |
- | | **b** | Move cursor | + | | **b** | Move cursor |
- | | **w** | Moves cursor | + | | **w** | Move cursor to beginning of next word | |
- | | **e** | Move cursor to end of current word | | + | | **e** | Move cursor to the end of the current word | |
- | | **H** | Moves cursor to the top of the screen | | + | | **H** | Move cursor to top of screen | |
- | | **M** | Moves cursor to the middle of the screen | | + | | **M** | Move cursor to middle of screen | |
- | | **L** | Moves cursor to the bottom of the screen | | + | | **L** | Move cursor to bottom of screen | |
- | | **G** or **:$** | Move cursor to last line of file | | + | | **G** or **:$** | Move cursor to the last line of the file | |
- | | **G** or **:0** | Move cursor to first line of file | | + | | **1G** or **:0** | Move cursor to first line in file | |
| **27G** | Move cursor to line 27 | | | **27G** | Move cursor to line 27 | | ||
- | | **Ctrl+f** | Scroll | + | | **Ctrl+f** | Move forward |
- | | **Ctrl+d** | Scroll | + | | **Ctrl+d** | Move down (forward) one half screen | |
- | | **Ctrl+b** | Scroll back one screen | + | | **Ctrl+b** | Move backward |
- | | **Ctrl+u** | Scroll | + | | **Ctrl+u** | Move up (back) one half screen | |
- | + | ||
- | <WRAP center round todo 60%> | + | |
- | **To do**: Test each command to see the results. Then return to the first screen and position your cursor at the beginning of line 13. | + | |
- | </ | + | |
<WRAP center round important 60%> | <WRAP center round important 60%> | ||
- | **Important**: To find out why the < | + | **To do** - Test each of the above commands. When you have finished, position the cursor at beginning of line 13. In order to understand |
</ | </ | ||
- | =====LAB #4 - Text insertion===== | + | =====LAB #4 - Inserting |
====4.1 - Commands==== | ====4.1 - Commands==== | ||
^ Key(s) ^ Description^ | ^ Key(s) ^ Description^ | ||
- | | **i** | Insert text before | + | | **i** | Insert text before cursor | |
- | | **I** | Insert text at beginning of the line | | + | | **I** | Insert text at beginning of current |
- | | **a** | Insert | + | | **a** | Append |
- | | **A** | Insert | + | | **A** | Append |
- | | **o** | Insert | + | | **o** | Open and put text in a new line below current line | |
- | | **O** | Insert | + | | **O** | Open and put text in a new line above current line | |
- | | **R** | Replace existing text | | + | | <key>Escape</ |
- | | <key>Echap</ | + | |
====4.2 - Inserting text==== | ====4.2 - Inserting text==== | ||
- | Insert a line below the current | + | Insert a line under the line 13 using the **o** command. Note that you are now in //Insert// mode. Type the following text : **Linux is super**. You will obtain |
< | < | ||
- | 1 This is line 1 | + | |
- | 2 This is line 2 | + | 2 This is line 2 |
- | 3 This is line 3 | + | 3 This is line 3 |
- | 4 This is line 4 | + | 4 This is line 4 |
- | 5 This is line 5 | + | 5 This is line 5 |
- | 6 This is line 6 | + | 6 This is line 6 |
- | 7 This is line 7 | + | 7 This is line 7 |
- | 8 This is line 8 | + | 8 This is line 8 |
- | 9 This is line 9 | + | 9 This is line 9 |
- | 10 This is line 10 | + | 10 This is line 10 |
- | 11 This is line 11 | + | 11 This is line 11 |
- | 12 This is line 12 | + | 12 This is line 12 |
- | 13 This is line 13 | + | 13 This is line 13 |
- | 14 Linux is super | + | 14 Linux is super |
- | 15 This is line 14 | + | 15 This is line 14 |
- | 16 This is line 15 | + | 16 This is line 15 |
- | 17 This is line 16 | + | 17 This is line 16 |
- | 18 This is line 17 | + | 18 This is line 17 |
- | 19 This is line 18 | + | 19 This is line 18 |
- | 20 This is line 19 | + | 20 This is line 19 |
- | 21 This is line 20 | + | 21 This is line 20 |
- | 22 This is line 21 | + | 22 This is line 21 |
- | 23 This is line 22 | + | 23 This is line 22 |
- | 24 This is line 23 | + | 24 This is line 23 |
- | 25 This is line 24 | + | 25 This is line 24 |
- | -- INSERT -- 14,15 Top | + | -- INSERT -- 14,15 |
</ | </ | ||
- | <WRAP center round alert 60%> | + | <WRAP center round important |
- | **Warning** - Do not change the size of your terminal. You should ONLY view the first 25 lines. | + | **Warning** - Do not change the size of the window. You only need to see the first 25 lines. |
</ | </ | ||
- | Now switch | + | Switch back to //Command// mode using the < |
< | < | ||
- | 1 This is line 1 | + | |
- | 2 This is line 2 | + | 2 This is line 2 |
- | 3 This is line 3 | + | 3 This is line 3 |
- | 4 This is line 4 | + | 4 This is line 4 |
- | 5 This is line 5 | + | 5 This is line 5 |
- | 6 This is line 6 | + | 6 This is line 6 |
- | 7 This is line 7 | + | 7 This is line 7 |
- | 8 This is line 8 | + | 8 This is line 8 |
- | 9 This is line 9 | + | 9 This is line 9 |
- | 10 This is line 10 | + | 10 This is line 10 |
- | 11 This is line 11 | + | 11 This is line 11 |
- | 12 This is line 12 | + | 12 This is line 12 |
- | 13 This is line 13 | + | 13 This is line 13 |
- | 14 Linux is super | + | 14 Linux is super |
- | 15 This is line 14 | + | 15 This is line 14 |
- | 16 This is line 15 | + | 16 This is line 15 |
- | 17 This is line 16 | + | 17 This is line 16 |
- | 18 This is line 17 | + | 18 This is line 17 |
- | 19 This is line 18 | + | 19 This is line 18 |
- | 20 This is line 19 | + | 20 This is line 19 |
- | 21 This is line 20 | + | 21 This is line 20 |
- | 22 This is line 21 | + | 22 This is line 21 |
- | 23 This is line 22 | + | 23 This is line 22 |
- | 24 This is line 23 | + | 24 This is line 23 |
- | 25 This is line 24 | + | 25 This is line 24Linux |
- | 26 This is line 25Linux | + | -- INSERT -- 25,30 Top |
- | -- INSERT -- 26,30 All | + | |
</ | </ | ||
- | Now switch | + | Switch back to //Command// mode using the < |
< | < | ||
- | 1 This is line Linux is super1 | + | |
- | 2 This is line 2 | + | 2 This is line 2 |
- | 3 This is line 3 | + | 3 This is line 3 |
- | 4 This is line 4 | + | 4 This is line 4 |
- | 5 This is line 5 | + | 5 This is line 5 |
- | 6 This is line 6 | + | 6 This is line 6 |
- | 7 This is line 7 | + | 7 This is line 7 |
- | 8 This is line 8 | + | 8 This is line 8 |
- | 9 This is line 9 | + | 9 This is line 9 |
- | 10 This is line 10 | + | 10 This is line 10 |
- | 11 This is line 11 | + | 11 This is line 11 |
- | 12 This is line 12 | + | 12 This is line 12 |
- | 13 This is line 13 | + | 13 This is line 13 |
- | 14 Linux is super | + | 14 Linux is super |
- | 15 This is line 14 | + | 15 This is line 14 |
- | 16 This is line 15 | + | 16 This is line 15 |
- | 17 This is line 16 | + | 17 This is line 16 |
- | 18 This is line 17 | + | 18 This is line 17 |
- | 19 This is line 18 | + | 19 This is line 18 |
- | 20 This is line 19 | + | 20 This is line 19 |
- | 21 This is line 20 | + | 21 This is line 20 |
- | 22 This is line 21 | + | 22 This is line 21 |
- | 23 This is line 22 | + | 23 This is line 22 |
- | 24 This is line 23 | + | 24 This is line 23 |
- | 25 This is line 24 | + | 25 This is line 24Linux |
- | 26 This is line 25Linux | + | -- INSERT -- 1,28 Top |
- | -- INSERT -- 1,27 All | + | |
</ | </ | ||
- | Now switch | + | Switch back to //Commande// mode using the < |
- | =====LAB #5 - Text search===== | + | =====LAB #5 - Searching for Text===== |
====5.1 - Commands==== | ====5.1 - Commands==== | ||
^ Key(s) ^ Description^ | ^ Key(s) ^ Description^ | ||
- | | **/** //string// | Search | + | | **/** //string// | Search |
- | | **%%//%%** | Search for the next occurrence | + | | **%%//%%** | Search |
- | | **?** | Search for // | + | | **?** // |
- | | **??** | Search for the next occurrence | + | | **??** | Search |
- | | **n** | Search for the next occurrence of //string// in the direction of the search | + | | **n** | Move to next occurrence of search |
- | | **N** | Search for the previous | + | | **N** | Move to next occurrence of search |
- | | **: | + | | **: |
- | ====5.2 - Find and replace | + | ====5.2 - Searching for and replacing |
- | Now search | + | Search the text for the string // |
- | Then search | + | Now search |
- | Now press the **n** key. Your cursor should be on the first line. Then press the **N** key. Your cursor | + | Now use the **n** command. Your cursor should be on the first line. Now use the **N** command. Your cursor |
- | Press the **H** command. Now replace | + | Place the cursor at the beginning of the first line and //search and replace// the string |
- | < | + | **%%: |
- | 1 This is line Linux is super1 | + | |
- | 2 This is line 2 | + | You will obtain a result similar to the following example : |
- | 3 This is line 3 | + | |
- | 4 This is line 4 | + | |
- | 5 This is line 5 | + | |
- | 6 This is line 6 | + | |
- | 7 This is line 7 | + | |
- | 8 This is line 8 | + | |
- | 9 This is line 9 | + | |
- | 10 This is line 10 | + | |
- | 11 This is line 11 | + | |
- | 12 This is line 12 | + | |
- | 13 This is line 13 | + | |
- | 14 Linux is super | + | |
- | 15 This is line 14 | + | |
- | 16 This is line 15 | + | |
- | 17 This is line 16 | + | |
- | 18 This is line 17 | + | |
- | 19 This is line 18 | + | |
- | 20 This is line 19 | + | |
- | 21 This is line 20 | + | |
- | 22 This is line 21 | + | |
- | 23 This is line 22 | + | |
- | 24 This is line 23 | + | |
- | 25 This is line 24 | + | |
- | 26 This is line 25Linux is super | + | |
- | : | + | |
- | </ | + | |
< | < | ||
- | 1 This is line Linux is wonderful1 | + | |
- | 2 This is line 2 | + | 2 This is line 2 |
- | 3 This is line 3 | + | 3 This is line 3 |
- | 4 This is line 4 | + | 4 This is line 4 |
- | 5 This is line 5 | + | 5 This is line 5 |
- | 6 This is line 6 | + | 6 This is line 6 |
- | 7 This is line 7 | + | 7 This is line 7 |
- | 8 This is line 8 | + | 8 This is line 8 |
- | 9 This is line 9 | + | 9 This is line 9 |
- | 10 This is line 10 | + | 10 This is line 10 |
- | 11 This is line 11 | + | 11 This is line 11 |
- | 12 This is line 12 | + | 12 This is line 12 |
- | 13 This is line 13 | + | 13 This is line 13 |
- | 14 Linux is wonderful | + | 14 Linux is wonderful |
- | 15 This is line 14 | + | 15 This is line 14 |
- | 16 This is line 15 | + | 16 This is line 15 |
- | 17 This is line 16 | + | 17 This is line 16 |
- | 18 This is line 17 | + | 18 This is line 17 |
- | 19 This is line 18 | + | 19 This is line 18 |
- | 20 This is line 19 | + | 20 This is line 19 |
- | 21 This is line 20 | + | 21 This is line 20 |
- | 22 This is line 21 | + | 22 This is line 21 |
- | 23 This is line 22 | + | 23 This is line 22 |
- | 24 This is line 23 | + | 24 This is line 23 |
- | 25 This is line 24 | + | 25 This is line 24Linux |
- | 26 This is line 25Linux | + | 3 substitutions on 3 lines 25,1 Top |
- | 3 substitutions on 3 lines 26,1 All | + | |
</ | </ | ||
- | =====LAB #6 - Deleting | + | =====LAB #6 - Deleting |
====6.1 - Commands==== | ====6.1 - Commands==== | ||
^ Key(s) ^ Description^ | ^ Key(s) ^ Description^ | ||
- | | **x** | Delete | + | | **x** | Delete |
- | | **X** | Delete character to left of the cursor | | + | | **X** | Delete |
- | | **5x**| Delete 5 characters | + | | **5x** | Delete 5 characters, starting with character |
| **dw** | Delete current word | | | **dw** | Delete current word | | ||
- | | **5dw** | Delete 5 words from current character | + | | **5dw** | Delete 5 words, starting with the word under cursor |
- | | **dd** or **:d** | Delete current line | | + | | **dd** or **:d** | Delete |
- | | **5dd** | Delete 5 lines starting | + | | **5dd** | Delete 5 lines starting |
| **:5,7 d** | Delete lines 5, 6 and 7 | | | **:5,7 d** | Delete lines 5, 6 and 7 | | ||
====6.2 - Deleting lines==== | ====6.2 - Deleting lines==== | ||
- | Go to line 14 and delete it using the **dd** command. You will obtain a result similar to the following: | + | Place the cursor on the line containing |
< | < | ||
- | 1 This is line Linux is wonderful1 | + | |
- | 2 This is line 2 | + | 2 This is line 2 |
- | 3 This is line 3 | + | 3 This is line 3 |
- | 4 This is line 4 | + | 4 This is line 4 |
- | 5 This is line 5 | + | 5 This is line 5 |
- | 6 This is line 6 | + | 6 This is line 6 |
- | 7 This is line 7 | + | 7 This is line 7 |
- | 8 This is line 8 | + | 8 This is line 8 |
- | 9 This is line 9 | + | 9 This is line 9 |
- | 10 This is line 10 | + | 10 This is line 10 |
- | 11 This is line 11 | + | 11 This is line 11 |
- | 12 This is line 12 | + | 12 This is line 12 |
- | 13 This is line 13 | + | 13 This is line 13 |
- | 14 This is line 14 | + | 14 This is line 14 |
- | 15 This is line 15 | + | 15 This is line 15 |
- | 16 This is line 16 | + | 16 This is line 16 |
- | 17 This is line 17 | + | 17 This is line 17 |
- | 18 This is line 18 | + | 18 This is line 18 |
- | 19 This is line 19 | + | 19 This is line 19 |
- | 20 This is line 20 | + | 20 This is line 20 |
- | 21 This is line 21 | + | 21 This is line 21 |
- | 22 This is line 22 | + | 22 This is line 22 |
- | 23 This is line 23 | + | 23 This is line 23 |
- | 24 This is line 24 | + | 24 This is line 24Linux is wonderful |
- | 25 This is line 25Linux is wonderful | + | 25 This is line 25 |
- | ~ | + | 14,1 All |
- | 3 substitutions on 3 lines 14,1 All | + | |
</ | </ | ||
- | Now delete | + | Note the contents of lines 4 through |
+ | |||
+ | **:4,6 d** | ||
+ | |||
+ | You will obtain | ||
< | < | ||
- | 1 This is line Linux is wonderful1 | + | |
- | 2 This is line 2 | + | 2 This is line 2 |
- | 3 This is line 3 | + | 3 This is line 3 |
- | 4 This is line 7 | + | 4 This is line 7 |
- | 5 This is line 8 | + | 5 This is line 8 |
- | 6 This is line 9 | + | 6 This is line 9 |
- | 7 This is line 10 | + | 7 This is line 10 |
- | 8 This is line 11 | + | 8 This is line 11 |
- | 9 This is line 12 | + | 9 This is line 12 |
- | 10 This is line 13 | + | 10 This is line 13 |
- | 11 This is line 14 | + | 11 This is line 14 |
- | 12 This is line 15 | + | 12 This is line 15 |
- | 13 This is line 16 | + | 13 This is line 16 |
- | 14 This is line 17 | + | 14 This is line 17 |
- | 15 This is line 18 | + | 15 This is line 18 |
- | 16 This is line 19 | + | 16 This is line 19 |
- | 17 This is line 20 | + | 17 This is line 20 |
- | 18 This is line 21 | + | 18 This is line 21 |
- | 19 This is line 22 | + | 19 This is line 22 |
- | 20 This is line 23 | + | 20 This is line 23 |
- | 21 This is line 24 | + | 21 This is line 24Linux is wonderful |
- | 22 This is line 25Linux is wonderful | + | 22 This is line 25 |
- | ~ | + | ~ |
- | ~ | + | ~ |
- | ~ | + | ~ |
- | ~ | + | 3 fewer lines |
- | 3 fewer lines 4,1 All | + | |
</ | </ | ||
- | + | =====LAB #7 - Copy, Cut and Paste===== | |
- | =====LAB #7 -Copy, Cut and Paste===== | + | |
====7.1 - Commands==== | ====7.1 - Commands==== | ||
^ Key(s) ^ Description^ | ^ Key(s) ^ Description^ | ||
- | | **yy** or **Y** | Copy current line | | + | | **yy** or **Y** or **:y** | Copy (yank) the current line into the buffer |
- | | **V** | Select a block | | + | | **V** | Select a block of text | |
- | | **p** | Paste the line cut or copied below the current line | | + | | **p** | Put (paste) |
- | | **P** | Paste the line cut or copied above the current line | | + | | **P** | Put (paste) |
- | | **:2,3 co 7** | Copy lines 2 to 3 to line below 7 | | + | | **:2,3 co 7** | Copy lines 2 to 3 to the line **after** |
- | | **:2,3 m 7** | Moves lines 2 to 3 to the line below line 7 | | + | | **:2,3 m 7** | Move lines 2 to 3 to lines 6 and 7 | |
- | ====7.2 - Copy, cut and paste text==== | + | ====7.2 - Copying, Cutting |
- | Place your cursor | + | Move the cursor |
< | < | ||
- | 1 This is line Linux is wonderful1 | + | |
- | 2 This is line 2 | + | 2 This is line 2 |
- | 3 This is line 3 | + | 3 This is line 3 |
- | 4 This is line 7 | + | 4 This is line 7 |
- | 5 This is line 8 | + | 5 This is line 8 |
- | 6 This is line 3 | + | 6 This is line 3 |
- | 7 This is line 9 | + | 7 This is line 9 |
- | 8 This is line 10 | + | 8 This is line 10 |
- | 9 This is line 11 | + | 9 This is line 11 |
- | 10 This is line 12 | + | 10 This is line 12 |
- | 11 This is line 13 | + | 11 This is line 13 |
- | 12 This is line 14 | + | 12 This is line 14 |
- | 13 This is line 15 | + | 13 This is line 15 |
- | 14 This is line 16 | + | 14 This is line 16 |
- | 15 This is line 17 | + | 15 This is line 17 |
- | 16 This is line 18 | + | 16 This is line 18 |
- | 17 This is line 19 | + | 17 This is line 19 |
- | 18 This is line 20 | + | 18 This is line 20 |
- | 19 This is line 21 | + | 19 This is line 21 |
- | 20 This is line 22 | + | 20 This is line 22 |
- | 21 This is line 23 | + | 21 This is line 23 |
- | 22 This is line 24 | + | 22 This is line 24Linux is wonderful |
- | 23 This is line 25Linux is wonderful | + | 23 This is line 25 |
- | ~ | + | ~ |
- | ~ | + | ~ |
- | ~ | + | 3 fewer lines |
- | 3 fewer lines 6,1 All | + | |
</ | </ | ||
- | Place your cursor | + | Move your cursor |
< | < | ||
- | 1 This is line Linux is wonderful1 | + | |
- | 2 This is line 2 | + | 2 This is line 2 |
- | 3 This is line 3 | + | 3 This is line 3 |
- | 4 This is line 7 | + | 4 This is line 7 |
- | 5 This is line 8 | + | 5 This is line 8 |
- | 6 This is line 7 | + | 6 This is line 7 |
- | 7 This is line 3 | + | 7 This is line 3 |
- | 8 This is line 9 | + | 8 This is line 9 |
- | 9 This is line 10 | + | 9 This is line 10 |
- | 10 This is line 11 | + | 10 This is line 11 |
- | 11 This is line 12 | + | 11 This is line 12 |
- | 12 This is line 13 | + | 12 This is line 13 |
- | 13 This is line 14 | + | 13 This is line 14 |
- | 14 This is line 15 | + | 14 This is line 15 |
- | 15 This is line 16 | + | 15 This is line 16 |
- | 16 This is line 17 | + | 16 This is line 17 |
- | 17 This is line 18 | + | 17 This is line 18 |
- | 18 This is line 19 | + | 18 This is line 19 |
- | 19 This is line 20 | + | 19 This is line 20 |
- | 20 This is line 21 | + | 20 This is line 21 |
- | 21 This is line 22 | + | 21 This is line 22 |
- | 22 This is line 23 | + | 22 This is line 23 |
- | 23 This is line 24 | + | 23 This is line 24Linux is wonderful |
- | 24 This is line 25Linux is wonderful | + | 24 This is line 25 |
- | ~ | + | ~ |
- | ~ | + | 3 fewer lines |
- | 3 fewer lines 6,1 All | + | |
</ | </ | ||
- | Use the command **:4,5 co 15**. You will get the following | + | Now use the following |
< | < | ||
- | 1 This is line Linux is wonderful1 | + | |
- | 2 This is line 2 | + | 2 This is line 2 |
- | 3 This is line 3 | + | 3 This is line 3 |
- | 4 This is line 7 | + | 4 This is line 7 |
- | 5 This is line 8 | + | 5 This is line 8 |
- | 6 This is line 7 | + | 6 This is line 7 |
- | 7 This is line 3 | + | 7 This is line 3 |
- | 8 This is line 9 | + | 8 This is line 9 |
- | 9 This is line 10 | + | 9 This is line 10 |
- | 10 This is line 11 | + | 10 This is line 11 |
- | 11 This is line 12 | + | 11 This is line 12 |
- | 12 This is line 13 | + | 12 This is line 13 |
- | 13 This is line 14 | + | 13 This is line 14 |
- | 14 This is line 15 | + | 14 This is line 15 |
- | 15 This is line 16 | + | 15 This is line 16 |
- | 16 This is line 7 | + | 16 This is line 7 |
- | 17 This is line 8 | + | 17 This is line 8 |
- | 18 This is line 17 | + | 18 This is line 17 |
- | 19 This is line 18 | + | 19 This is line 18 |
- | 20 This is line 19 | + | 20 This is line 19 |
- | 21 This is line 20 | + | 21 This is line 20 |
- | 22 This is line 21 | + | 22 This is line 21 |
- | 23 This is line 22 | + | 23 This is line 22 |
- | 24 This is line 23 | + | 24 This is line 23 |
- | 25 This is line 24 | + | 25 This is line 24Linux |
- | 26 This is line 25Linux | + | :4,5 co 15 17,1 Top |
- | :4,5 co 15 17,1 All | + | |
</ | </ | ||
- | Note that lines 4 and 5 have been copied after line 15 : | + | Note that lines 4 and 5 have been copied |
< | < | ||
... | ... | ||
- | 15 This is line 16 | + | 15 This is line 16 |
- | 16 This is line 7 | + | 16 This is line 7 |
- | 17 This is line 8 | + | 17 This is line 8 |
+ | 18 This is line 17 | ||
... | ... | ||
</ | </ | ||
- | Use the command **:4,6 m 20**. You will get the following | + | Now use the following |
< | < | ||
- | 1 This is line Linux is wonderful1 | + | |
- | 2 This is line 2 | + | 2 This is line 2 |
- | 3 This is line 3 | + | 3 This is line 3 |
- | 4 This is line 3 | + | 4 This is line 3 |
- | 5 This is line 9 | + | 5 This is line 9 |
- | 6 This is line 10 | + | 6 This is line 10 |
- | 7 This is line 11 | + | 7 This is line 11 |
- | 8 This is line 12 | + | 8 This is line 12 |
- | 9 This is line 13 | + | 9 This is line 13 |
- | 10 This is line 14 | + | 10 This is line 14 |
- | 11 This is line 15 | + | 11 This is line 15 |
- | 12 This is line 16 | + | 12 This is line 16 |
- | 13 This is line 7 | + | 13 This is line 7 |
- | 14 This is line 8 | + | 14 This is line 8 |
- | 15 This is line 17 | + | 15 This is line 17 |
- | 16 This is line 18 | + | 16 This is line 18 |
- | 17 This is line 19 | + | 17 This is line 19 |
- | 18 This is line 7 | + | 18 This is line 7 |
- | 19 This is line 8 | + | 19 This is line 8 |
- | 20 This is line 7 | + | 20 This is line 7 |
- | 21 This is line 20 | + | 21 This is line 20 |
- | 22 This is line 21 | + | 22 This is line 21 |
- | 23 This is line 22 | + | 23 This is line 22 |
- | 24 This is line 23 | + | 24 This is line 23 |
- | 25 This is line 24 | + | 25 This is line 24Linux |
- | 26 This is line 25Linux | + | 3 lines moved |
- | 3 lines moved 20,1 All | + | |
</ | </ | ||
- | Note that by deleting lines 4 to 6, line 20 has become line 17. The three cut lines therefore appear after line 17 and not after line 20 : | + | =====LAB #8 - Configuring a Personalised Interface===== |
- | < | + | VI can be configured by any user to suit his/her requirements. This is achieved |
- | ... | + | |
- | 17 This is line 19 | + | |
- | 18 This is line 7 | + | |
- | 19 This is line 8 | + | |
- | 20 This is line 7 | + | |
- | ... | + | |
- | </ | + | |
- | + | ||
- | =====LAB #8 -Configuring a Personal VI Interface===== | + | |
- | + | ||
- | VI can be configured by each user by creating | + | |
< | < | ||
set nu | set nu | ||
set list | set list | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | ~ | ||
- | -- INSERT -- 2,9 All | ||
</ | </ | ||
- | <WRAP center round todo 60%> | + | <WRAP center round important |
- | **To do** - Save your vitext file and exit VI. Copy the above text and paste it into a new file called **.exrc** | + | **To do** - Save your vitext file and quit VI, copy the above text and paste it into a new file in your home directory |
</ | </ | ||
- | Now open the file **/ | + | Open the **/ |
< | < | ||
[trainee@redhat9 ~]$ vi vitext | [trainee@redhat9 ~]$ vi vitext | ||
</ | </ | ||
+ | |||
+ | You will see a result similar to that shown below: | ||
< | < | ||
- | 1 This is line Linux is wonderful1$ | + | |
- | 2 This is line 2$ | + | 2 This is line 2$ |
- | 3 This is line 3$ | + | 3 This is line 3$ |
- | 4 This is line 3$ | + | 4 This is line 3$ |
- | 5 This is line 9 | + | 5 This is line 9$ |
- | 6 This is line 10 | + | 6 This is line 10$ |
- | 7 This is line 11 | + | 7 This is line 11$ |
- | 8 This is line 12 | + | 8 This is line 12$ |
- | 9 This is line 13 | + | 9 This is line 13$ |
- | 10 This is line 14 | + | 10 This is line 14$ |
- | 11 This is line 15 | + | 11 This is line 15$ |
- | 12 This is line 16 | + | 12 This is line 16$ |
- | 13 This is line 7$ | + | 13 This is line 7$ |
- | 14 This is line 8$ | + | 14 This is line 8$ |
- | 15 This is line 17 | + | 15 This is line 17$ |
- | 16 This is line 18 | + | 16 This is line 18$ |
- | 17 This is line 19$ | + | 17 This is line 19$ |
- | 18 This is line 7$ | + | 18 This is line 7$ |
- | 19 This is line 8$ | + | 19 This is line 8$ |
- | 20 This is line 7$ | + | 20 This is line 7$ |
- | 21 This is line 20$ | + | 21 This is line 20$ |
- | 22 This is line 21 | + | 22 This is line 21$ |
- | 23 This is line 22 | + | 23 This is line 22$ |
- | 24 This is line 23 | + | 24 This is line 23$ |
- | 25 This is line 24 | + | 25 This is line 24Linux |
- | 26 This is line 25Linux | + | "vitext" |
- | ‘vitext 26L, 442B 20,1 All | + | |
</ | </ | ||
----- | ----- | ||
Copyright © 2024 Hugh Norris. | Copyright © 2024 Hugh Norris. |