90 likes | 213 Views
CSCI-1411 F undamentals o f C omputing L ab. Shane Transue. Spring 2014. Introduction. Problem: Need simple editors that can be used in the Unix console (why?) Moving files back-and-forth is tedious and error-prone Other editors may do things you don’t intend What editors should we use?
E N D
CSCI-1411 Fundamentals of Computing Lab Shane Transue Spring 2014
Introduction • Problem: Need simple editors that can be used in the Unix console (why?) • Moving files back-and-forth is tedious and error-prone • Other editors may do things you don’t intend • What editors should we use? • nano • vi • Why use simple console editors? • How do we use (nano and vi)?
Editor Introduction • Editors Covered • nano • Basic console-based text editor (simple) • vi • Command-based text editor (advanced) • What are we doing? • Creating a file • Editing the file • Saving the file • Exiting the editor
Why are we using Unix editors? • Edit, Compile, Run all from the command line (terminal) • Faster than always copying files • Practice! • More complex editors are easy to misuse • A .docx file will never compile using a C++ compiler (g++) • Provide an understanding for more complex editing environments (such as IDEs) • Need to understand what they are doing internally • What if a more complex editor is not doing what you want? • Part of a larger Software Engineering Ecosystem • Programmers and software engineers will understand what you are doing
nano Overview • Simple Text Editor • Opening and Editing Files (txt, cpp) • Creating a new file/Editing an existing file • What you see is what you get (WYSIWYG) • Help Ctrl+G • Basic Navigation • Moving around using arrow keys and tab • Saving and Exiting • Writing out to a file • Exiting nano
Using nano • Creating/Opening a file • nano test.cpp • Editing a file • Arrow Keys, Type away • Cut/Paste • Ctrl+^ (to select) • Ctrl + K (to cut), Ctrl + U (to paste) • Saving a file • Ctrl+O(type in filename and hit enter) • Exiting nano • Ctrl+X
vi Overview • Command Driven Text Editor • Commands Mode • Creating/Opening Files • Navigation • Saving a file • Insert Mode • Navigation • Writing a quick C++ program
Using vi • vi test.cpp • Command Mode • Default Mode • Enter Command mode with the “Esc” Key • :w filename.cpp (save to file: filename.cpp) • :q (Quit the vi editor) • Movement • H (Move left), L (right), J (down), K (up) • Insert Mode • Normal Input (like everyone is used to) • Enter Insert mode with the “i” key • Movement • Arrow Keys
Reference Guides and Links • Nano Website (GNU):http://www.nano-editor.org/ • Nano Guide: http://mintaka.sdsu.edu/reu/nano.html • Intractive Vi Tutorial: http://www.openvim.com/tutorial.html • Vi Cheat Sheet:http://www.lagmonster.org/docs/vi.html