Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Unix Editors (ee, ed, ex, vi, vim) and Compilers (g77, gcc) Speaker: Li-Wen Chen Date: 2011-07-19.

Similar presentations


Presentation on theme: "1 Unix Editors (ee, ed, ex, vi, vim) and Compilers (g77, gcc) Speaker: Li-Wen Chen Date: 2011-07-19."— Presentation transcript:

1 1 Unix Editors (ee, ed, ex, vi, vim) and Compilers (g77, gcc) Speaker: Li-Wen Chen Date: 2011-07-19

2 2 Introduction line-oriented editor  ed  ex screen oriented editor  ee  vi - a screen-based editor used by many Unix users.  vim - Vi IMproved

3 3 ed Starting the ed Editor  $ ed [ filename ] [ ] means it is optional After entering, ed is in command mode.  command mode allows the entry of commands to manipulate text a – (append) go to input mode  input mode puts anything typed on the keyboard into the current file. – terminate input mode Commands about quit ed  w – write (save file)  q - quit

4 4 Other ed commands  a – append after the specified line  i – insert before the specified line  c – change the specified line . – the current line , or % - the first line  $ - the last line  l – list (print, display)  d – delete  u – undo Key in the character, and then enter input mode

5 5 vi Starting the VI Editor  $ vi [ filename ] After entering  command mode allows the entry of commands to manipulate text i – (insert) go to insert mode  insert mode puts anything typed on the keyboard into the current file Esc – go to command mode Commands about quit vi  :q – quit the vi editor  :w – write (save file)  :wq or ZZ – write and quit  :q! – force vi to quit

6 6 Inserting New Text I – i nsert from the beginning of the current line A – a ppend at the end of the current line a – a ppend after the current cursor position i – insert before the current cursor position O – create a new line above the current cursor position o – create a new line below the current cursor position Type these characters, and then enter insert mode.

7 7 Type Commands [count] command  command – most commands are one character long  count – a number, any character from 1 to 9 Ex: 10x  x – delete a characters under the cursor  10x – delete 10 characters at a time

8 8 Moving the Cursor k - ↑, move the cursor up one line. j - ↓, move the cursor down one line. h - ←, move the cursor to the left one character position. l - →, move the cursor to the right one character position. ^ - Move the cursor to the first non-whitespace character. $ - Move the cursor to the end of the current line. % - Move the cursor to the matching parenthesis or brace.

9 9 Moving the Cursor (cont.) ctrl F  Scroll forwards one page. A count scrolls that many pages. ctrl B  Scroll backwards one page. A count scrolls that many pages. ctrl D  Scroll forwards half a window. A count scrolls that many lines. ctrl U  Scroll backwards half a window. A count scrolls that many lines. G - Go to the line number specified as the count. If no count is given, then go to the end of the file. gg - go to the beginning of the file

10 10 Edit r - replace one character under the cursor. x - delete character under the cursor. ~ - Switch the case of the character under the cursor. u - undo the last change to the file. d^ - delete from current cursor position to the beginning of the line. d$ - delete from current cursor position to the end of the line. dw - delete from current cursor position to the end of the word. 3dd - delete three lines from current cursor position downwards. y (copy) and p (paste) are similar to d.

11 11 Search and Replace / - Search the file downwards for the string specified after the /. ? - Search the file upwards for the string specified after the ?. n - Repeat the last search given by '/' or '?' N - Repeat the last search given by '/' or '?‘, but in opposite direction  For example: /\ should find only word the, but not words like these: there and other. :s . – current position  $ - the last line  for example: :1,$ s/buffer/BUF/ from first line to last line :.,$ s/money/Money/g from current line to last line

12 12 Other useful vi commands <<  Shifts the current line to the left by one shift width. >>  Shifts the current line to the right by one shift width. :set autoindent or :set ai. To unset it, you can type :set noautoindent or :set noai :set nu :set nonu

13 g77 =GNU Fortran  the Fortran development system for Project GNU GNU  GNU's Not UNIX  non-profit organization a free replacement for the UNIX f77 replaced by gfortran since release 4.0

14 GNU Compiler Collection (GCC) GNU C Compiler  C  a replacement for the UNIX cc →GNU Compiler Collection:  C, C++, Fortran, Pascal, Java cross-compiler

15 gcc test.c ./a.out gcc test.c -o test ./test -Wall  警告訊息 gcc - I /usr/X11R6/include - L /usr/X11R6/lib - l X11 test.c -o test

16 16 Reference $man ed Mastering the VI editor GNU Fortran 77 (g77) Legacy Site


Download ppt "1 Unix Editors (ee, ed, ex, vi, vim) and Compilers (g77, gcc) Speaker: Li-Wen Chen Date: 2011-07-19."

Similar presentations


Ads by Google