This page is here to help you get started with a text user interface editor for use within a terminal (also lightly covered in CSE 391). While you can make just about anything work, we still encourage you to try one of these to avoid unnecessary transferring of files or delays from sending graphics data over the network.
This page covers setup and tips for the two most popular options:vim
(project page) and Emacs (project page).
vim
on the CSE Linux environment, type vim
or vim <filename>
on the command line and press [Enter]. This will open a welcome screen or the specified file, respectively, for viewing and modification.vim
commands to help you get started with basic file navigation and editing, which can be useful while learning and before you have the muscle memory down.:q
to exit (or :q!
to exit and discard changes).Command | Function | Example | Explanation | Notes |
---|---|---|---|---|
i | Inserts before the cursor | i | This will start insert mode and you can start editing the file. | |
Esc | Exits insert mode. | Esc | This will exit the insert mode on the editor. | ALWAYS do Esc before other vim commands, or else you will be typing the commands into the file. |
:wq | Saves the changes made and quits. | :wq | This will exit the vim editor and save the changes to the file. | |
:q! | Quits and throws away unsaved changes. | :q! | This will exit the vim editor without saving the changes made. | |
yy | Yanks (copies) a line. | yy | This will copy the current line to the clipboard. | |
2yy | Yanks (copies) 2 lines. | 2yy | This will copy the current line and the next to the clipboard. | You can replace 2 with any number. |
dd | Deletes (cuts) a line. | dd | This will delete the current line. | |
2dd | Deletes (cuts) 2 lines. | 2dd | This will delete the current line and the line after. | You can replace 2 with any number. |
p | Puts (pastes) the clipboard after cursor. | p | This will paste the clipboard after cursor. |
vimtutor
can be run from the command line and gives a brief introduction to vim
terminology and the general gist of how it works. This describes how to move around, select, copy, paste, and other basic functions of vim
. However, vimtutor
is quite dry.vim
, but in a way that will help with your muscle memory.Commands placed in the file ~/.vimrc
will be run whenvim
starts up. The CSE 351 starter vimrc file can be automatically placed in the correct location for you using the following command:
$ curl -Lo ~/.vimrc https://cs.uw.edu/351/files/vimrc.txt
This should serve as a good starting point for you to customizevim
yourself and does the following for you:
‘ron’
. Instructions for changing this are in the .vimrc
file.F9
to run make (you can also just do :make
). Then, you can run :copen
to see the output alongside your code.vim
will even take you to the lines that have compiler problems.If you're curious how it works, the file has comments that describe what each command does; just open the file withvim ~/.vimrc
.
Emacs
on the CSE Linux environment, type emacs
or emacs <filename>
on the command line and press [Enter]. This will open a welcome screen or the specified file, respectively, for viewing and modification.Ctrl-x, Ctrl-c
to exit.Ctrl-h, t
from within Emacs
. This will open up a text file with instructions to follow that covers the basics of movement and editing. As this is just plain text, it can feel dry and is a lot to read.Emacs
documentation includes this guided tour.Emacs
. The author does recommend going through the Emacs Tutorial first, but has an article on editing and movement.Commands placed in the file ~/.emacs
will be run whenEmacs
starts up. The default settings should do a decent job as-is, so we won't be providing a starter configuration file. If you do feel like customizing a bit, you can find some examples here.