Text Editors for Programmers. Dr. Prasad Kulkarni Michael Jantz Jamie Robinson

Similar documents
Text Editors for Programmers. EECS-678 Staff

Editors in Unix come in two general flavours:

Computer Programming Lecture 3 이윤진서울대학교

Emacs manual:

Bok, Jong Soon

Basic vi Commands. What is vi? To Get Into and Out Of vi

Unix Philosophy, Text Editors, IDEs

INTRODUCTION TO VIM. John Kerl University of Arizona Department of Mathematics Software Interest Group September 7, 2005

vi filename edit filename starting at line 1

Lab 1: Using Oz/Mozart IDE

Mastering Linux by Paul S. Wang Appendix: The emacs Editor

Using CRISP. I. CRISP Basics To create a new file, at the UNIX prompt type: cr newfilename

VIM Guide. Meher Krishna Patel. Created on : Octorber, 2017 Last updated : May, More documents are freely available at PythonDSP

entity tomove over backward forward character C-b C-f word M-b M-f line C-p C-n go to line beginning (or end) C-a C-e sentence M-a M-e paragraph M- M-

1 Ctrl + X Cut the selected item. 2 Ctrl + C (or Ctrl + Insert) Copy the selected item. 3 Ctrl + V (or Shift + Insert) Paste the selected item

The Xemacs Editor. Overview

Program Development Tools. Lexical Analyzers. Lexical Analysis Terms. Attributes for Tokens

TNM093 Practical Data Visualization and Virtual Reality Laboratory Platform

VIP Quick Reference Card

Introduction to EMACS. Harriet Borton Academic and Research Computing

Helpful Tips for Labs. CS140, Spring 2015

VIM Tips and Tricks. Search and replace a string in a document : :.,$s/search_string/replacement_string/g

Linux 下代码查看 编辑 编译与调试 (I) 袁华

Lab 3, Part 1: Using Oz/Mozart IDE

FILE MAINTENANCE COMMANDS

DOCQSCRIBE 7.1 KEYBOARD SHORTCUTS

Introduction. File System. Note. Achtung!

Using the Vi Text Editor

MICROSOFT EXCEL KEYBOARD SHORCUTS

Tracktion Shortcut Keys

Vim Habits. Detect inefficiency Find a quicker way Make it a habit

CHE3935. Lecture 1. Introduction to Linux

Princeton University COS 217: Introduction to Programming Systems Emacs Reference and Tutorial

Switch between open apps Close the active item, or exit the active app

Mills HPC Tutorial Series. Linux Basics I

Recitation #1 Boot Camp. August 30th, 2016

Intel Edison Tutorial: Introduction to Vim 1

Mouse Navigation. Middle Button (wheel) Pan. Click + Drag. Re-Center View. Double-Click. Context Menu. Tool Operation. Click. Click. Multi-Select.

Microsoft Excel > Shortcut Keys > Shortcuts

CSCI 211 UNIX Lab. Text Editor - Vi. Dr. Jiang Li. Jiang Li, Ph.D. Department of Computer Science

Operating System Interaction via bash

Modern Vim. Extracted from: Craft Your Development Environment with Vim 8 and Neovim. The Pragmatic Bookshelf

BEG 6. 50p. Getting Started with the Emacs Screen Editor. An introduction to the Emacs screen editor, which is available on Unix systems.

Introduction to the Emacs Editor

213/513/613 Linux/Git Bootcamp. Cyrus, Eugene, Minji, Niko

<<<<<<<<<<BASIC VI COMMANDS>>>>>>>>>>>>>>>>>>

Once you have installed MobaXterm, open MobaXterm. Go to Sessions -> New Session, and click on the SSH icon.

Lab 3a Using the vi editor

CSE 391 Lecture 1. introduction to Linux/Unix environment

vi Primer Adapted from:

Basic File Attributes

Part I. UNIX Workshop Series: Quick-Start

Introduction to GNU Emacs

K e y b o a r d s h o rt c ut s

Recitation #1 Unix Boot Camp. August 29th, 2017

Chapter 1 An Introduction to C++, Unix, SSH and Komodo Edit

Intermediate Programming, Spring Misha Kazhdan

Phil Sung. Special thanks to Piaw Na and Arthur Gleckler

15-122: Principles of Imperative Computation

Eugene, Niko, Matt, and Oliver

Introduction to Linux Environment. Yun-Wen Chen

RH033 Red Hat Linux Essentials

Computer Networks Vim and Emacs. Seongjin Lee

Getting Started With XEmacs

Introduction to UNIX Part II

Getting Started. Running Utilities. Shells. Special Characters. Special Characters. Chapter 2 Unix Utilities for non-programmers

viplugin User Manual v2.6.0

Using the Zoo Workstations

A beginner s guide to (GNU) Emacs 24

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Once you compile, Vim automatically takes you to the first line that is causing the error. To go to the next error; use :cn to take you to the next li

! Emacs Howto Tutorial!

