DOC PREVIEW
FSU COP 3353 - Lecture 3 emacs and vi

This preview shows page 1-2-3-4-5-6 out of 17 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Lecture 3emacsemacs - basic commandsemacs - cutting and pastingemacs - command summaryemacs - command summary contviStarting vivi - saving and quittingMoving the cursorMoving the cursor continuedvi - inserting textvi - changing and replacing textvi - deleting textvi - searching for textvi - searching and replacing textA few helpful vi links1Lecture 3More on editors: emacs and viCOP 3344 Introduction to UNIX2emacs•In order to use emacs via the secure shell, you need to do the following:–Download and run the program X-Win32–Edit profile so that TunnelX11 connections is enabled (Tunneling)•The command "emacs" will start the "emacs" text editor in "scratch" mode, with an empty buffer•"Scratch" mode is a pain to use, will not warn you about saving your work, and will cause various other grief•Specifying a file name will have "emacs" open that file (or start a new file).•emacs (avoid this)•emacs <filename>3emacs - basic commands•Arrow keys are used to navigate around document•If configured, the mouse can work, but you will learn to work without it•The caret symbol (^) indicates you must press and hold the control key first, then press the key for the command.Undo!•^x u or ^- will undo the most recent command (one of the only places in UNIX where you can undo something)Saving•^x ^s saves the buffered text to the currently specified file•^x ^c exits "emacs"4emacs - cutting and pasting•^k cuts text (kills) from cursor to end of line•^y pastes text (yanks back)•^@ (ctrl-shift-2) sets a "Mark" at the current cursor position•Use the arrow keys to move to the end of the text you want to cut (will not highlight)•^w cuts text from "Mark" to current cursor position•Move to position you want to insert the cut text•^y then brings the text back at the current cursor position5emacs - command summary(arrows)Move cursor(bksp)Move cursor left one space, deleting character (this may or may not work depending on your configuration)(del)Typically works like you would expect bksp to work^aMove to beginning of line^bMove back one character (same as left arrow)^eMove to end of line^fMove forward one character (same as right arrow)^nMove to next line (same as down arrow)^pMove to previous line (same as up arrow)^vMove forward one page6emacs - command summary cont^x ^sSave buffered text to currently specified file^x ^wWrite buffered text to a specific file^x ^fFind a file and copy it into buffer^x ^cExit "emacs" (if you are in "scratch" mode it will NOT warn you to save your work)^dDelete character at current position^sSearch forward^rSearch backward^kCut (Kill) text from cursor to end of line^@Set "Mark"^wCut text from "Mark" to current cursor position^yPaste text at current cursor position^x uUndo most recent command^-Undo most recent command (alternate)^gCancel command ("Get out" of a string of ctrl commands)7vi•vi is available on most Unix systems and is as powerful as emacs - personal preference on which one to use•vi <filename>•vi has two modes–Command mode: in this mode characters you type are interpreted as commands–Insert mode: characters you type are inserted as part of the text–vi starts out in insert mode–Typing i switches to insert mode–The ESC key puts you back in command mode•vi is case sensitive so upper case and lower case commands act differently•Commands are not displayed on the screen and do not require a return or enter8Command Description vi file start at line 1 of fi l e vi +n file start at line n of file vi + file start at last line of file vi +/pattern file start at pattern in file vi -r file recover file after a system crash Starting vi9vi - saving and quittingCommand Description :e fil e edit f i l e (save current file with :w first) :w save (write out) the file being edited :w file save as fi l e :w! file save as an existing file :q quit vi :wq save the file and quit vi :x save the file if it has changed and quit vi :q! quit vi without saving changes10Keys pressed Effect h left one character l or <Space> right one character k up one line j or <Enter> down one line b left one word w right one word ( start of sentence ) end of sentence { start of paragraph } end of paragraph Moving the cursor11Keys pressed Effect 1G top of file nG line n G end of file <Ctrl>W first character of insertion <Ctrl>U up ½ screen <Ctrl>D down ½ screen <Ctrl>B up one screen <Ctrl>F down one screen Moving the cursor continued12Keys pressed Text inserted a after the cursor A after last character on the line i before the cursor I before first character on the line o open line below current line O open line above current line vi - inserting text13Keys pressed Text changed or replaced cw word 3cw three words cc current line 5cc five lines r current character only R current character and those to its right s current character S current line ~ switch between lowercase and uppercase vi - changing and replacing text14Keys pressed Text deleted x character under cursor 12x 12 characters X character to left of cursor dw word 3dw three words d0 to beginning of line d$ to end of line dd current line 5dd five lines d{ to beginning of paragraph d} to end of paragraph :1,. d to beginning of file :.,$ d to end of file :1,$ d whole file vi - deleting text15Search Finds /and next occurrence of ``and'', for example, ``and'', ``stand'', ``grand'' ?and previous occurrence of ``and'' /^The next line that starts with ``The'', for example, ``The'', ``Then'', ``There'' /^The\> next line that starts with the word ``The'' /end$ next line that ends with ``end'' /[bB]ox next occurrence of ``box'' or ``Box'' n repeat the most recent search, in the same direction N repeat the most recent search, in the opposite direction vi - searching for text16Command Description :s/pear/peach/g replace all occurrences of ``pear'' with ``peach'' on current line :/orange/s//lemon/g change all occurrences of ``orange'' into ``lemon'' on next line containing ``orange'' :.,$^<file/directory/g replace all words starting (note word anchor ^<) with ``file'' by ``directory'' on every line from current line onward, for example, ``filename'' becomes ``directoryname'' :g/one/s//1/g replace every occurrence of ``one'' with 1, for example, ``oneself'' becomes ``1self'', ``someone'' becomes ``some1'' vi - searching and replacing textA few helpful vi links•vi Manual (on our department’s web


View Full Document

FSU COP 3353 - Lecture 3 emacs and vi

Download Lecture 3 emacs and vi
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 3 emacs and vi and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 3 emacs and vi 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?