Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
elearning:workbooks:redhat:rh124en:l101 [2024/11/04 13:30] adminelearning:workbooks:redhat:rh124en:l101 [2024/11/23 13:34] (Version actuelle) admin
Ligne 3: Ligne 3:
 Version : **2024.01** Version : **2024.01**
  
-Last update : ~~LASTMOD~~+Updated: ~~LASTMOD~~
  
-======RH12402 - The VI Editor======+======RH12402 - The VIsual Editor======
  
-=====Module content=====+=====Contents=====
  
-  * **RH12402 - The VI Editor**  +  * **RH12402 - The VIsual Editor** 
-    * Module content+    * Contents
     * Presentation     * Presentation
-    * LAB #1 - Creating, opening and closing files+    * LAB #1 - Creating, Opening and Closing files with VI
       * 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 a file in read-only mode using view 
-      * 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 line numbering with the set command +      * 2.2 - Turning on line numbering using set 
-    * LAB #3 - Moving within a File+    * LAB #3 - Moving around within the file
       * 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 and replacing text+      * 5.2 - Searching for and replacing text
     * LAB #6 - Deleting Text     * LAB #6 - Deleting Text
       * 6.1 - Commands       * 6.1 - Commands
-      * 6.2 - Deleting Lines+      * 6.2 - Deleting lines
     * 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 Interface
  
-=====Présentation=====+=====Presentation=====
  
-VI is a powerful text editor with three modes:+The **VI**sual Editor (a.k.a. **VI**) is a powerful text editor that operates in three basic modes :
  
   * //Command//   * //Command//
Ligne 44: Ligne 44:
   * //Insert//   * //Insert//
  
-In command mode, you can enter commands such as **i** to insert text.+In //Command// mode it is possible to use keys such as **i** to insert text.
  
-In Ex-Modemost VI commands are preceded by the <key>:</key> key, for example **:q** to quit.+In //Ex-mode// modeall commands sent to VI must be preceded by the <key>:</key> key.
  
-In insert mode, you can:+In //Insert// mode VI can be used to :
  
   * 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 existing text.
  
-=====LAB #1 - Createopen and close files=====+=====LAB #1 - CreatingOpening and Closing files with VI=====
  
-====1.1 - Commands===+====1.1 - Commands====
  
 ^ Command ^ Description^ ^ Command ^ Description^
-| **vi** //fileName// | Open or create a file +| **vi** //filename// | Edit //filename// starting at line 1 
-| **vi** | Opening a new file | +| **vi** | Edit a new file starting at line 1 
-| **vi -r** //filename//Recovering a file after a failure +| **vi -r** //filename//Recover //filename// that was being edited when system crashed 
-| **view** //filename// | Open a file in read-only mode | +| **view** //filename// | Open //filename// in read-only mode | 
-| **:wq** | Exit by saving and changing the modification date | +| **:wq** | Quit vi, writing out modified file to file named in original invocation and modify the //mtime// 
-| **ZZ** | The same as :wq +| **:x** | Quit vi, writing out modified file to file named in original invocation without modifying the //mtime// if the file was not modified | 
-| **:x** | Exit by saving without modifying the modification date if the file has not been modified | +| **: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 to the current line | 
-| **: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:
  
 <file> <file>
Ligne 107: Ligne 107:
 </file> </file>
  
-Create a new file called **vitext** using the vi command:+Create a new file called **vitext** using vi:
  
 <code> <code>
Ligne 116: Ligne 116:
 </code> </code>
  
-<WRAP center round todo 60%> +<WRAP center round important 60%> 
-**To do** - Press the **i** key on your keyboard to switch to //insert// mode. Click the middle button (the wheel) of your mouse to paste lines 1 to 25 into the fileThen use the <key>Escape</key> key to switch to //Command// mode. Press the <key>:</key> key followed by the <key>x</key> key to save and exit VI.+**To do** - Use the **i** key to change to //insert// mode. Paste lines 1 through 25. Hit the <key>Escape</key> key to move to //Command// mode. Now hit the <key>:</key> key followed by the <key>x</key> key to save the file and quit vi.
 </WRAP> </WRAP>
  