CSE 391 Lecture 1. introduction to Linux/Unix environment

Connecting to ICS Server, Shell, Vim CS238P Operating Systems fall 18

Introduction to 9.0. Introduction to 9.0. Getting Started Guide. Powering collaborative online communities.

CSE Linux VM. For Microsoft Windows. Based on opensuse Leap 42.2

Appendix J: Using Shortcut Keys and Shortcut Menus

VI (and Clone) Introductory Guide

Computer Shortcut Keys

Practical Vim, Second Edition

Getting Started With UNIX Lab Exercises

STAR OFFICE WRITER. Lesson 1

Intro. To Unix commands. What are the machines? Very basics

Short Read Sequencing Analysis Workshop

Introduction. SSH Secure Shell Client 1

User s Guide. Valvova Oy

Carnegie Mellon. Linux Boot Camp. Jack, Matthew, Nishad, Stanley 6 Sep 2016

VI Commands Cheat Sheets

emacs Know your tools emacs keys Minimal number of key commands for emacs GNU Emacs is an extensible, customisable text editor-and more

Chapter 1 An Introduction to C++, Unix, SSH and Komodo Edit

CS197U: A Hands on Introduction to Unix

Getting started with Hugs on Linux

Introduction to the UNIX command line

Switches between worksheet and menu / Ribbon. Calculates all worksheets in all open workbooks. Highlights shortcut keys of Menu and Ribbon items.

Unix File System. Learning command-line navigation of the file system is essential for efficient system usage

Vim: A great tool for your toolbox! 1/13

Windows 10 Essentials

CS101 Linux Shell Handout

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

Emacs Tutorial. Creating or Opening a File. Geog 405/605 Computer Programming for Environmental Research Fall 2018

Transcription:

Text Editors for Programmers Dr. Prasad Kulkarni Michael Jantz Jamie Robinson 1

Real Programmers 2

vim Based on vi vi written in 1976 and has become standard on Unix machines Basic design principles: Retains each permutation of typed keys to resolve commands Smaller and faster editor but with less capacity for customization Uses distinct editing modes 3

Using Vim on a Simple Example You should have received two source files (simple.c and simple.h), a Makefile, and a dot_vimrc file from the lab website. Save dot_vimrc as.vimrc in your home directory Use mv to rename the file mv dot_vimrc ~/.vimrc dot_vimrc A collection of vim commands run each time you start vim Used to set mappings / options that are not otherwise set by default. 4

Using Vim to Create & Edit a File Start a session vim simple.c Press 'i' to enter insert mode Now type any text you want 'Esc' to enter command mode ':wq' to write changes and exit the session 5

Vim Modes of Operation Command Mode Input Mode Visual Mode Command Escape V, v, ctrl - v Escape I, i, A, a, O, o, R, r Visual Input 6

Essential Commands :e file Edit file in a new buffer :w Save any modifications to the current buffer. :q Quit Vim. If you have modifications you do not want to save, use :q! u, <c-r> Undo, redo 7

Command Mode: Navigation Reopen simple.c Use j, k, l, and h to navigate around the file as shown. This may take awhile get used to, but is very nice once you have it down. For faster page scrolling, use <c-b> and <c-f> for page up and page down. I've mapped these commands to spacebar and backspace in my.vimrc 8

Input Mode The following commands switch to input mode: i characters inserted just before the cursor position I characters inserted at the beginning of the line a characters inserted just after the cursor position A characters appended to the end of the line o characters inserted in a new line below the cursor O characters inserted in a new line above the cursor C Often overlooked, deletes the line after the cursor position and start inserting characters at this position After you're done editing, press Escape to go back to command mode, and :w to write the changes 9

Common Editor Commands Cut/copy/paste in command mode: dd cut a line of text yy copy ( yank ) a line of text P/p paste a line of text above / below the cursor position Commands in Vim can be applied to multiple lines by typing the number of lines you want before the command: 12dd cuts 12 lines of text 4j moves the cursor down 4 lines 10

Common Editor Commands (cont). gq<motion command> - Format a block of code to comply with textwidth setting <motion command> is any of the commands to move the cursor (i.e. j, k, h, and l) See example in simple.c == - Format a block of code to correspond to tabbing conventions See example in simple.c 11

Searching /word Search for occurrences of word Cursor jumps to the next occurrence of word n/n jump to the next / previous occurrence of word?word search initially jumps to previous occurrence of word. :set ic ignore case th toggle search highlighting 12

Find/Replace :s /search_for/replace_with/ Variations :s /s/r/g Replace every occurrence on the line (not just the first) :%s /s/r/g Replace every occurrence in the current buffer :s /s/r/g 12 Replace for the next 12 lines :s /s/r/gc Replace, but get confirmation before doing so :s /s/r/gi Ignore case when searching for s. 13

