Changes

Jump to: navigation, search

Tutorial2: Unix / Linux File Management

829 bytes added, 08:49, 13 January 2021
Part 2: Creating Text Files Using The vi Text Editor
# Issue the following Linux command to edit a text file called '''othertext.txt''' in the '''linux/practice''' directory:<br><span style="color:blue;font-weight:bold;font-family:courier;">nano textedit/practice/othertext.txt</span><br><br>'''NOTE:''' When using the '''Nano''' text editor, you are placed in '''COMMAND''' mode, so you need to issue a command to switch to ''INPUT'' mode.<br><br>[[Image:vi-text-editor-a.png|right|400px|thumb|Enter the following text that appears in this diagram.]]
# Press Type the following key to enter ''INPUT'' mode: <span style="color:blue;font-weight:bold;font-family:courier;">i</span><br><br>
# Enter the line shown in the other diagram of the vi text editor on the right side.<br><br>'''NOTE:''' Refer to the table below for a list of<br>the most common '''vi''' ('''vim''') navigation &amp; editing commands:<br><br><table cellpadding="5"><tr><th style="border-bottom: 1px solid black;">Key(s)</th><th style="border-bottom: 1px solid black;">Purpose</th></tr><tr><td style="font-family:courier">'''i'''</td><td>Enter '''INPUT''' mode</td></tr><tr><td style="font-family:courier">'''&lt;esc&gt;'''</td><td>Return to '''COMMAND''' MODE</td></tr><tr><td style="font-family:courier">'''x'''</td><td>Delete text to the right in COMMAND mode</td></tr><tr><td style="font-family:courier">'''W'''</td><td>Move forward one word in COMMAND mode</td></tr><tr><td style="font-family:courier">'''B'''</td><td>Move back one word in COMMAND mode</td></tr><tr><td style="font-family:courier">'''dd'''</td><td>Cut line in COMMAND mode</td></tr><tr><td style="font-family:courier">'''yy'''</td><td>Copy Line in COMMAND mode</td></tr><tr><td style="font-family:courier">'''p / P'''</td><td>Paste Cut/Copied Text below/above line in COMMAND mode</td></tr><tr><td style="font-family:courier">'''u'''</td><td>Undo previous editing command</td></tr><tr><td style="font-family:courier">''':help'''</td><td>Display help screen in COMMAND mode</td></tr><tr><td style="font-family:courier">''':x'''</td><td>Save editing changes and exit (in COMMAND mode)</td></tr><tr><td style="font-family:courier">''':w name'''</td><td>Save editing changes to "name" in COMMAND mode</td></tr><tr><td style="font-family:courier">''':q!'''</td><td>Abort editing session and exit (in COMMAND mode)</td></tr></table><br>
# While on the first line, press the following key to enter ''COMMAND'' mode: <span style="color:blue;font-weight:bold;font-family:courier;">ESC</span><br><br>
# Press Type the following keys to <u>copy</u> the current line: <span style="color:blue;font-weight:bold;font-family:courier;">yy</span><br><br># Press Type the following key to <u>copy</u> the current line: <span style="color:blue;font-weight:bold;font-family:courier;">p</span><br><br>What did you notice?<br><br># Press Type the following keys: <span style="color:blue;font-weight:bold;font-family:courier;">u</span><br><br>What did you notice?<br><br># Press Type the following key to undo changes: <span style="color:blue;font-weight:bold;font-family:courier;">u</span><br><br>What did you notice?<br><br># Press Type the following keys: <span style="color:blue;font-weight:bold;font-family:courier;">4p</span><br><br>What did you notice?<br><br>[[Image:vi-text-editor-b.png|right|400px|thumb|Enter the following text that appears in this diagram.]]# Use a combination of arrow keys and the w and b keys while in COMMAND mode to change the correct words for the second to fourth lines (refer to diagram on right).<br><br># Move to the 4th line (i.e. last line).<br><br># Type the following keys: <span style="color:blue;font-weight:bold;font-family:courier;">dd</span><br><br>What did you notice?<br><br>Let's save editing changes and exit the vi text editor.<br><br># Type the following keys: <span style="color:blue;font-weight:bold;font-family:courier;">:x</span><br><br>What did you notice?<br><br># Issue the same command that you performed in '''Step #1''' to confirm that you had properly edited that file.<br><br># '''Save''' and '''exit''' your vi editing session.<br><br>[[Image:vi-text-editor-2.png|right|250px|thumb|The online vi-tutorial provides users "hands-on" experience of using the vi text editor.]]
An '''online tutorial''' has been created to give you "hands-on" experience on how to use vi text editor. It is <u>recommended</u> that you run this online tutorial in your Matrix account to learn how to create and edit text files with the vi text editor.
 
 
 
# Issue the following to run the vi online tutorial:<br><span style="color:blue;font-weight:bold;font-family:courier;">/home/murray.saul/vi-tutorial<br><br>
# In the tutorial menu, select the first menu item labelled "'''USING THE VI TEXT EDITOR'''"<br><br>
13,420
edits

Navigation menu