-====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 **/home/trainee/vitext** in read-only mode:+Now open **/home/trainee/vitext** in read-only mode:
  
 <code> <code>
Ligne 128: Ligne 128:
 </code> </code>
  
-You will get a result similar to this one:+You will obtain a result similar to the following example:
  
 <code> <code>
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[readonly] 25L, 391C
 </code> </code>
  
-<WRAP center round alert 60%> +<WRAP center round important 60%> 
-**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 lines.
 </WRAP> </WRAP>
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important**Note that the last line is marked [readonly].+**Important** Note the [readonly] statement on the last line.
 </WRAP> </WRAP>
  
-====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 **/home/trainee/vitext** file in read-write mode:+Quit using the **:q** command and open the file in read-write mode :
  
 <code> <code>
Ligne 176: Ligne 176:
 </code> </code>
  
-You will get a result similar to this one:+You will obtain a result similar to the following example :
  
 <code> <code>
Ligne 204: Ligne 204:
 This is line 24 This is line 24
 This is line 25 This is line 25
-~  +"vitext25L, 391C                                            25,1          All  
-vitext 25L, 391B 1,14 All+
 </code> </code>
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important**Note that vi is run in Command mode.+**Important** Note that VI is launched in **//Command//** mode. Note that there are 25 lines and 391 characters.
 </WRAP> </WRAP>
  
-=====LAB #2 - The set command===== +=====LAB #2 - The set Command=====
  
 ====2.1 - Commands==== ====2.1 - Commands====
  
 ^ Command ^ Description^ ^ Command ^ Description^
-| **:set nu** | Display line numbering | +| **:set nu** | Turns on line numbering | 
-| **:set number** | Display line numbering | +| **:set number** | Turns on line numbering | 
-| **:set nonu** | Suppress line numbering | +| **:set nonu** | Turns off line numbering | 
-| **:set nonumber** | Suppress line numbering | +| **:set nonumber** | Turns off line numbering | 
-| **:set ic** | Search without regard to case | +| **:set ic** | Turns on independent case searching 
-| **:set noic** | Search case sensitive |+| **:set noic** | Turns on case dependent searching |
  
-====2.2 - Enable line numbering with the set command==== +====2.2 - Turning on line numbering using set====
  
-Activate line numbering with the **:set nu** command or the **:set number** command. You will obtain a result similar to the following:+Turn on line numbering with the command of your choice. You will obtain a result similar to the following example:
  
 <code> <code>
-1 This is line 1 +  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,         All 
-:set nu 1,14 All+
 </code> </code>
  
-=====LAB #3 - Moving within file=====+<code> 
 +  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                                                   25,         All 
 +</code> 
 + 
 +=====LAB #3 - Moving around within the file=====
  
 ====3.1 - Commands==== ====3.1 - Commands====
  
 ^ Command ^ Description^ ^ Command ^ Description^