Setting the Mark ma Sets the mark a to the current cursor position a is not unique, any alphanumeric character can be used. Now, pressing `a in command mode returns you to the position marked by a. Helpful for getting back to hard to find sections of code quickly See the example in simple.c that shows how it can be used with the find/replace command to comment out large sections of code. da Deletes the mark a. 14

Visual Mode V/v enter into visual mode Allows user to visually select text for commands. Navigate in visual mode as in command mode (g,j,h,k) Issue commands with selected text ('y' to yank, 'd' to cut, etc.) `esc` exits visual mode 15

Buffers Vim allows you to edit multiple files in one session using buffers <c-w> v to split the screen vertically <c-w> s to split the screen horizontally <c-w> w to switch to the other screen :V/Sex splits the screen vertically or horizontally and opens a file explorer in the new screen. Select simple.h to open it in the new screen. 16

Installing Buffer Explorer Vim has built-in commands to work with its open buffers, but there is a plugin that allows you to visualize and navigate the open buffers. Goto http://vim.sourceforge.net/scripts/script.php?script_id=42 Download the latest version of bufexplorer.zip and extract it In your home directory, if a.vim/ directory does not exist, create it: ls -a.v* If.vim/ is not present, do mkdir.vim Now, move the contents of the extracted bufexplorer folder into.vim/: mv bufexplorer/doc/ bufexplorer/plugin/.vim/ Inside your vim session do: :helptag ~/.vim/doc/ Quit and reopen vim 17

Buffer Explorer \be Opens the buffer explorer in the current screen. Allows you to navigate (as in command mode) and select a buffer. Also can press the number of the buffer to select a buffer. 18

Tagging the Source Big advantage to Vim is its integration with a source code tagging program. Inside a terminal, goto the directory of the simple source and type: ctags -R Should create a file named tags. Now, reopen simple.c in Vim. 19

Using Tags with Vim <c-]> - With your cursor over a variable, jump to the declaration of that variable. <c-t> - Having jumped to a declaration, go back to the spot you jumped from You can use <c-]> multiple times before using <c-t>. The functionality operates like pushing and popping frames on a stack. Extremely helpful for browsing and learning large programs. 20

Colors Colorschemes can be downloaded from: http://www.cs.cmu.edu/~maverick/vimcolorsch emetest/ Current default colorschemes for EECS machines are in: /usr/share/vim/vim72/colors/ Set a new colorscheme with: :colorscheme name 21

Vim Resources Vim Tips Wiki: http://vim.wikia.com/wiki/main_page Vim Cookbook http://www.oualline.com/vim-cook.html Slashdot comments discussing Vim tips: http://ask.slashdot.org/article.pl?sid=08/11/06/2 06213 For everything else, just use Google. 22

Screen Screen is a 'terminal multiplexer' Allows users to access multiple separate terminal sessions from within a single terminal window or remote terminal session. 23

Screen Essential Commands Commands outside screen: Create a screen: bash> screen List screens: bash> screen -ls Attach to existing screen: bash> screen -D -R Commands within screen: Create a new terminal: <c-a> + c Cycle through terminals: <c-a> + n, <c-a> + p Kill terminal: <c-d> Detach from screen: <c-a> d 24

Editor Comparisons Vim vs. Emacs Vim is primarily an editor Emacs is a Lisp interpreter running an editor Wikipedia: Editor War 25

Emacs Properties Single mode editor Each key is a command to add the letter to the buffer Key combos shortcut commonly used commands C-x C-s to save a file to disk C-x C-c to exit Emacs Access all commands with M-x <command name> Highly extensible and versatile Plugins for almost any functionality Emacs Lisp (Elisp) programming language More than just a text editor: M-x org-mode, M-x shell, M-x life, M-x list-packages If you like Vim keybindings install the evil-mode package via M-x list-packages or use the Spacemacs configuration 26

.emacs Similar to.vimrc An Elisp script run at start up Used for configuring Emacs options and attaching plugins Follow the instructions for the dot_vimrc file on the dot_emacs file while changing the file names where necessary 27

Emacs Navigation and Command Shortcuts Command shortcut syntax: C- means hold Ctrl key M- means hold Alt key or press Esc key Forward 1 character: C-f Backward 1 character: C-b Go to previous line: C-p Go to next line: C-n Forward 1 word: M-f Backward 1 word: M-b Page up: M-v Page down: C-v Go to top of buffer: M-< Go to bottom of buffer: M-> Go to line n : M-g g n Repeat following command n times: <Esc> n command Repeat last command: C-x z [z z z ] All commands can be accessed with M-x command name 28

Basic Emacs Command Shortcuts Start Emacs from the command line: emacs emacs file name Close session: C-x C-c Suspend: C-x C-z Open file: C-x C-f Save file: C-x C-s Undo = Redo: C-_ or C-x u Abort command: C-g Begin mark region: C-<space> Copy region: M-w Kill region (Cut): C-w Yank (Paste): C-y Search buffer contents: C-s Select buffer: C-x C-b Previous buffer: C-x <left> Next buffer: C-x <right> Window - split: Vertically: C-x 2 Horizontally: C-x 3 Window - cycle cursor: C-x o GNU Reference Card 29