Presentation is loading. Please wait.

Presentation is loading. Please wait.

ITX2000 Remote hosts and web servers Prof. Xiaohong (Sharon) Gao Room: T125 Ext: 12252 Week 14 – UNIX vi text editor.

Similar presentations


Presentation on theme: "ITX2000 Remote hosts and web servers Prof. Xiaohong (Sharon) Gao Room: T125 Ext: 12252 Week 14 – UNIX vi text editor."— Presentation transcript:

1 ITX2000 Remote hosts and web servers Prof. Xiaohong (Sharon) Gao Room: T125 Ext: 12252 Email: x.gao@mdx.ac.ukx.gao@mdx.ac.uk Week 14 – UNIX vi text editor Reference: http://www.w3schools.com/phphttp://www.w3schools.com/php

2 Start Ubuntu  Start VMware Player   Select Ubuntu 

3 Login to Ubuntu Username :itx2000 Password:MDXstudent

4 Switch mouse click Click in the virtual screen to work on UNIX systems. Ctrl + Atl to work on Windows.

5 VI (visual editor)  The vi editor (short for visual editor) is a screen editor which is available on almost all Unix systems.  Once you have learned vi, you will find that it is a fast and powerful editor.  vi has no menus but instead uses combinations of keystrokes in order to accomplish commands.

6 Starting vi  To start using vi, at the Unix prompt type vi followed by a file name.  vi myFile.txt (then hit return)

7 vi's Modes and Moods  vi has two modes: the command mode and the insert mode.  When you are in command mode, letters of the keyboard will be interpreted as commands.  When you are in insert mode the same letters of the keyboard will type or edit text.  vi always starts out in command mode.  You can type i to enter the insert mode.  If you wish to leave insert mode and return to the command mode, hit the ESC key.  If you're not sure where you are, hit ESC a couple of times and that should put you back in command mode.

8 General Command Information As mentioned previously, vi uses letters as commands. It is important to note that in general vi commands:  are case sensitive - lowercase and uppercase command letters do different things  are not displayed on the screen when you type them  generally do not require a Return after you type the command. You will see some commands which start with a colon (:).

9 Entering Text  To begin entering text in an empty file, you must first change from the command mode to the insert mode.  To do this, type the letter i.  When you start typing, anything you type will be entered into the file.  Type a few short lines and hit Return at the end of each of line.  Unlike word processors, vi does not use word wrap. It will break a line at the edge of the screen.  If you make a mistake, you can use Delete or Backspace key to remove your errors.

10 Cursor Movement You must be in command mode if you wish to move the cursor to another position in your file. If you've just finished typing text, you're still in insert mode and will need to press ESC to return to the command mode. Moving One Character at a Time Try using your direction keys to move up, down, left and right in your file. Sometimes, you may find that the direction keys don't work. If that is the case, to move the cursor one character at the time, you may use the h, j, k, and l keys.  h left one space  l right one space  j down one space  k up one space

11 Moving among Words and Lines  There are some shortcut keys that you can use to move a little more quickly through a document.  To move more quickly among words, you might use the following:  w moves the cursor forward one word  b moves the cursor backward one word (if in the middle of a word, b will move you to the beginning of the current word).  e moves to the end of a word.  To build on this further, you can precede these commands with a number for greater movement.  For example,  5w would move you forward five words;  12b would move you backwards twelve words.  [You can also use numbers with the commands mentioned earlier.  For example, 5j would move you down 5 characters.]

12 Summary – vi basics (view)  vi to open a file for editing  ←↑→↓ move the cursor left up right and down. also j,k,h,l accomplish the same thing  x or Delete delete the letter over the cursor  dd deletes a line  dw deletes the word  yy yanks a line into the buffer,  pp paste the line at the cursor,  / performs a regular expression search for a certain word i.e., ‘/test ↵ ’ will place the cursor at the first instance of the word  cw allows you to change the word under the cursor (press esc when done)  r allows you to change the character under the cursor.

13 Summary – vi basics (insert) i, I puts vi into insert (edit) mode at/before the cursor o, O puts vi into insert mode above/below the current line ( it creates a new line) a, A inserts text at the beginning/ending of the current line. To exit insert mode hit the ESC key.

14 Summary – vi basics (command) to enter command mode use : in view mode or esc : in insert mode Basic Command options  :q Quit vi,  :w save the current file,  :qw save the file and quit vi  :q! force quite vi without writing changes  :/ find selected pattern in file  :^ go to the beginning of the file  :$ go to the end of the current file.  : got to the line number in the file.

15 CW2 – part 1 (25%) Task 1 (25%). Using vi editor to create a file in a UNIX-like environment. For example, type in the following paragraph: In multitasking computer operating systems, a daemon is a computer program that runs as a background process, rather than being under the direct control of an interactive user. Traditionally daemon names end with the letter d: for example, ‘syslogd’ is the daemon that implements the system logging facility and ‘sshd’ is a daemon that services incoming ‘SSH’ connections. In a Unix environment, the parent process of a daemon is often, but not always, Deadline: week 22 (March 23-27), to show to the lab tutors


Download ppt "ITX2000 Remote hosts and web servers Prof. Xiaohong (Sharon) Gao Room: T125 Ext: 12252 Week 14 – UNIX vi text editor."

Similar presentations


Ads by Google