-| **h** or <key>Left</key> or <key>Backspace</key> | Move cursor one character to the left +| **h** or <key>Left</key> or <key>Backspace</key> | Move cursor left one character | 
-| **j** or <key>Down</key> or <key>Enter</key> | Move cursor one line down +| **j** or <key>Down</key> or <key>Enter</key> | Move cursor down one line  
-| **k** or <key>Up</key> | Move cursor one line up | Move cursor one character to the right +| **k** or <key>Up</key> | Move cursor up one line  
-| **l** or <key>Right</key> or <key>Spacebar</key> | Move cursor one character to the right +| **l** or <key>Right</key> ou <key>Space Bar</key> | Move cursor right one character | 
-| **b** | Move cursor one word to the left +| **b** | Move cursor back to beginning of preceding word | 
-| **w** | Moves cursor one word to the right +| **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 forward screen page +| **Ctrl+f** | Move forward one screen | 
-| **Ctrl+d** | Scroll forward half-screen page |  +| **Ctrl+d** | Move down (forward) one half screen | 
-| **Ctrl+b** | Scroll back one screen page +| **Ctrl+b** | Move backward one screen | 
-| **Ctrl+u** | Scroll back one half-screen page | +| **Ctrl+u** | Move up (backone 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> +
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important**: To find out why the <key>h</key>, <key>j</key>, <key>k</key> and <key>l</key> keys are used as a directional pad, see this [[http://www.catonmat.net/blog/why-vim-uses-hjkl-as-arrow-keys/|page]].+**To do** - Test each of the above commands. When you have finished, position the cursor at beginning of line 13. In order to understand why the <key>h</key>, <key>j</key>, <key>k</key> and <key>l</key> keys are used as arrow keysplease see this **[[http://www.catonmat.net/blog/why-vim-uses-hjkl-as-arrow-keys/|page]]**.
 </WRAP> </WRAP>
  
-=====LAB #4 - Text insertion=====+=====LAB #4 - Inserting Text=====
  
 ====4.1 - Commands==== ====4.1 - Commands====
  
 ^ Key(s) ^ Description^ ^ Key(s) ^ Description^
-| **i** | Insert text before the cursor | +| **i** | Insert text before cursor | 
-| **I** | Insert text at beginning of the line | +| **I** | Insert text at beginning of current line | 
-| **a** | Insert text after the cursor | +| **a** | Append text after cursor | 
-| **A** | Insert text at end of the line | +| **A** | Append text to end of current line | 
-| **o** | Insert line after the current line | +| **o** | Open and put text in a new line below current line  
-| **O** | Insert line before the current line +| **O** | Open and put text in a new line above current line | 
-| **R** | Replace existing text +| <key>Escape</key>Returns the editor to //Command// mode |
-| <key>Echap</key>Switch from //Insert// mode to //Command// mode |+
  
 ====4.2 - Inserting text==== ====4.2 - Inserting text====
  
-Insert a line below the current line using the **o** command. Note that you are now in //Insert// mode. Then type **Linux is super**. You will get a result similar to this one:+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 a result similar to the following example :
  
 <code> <code>
-1 This is line 1 +  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         Top
 </code> </code>
  
-<WRAP center round alert 60%> +<WRAP center round important 60%> 
-**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.
 </WRAP> </WRAP>
  
-Now switch to //Command// mode by pressing the <key>Escape</key> key, then position yourself on the last line of the screen using the **L** command. Go to the end of the line in //Insert// mode using the **A** command and enter the phrase **Linux is super** again. You'll get a result similar to this one:+Switch back to //Command// mode using the <key>Escape</key> key and place the cursor on the last line of the screen using the **L** command. Move the cursor to the end of the line in //Insert// mode using the **A** command and once again type **Linux is super**. You will obtain a result similar to the following example :
  
 <code> <code>
-1 This is line 1 +  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 is super 
-26 This is line 25Linux is super +-- INSERT --                                                  25,30         Top
--- INSERT -- 26,30 All+
 </code> </code>
  
-Now switch to //Command// mode by pressing the <key>Escape</key> key, then position yourself at the start of the first line of the screen using the **H** command. Position yourself at the fourth word using the **w** command three times. Switch to //Insert// mode using the **i** command, then type the phrase **Linux is super** again. You will get a result similar to this one:+Switch back to //Command// mode using the <key>Escape</key> key and move the cursor to the first line of the screen using the **H** command. Move the cursor to the third word by pressing the **w** key 3 times. Switch to //Insert// mode using the **i** key and type **Linux is super**. You will obtain a result similar to the following example :
  
 <code> <code>
-1 This is line Linux is super1 +  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 is super 
-26 This is line 25Linux is super +-- INSERT --                                                  1,28          Top
--- INSERT -- 1,27 All+
 </code> </code>
  
-Now switch to //Command// mode by pressing the <key>Escape</key> key, then move to the beginning of the first line of the screen using the **H** command. +Switch back to //Commande// mode using the <key>Escape</key> key and move the cursor to the first line of the screen using the **H** command. 
  
-=====LAB #5 - Text search=====+=====LAB #5 - Searching for Text=====
  
 ====5.1 - Commands==== ====5.1 - Commands====
  
 ^ Key(s) ^ Description^ ^ Key(s) ^ Description^
-| **/** //string// | Search //string// downwards +| **/** //string// | Search forward for occurrence of string in text 
-| **%%//%%** | Search for the next occurrence down from the last search +| **%%//%%** | Search forward for next occurrence of string in text 
-| **?** | Search for //string// upwards +| **?** //string// | Search backward for occurrence of string in text 
-| **??** | Search for the next occurrence up from the last search +| **??** | Search backward for next occurrence of string in text 
-| **n** | Search for the next occurrence of //string// in the direction of the search +| **n** | Move to next occurrence of search string | 
-| **N** | Search for the previous occurrence of //string// in the direction of the search +| **N** | Move to next occurrence of search string in opposite direction | 
-| **:g/**//string//**%/s//%%**//string1//**/g** | Search and replace //string// with //string1// |+| **:g/**//string//**%%/s//%%**//string1//**/g** | Search and replace //string// by //string1// |
  
-====5.2 - Find and replace text====+====5.2 - Searching for and replacing text====
  
-Now search for the string //super// using the **%%/super%%** command followed by the <key>Enter</key> keyThen search for the next two occurrences using the command **%%//%%** follow by the <key>Enter</key> key then **%%//%%** follow by the <key>Enter</key> keyAt this point your cursor should be on the last word of the last line of your screen.+Search the text for the string //super// by using the **%%/super%%** command. Now search the next two occurrences using the **%%//%%** command twiceYour cursor should now be at the beginning of the last word on the last line.
  
-Then search upwards for the //super// string using the **?super** command follow with the <key>Enter</key> key. Your cursor should be on line 14.+Now search backwards for the same string using the **?super** command. Your cursor should now be on the line in the middle of the screen.
  
-Now press the **n** key. Your cursor should be on the first line. Then press the **N** key. Your cursor must be on line 14.+Now use the **n** command. Your cursor should be on the first line. Now use the **N** command. Your cursor should now be, once again, on the line in the middle of the screen.
  
-Press the **H** command. Now replace the word //super// with //wonderful// using the command **%%:g/super/s//wonderful/g%%** followed by the <key>Enter</key> key. VI confirms the replacement:+Place the cursor at the beginning of the first line and //search and replace// the string **super** by the string **wonderful** using the following command :
  
-<code> +**%%:g/super/s//wonderful/g%%** 
-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 +
-:g/super/s//wonderful/+
-</code>+
  
 <code> <code>
-1 This is line Linux is wonderful1 +  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 is wonderful 
-26 This is line 25Linux is wonderful +3 substitutions on 3 lines                                    25,1          Top
-3 substitutions on 3 lines 26,1 All+
 </code> </code>
  
-=====LAB #6 - Deleting text=====+=====LAB #6 - Deleting Text=====
  
 ====6.1 - Commands==== ====6.1 - Commands====
  
 ^ Key(s) ^ Description^ ^ Key(s) ^ Description^
-| **x** | Delete current character | +| **x** | Delete single character under cursor 
-| **X** | Delete character to left of the cursor | +| **X** | Delete single character to the left of cursor | 
-| **5x**| Delete 5 characters from current character |+| **5x** | Delete 5 characters, starting with character under cursor |
 | **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 the current line | 
-| **5dd** | Delete 5 lines starting from current line |+| **5dd** | Delete 5 lines starting with the line under cursor |
 | **: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 14 and delete it using the **dd** command. You will obtain a result similar to the following example :
  
 <code> <code>
-1 This is line Linux is wonderful1 +  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+
 </code> </code>
  
-Now delete lines 4, 5 and 6 using the **:4,6 d** command. You will get a result similar to this one:+Note the contents of lines 4 through 6. Now delete those lines using the following command: 
 + 
 +**:4,6 d** 
 + 
 +You will obtain a result similar to the following example :
  
 <code> <code>
-1 This is line Linux is wonderful1 +  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                                                 4,1           All
-3 fewer lines 4,1 All+
 </code> </code>
  
- +=====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) the line(s) in the buffer into the text after the current line | 
-| **P** | Paste the line cut or copied above the current line  +| **P** | Put (paste) the line(s) in the buffer into the text before the current line | 
-| **: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** line 7 | 
-| **: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 - Copycut and paste text====+====7.2 - CopyingCutting and pasting text====
  
-Place your cursor on line 3. Copy it using the **yy** command. Place your cursor on line 5 and use the **p** command. You will get the following result:+Move the cursor to line 3 and copy it using the **yy** command. Move to line 5 and paste the line using the **p** command:
  
 <code> <code>
-1 This is line Linux is wonderful1 +  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                                                 6,1           All
-3 fewer lines 6,1 All+
 </code> </code>
  
-Place your cursor on line 4 and use the **Y** command. Place your cursor on line 6 and use the **P** command. You will get the following result:+Move your cursor to line 4 and copy it using the **Y** command. Now move your cursor to line 6 and paste the copied line using the **P** command. You will obtain a result similar to the following example:
  
 <code> <code>
-1 This is line Linux is wonderful1 +  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                                                 6,1           All
-3 fewer lines 6,1 All+
 </code> </code>
  
-Use the command **:4,5 co 15**. You will get the following result:+Now use the following command **:4,5 co 15**. You will obtain a result similar to the following example:
  
 <code> <code>
-1 This is line Linux is wonderful1 +  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 is wonderful 
-26 This is line 25Linux is wonderful +:4,5 co 15                                                    17,1          Top
-:4,5 co 15 17,1 All+
 </code> </code>
  
-Note that lines 4 and 5 have been copied after line 15 :+Note that lines 4 and 5 have been copied to after line 16:
  
 <code> <code>
 ... ...
-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
 ... ...
 </code> </code>
  
-Use the command **:4,6 m 20**. You will get the following result:+Now use the following command**:4,6 m 20**. You will obtain a result similar to the following example:
  
 <code> <code>
-1 This is line Linux is wonderful1 +  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 is wonderful 
-26 This is line 25Linux is wonderful +3 lines moved                                                 20,1          Top
-3 lines moved 20,1 All+
 </code> </code>
  
-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=====
  
-<code> +VI can be configured by any user to suit his/her requirements. This is achieved by creating and editing the file **~/.exrc**. The file is read by VI each time it is launched by that user and the commands contained in it are executed. The format of each command is the same as if it were typed by the user within VI //except// that the leading **:** character is omitted. For example the following .exrc file would tell VI to turn on line numbering and show hidden characters: 
-... +
-17 This is line 19 +
-18 This is line 7 +
-19 This is line 8 +
-20 This is line 7 +
-... +
-</code> +
- +
-=====LAB #8 -Configuring a Personal VI Interface===== +
- +
-VI can be configured by each user by creating file called **~/.exrc**. This file must contain the option commands as they are typed on the command line but without the **:** character. The **~/.exrc** file is read by VI when it is launched and the options set. For examplethe following file will activate the //line numbering// and //visibility of hidden characters// options:+
  
 <file> <file>
 set nu set nu
 set list set list
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
--- INSERT -- 2,9 All 
 </file> </file>
  
-<WRAP center round todo 60%> +<WRAP center round important 60%> 
-**To do** - Save your vitext file and exit VI. Copy the above text and paste it into a new file called **.exrc** in your home directory.+**To do** - Save your vitext file and quit VI, copy the above text and paste it into a new file in your home directory called **.exrc**.
 </WRAP> </WRAP>
  
-Now open the file **/home/trainee/vitext** with VI:+Open the **/home/trainee/vitext** file using VI:
  
 <code> <code>
 [trainee@redhat9 ~]$ vi vitext [trainee@redhat9 ~]$ vi vitext
 </code> </code>
 +
 +You will see a result similar to that shown below:
  
 <code> <code>
-1 This is line Linux is wonderful1$ +  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 is wonderful$ 
-26 This is line 25Linux is wonderful$ +"vitext26L, 442C                                            20,1          Top
-vitext 26L, 442B 20,1 All+
 </code> </code>
  
 ----- -----
 Copyright © 2024 Hugh Norris. Copyright © 2024 Hugh Norris.
Menu