UP | HOME

Editor
Programming Environment
COP-3402

Table of Contents

Multiplexer-based development workflow

ssh NID@eustis.cecs.ucf.edu
mkdir hello
cd hello/
byobu
emacs hello.c
# press F2 for new byobu window
gcc -o hello hello.c
# notice bug
# F3 to switch back to editor
# F4 to switch back to compiler
gcc -o hello hello.c
./hello
# F6 to detach
# byobu to reattach, selecting session number

Emacs

Emacs-logo.svg

Overview

Emacs is a text-editor, designed to be

  • Self-documenting (Ctrl-h for help)
  • Customizable (change keybindings)
  • Extensible (write packages)

More than text editing

  • Invoke sub-processes (make, terminal, etc.)
  • Email, IRC, etc.
  • git integration
  • File management and viewing
  • Windowing
  • org-mode (this class's webpage!)

tetris.png

Alt-X tetris

Tutorial

After logging into eustis, run

emacs -f help-with-tutorial
Keyboard Mnemonic Description
Ctrl-X Ctrl-C Ctrl-C kills processes in bash Exit emacs

Easy cursor movement

Can use keyboard navigation keys

  • Up, down, left, right
  • Pg-up, Pg-down
  • Home, end

Warning: cannot use the mouse when in terminal only, though emacs does have mouse support in windowed versions.

The emacs way

Keyboard Mnemonic Description
Ctrl-p or <up> p for previous Previous line
Ctrl-n or <down> n for next Next line
Ctrl-f or <right> f for forward Forward a character
Ctrl-b or <left> b for backward Backward a character
Ctrl-a or <home> a is beginning of the alphabet Beginning of line
Ctrl-e or <end> e for end End of line
Ctrl-v or <pgdown> v looks like a down arrow Next page
Alt-v or <pgup> Alternative of Ctrl-v Previous page

Emacs documentation refers to a Meta key, but on PC keyboards this is the Alt key.

You can also use Meta by hitting Esc and then the key, e.g., Esc then v is the same as Alt-v together.

Search

Keyboard Mnemonic Description
Ctrl-S s for search Search for text
  1. Press Ctrl-S
  2. Start typing the string
  3. Press Ctrl-S to find more instances
  4. Press <enter> to stop or press Ctrl-G to cancel

Advanced navigation

Move by words

Keyboard Mnemonic Description
Alt-f or <right> f for forward Forward a character
Alt-b or <left> b for backward Backward a character
Alt-a or <home> a is beginning of the alphabet Beginning of sentence
Alt-e or <end> e for end End of sentence

Move to top and bottom

Keyboard Mnemonic Description
Alt-> > is like a right arrow End of document
Alt-< < is like a left arrow Beginning of document

File handling

Keyboard Mnemonic Description
Ctrl-x Ctrl-s s for save Save file
Ctrl-x Ctrl-f f for file Open file
Ctrl-x Ctrl-w w for write Save file under another name

Can use tab completion when opening files as well

Directory browsing

Emacs also has extensive in-editor file management, such as interactive directory browsers. Try opening a directory instead of a file.

Fun Emacs usage

Buffer management

Window management

File management

Org-mode

Class

Version control and software development

vim

vimlogo.svg

Modes

vim has several modes. Two of them are

  • Normal mode: navigating text, saving, quitting, entering commands
  • Insert mode: inserting text into the file

This separation of modes makes vim a little unusual compared to other commonly-used, including emacs.

After opening a file, you won't be able to start entering text without entering insert mode.

One benefit of this separation of modes is that vim's common commands are mostly just one or a few keys. No emacs pinky or heavy use of Ctrl and Meta modifiers. All keys are available as commands in normal mode since no text entry is happening in that mode.

Normal mode

  • When you open a file, you'll be in normal mode
  • Cannot enter text (yet)
  • But can navigate and even delete text

Exiting vim

  • <Esc> to enter normal mode
  • :q to quit

Exit variants

Key Description
:q Quit (prompt if unsaved)
:wq Write (save) then quit
:q! Quite without saving (warning: can lose work!)

Navigation

Key Description
h Left
j Down
k Up
l right

These keys are not unlike the WASD keys in many games. They approximate a physical arrow key layout.

Word-level commands

Key Description
w Forward a word
e Forward a word (cursor on end of word)
b Back a word

Larger movements

Key Description
0 Beginning of line
$ End of line
gg Beginning of file
G End of file
##G Go to line ## (enter the number first, then type G)
/string Search for a string (type / then the string, then enter)
n Next match (after a search)
N Previous match (after a search)

Deletion

Key Description
x Delete a character (forward)
X Delete a character (backwards)
dw Delete a word (d plus w)
de Delete a word (leaving the space; d plus e)
db Delete a word (d plus b)
dd Delete a line
p Paste last deleted text
u Undo

Insert mode

Key Description
i Start inserting text at cursor point
A Append text at end of line

Important: use <Esc> to return to normal mode (otherwise normal mode commands will not work and will enter text instead)

Conclusion

  • Pick emacs or vim editor
  • Or both!
    • emacs-like commands used in bash
    • vim-like commands used in less
  • Use one of these editors in eustis exclusively for class projects

Author: Paul Gazzillo

Created: 2024-09-24 Tue 22:31

Validate