24wi ver.

Note: this is for the Winter 2024 iteration of CSE 121. Looking for a different quarter? Please visit https://courses.cs.washington.edu/courses/cse121/.

Keyboard Shortcuts in Ed

Note

Fun fact: most of these shortcuts work in other IDEs like Intelli-J and VSCode!

Shortcut Windows Shortcut Keys / Instructions Mac Shortcut Keys / Instructions
Copy Ctrl + C Command + C
Paste Ctrl + V Command + V
Undo Ctrl + Z Command + Z
Redo Ctrl + Y Command + Shift + Z
Save (for non-Ed IDEs) Ctrl + S Command + S
Select all code Ctrl + A
or, left-click four times quickly
Command + A
or, left-click four times quickly
Comment (or uncomment) current line Ctrl + / Command + /
Comment (or uncomment) multiple lines
  1. Select lines of code
  2. Ctrl + /
  1. Select lines of code
  2. Command + /
Indent multiple lines
  1. Select lines of code
  2. Tab
  1. Select lines of code
  2. Tab
Unindent multiple lines
  1. Select lines of code
  2. Shift + Tab
  1. Select lines of code
  2. Shift + Tab
Search for word(s) on Ed

See: more complex searches
  1. Click within the Ed code editor
  2. Ctrl + F
  3. Type within the “find” input
  4. Use the arrows in the search UI to see the next/previous occurrence
  1. Click within the Ed code editor
  2. Command + F
  3. Type within the “find” input
  4. Use the arrows in the search UI to see the next/previous occurrence
Replace specific word(s) on Ed

See: more complex searches, updating variable names
  1. Click within the Ed code editor
  2. Ctrl + F
  3. Type what you’re looking for in the “find” input
  4. Type your replacement text in the “replace” input
  5. Use Enter to replace the first occurence
  6. Or, use the “replace all” button to replace all at once
  1. Click within the Ed code editor
  2. Command + F
  3. Type what you’re looking for in the “find” input
  4. Type your replacement text in the “replace” input
  5. Use Return to replace the first occurence
  6. Or, use the “replace all” button to replace all at once
Select next occurrence of word(s) on Ed

See: updating variable names
  1. Select word
  2. Ctrl + D
  1. Select word
  2. Command + D
Type on multiple lines (“multi-cursor”)

See: updating variable names
  1. While holding Alt, click where you’d like another cursor to appear
  2. Type with multiple cursors
  3. Click somewhere else to stop multi-cursor mode
  1. While holding Option, click where you’d like another cursor to appear
  2. Type with multiple cursors
  3. Click somewhere else to stop multi-cursor mode
Select the same column in multiple rows Hold the middle mouse button and move it up and/or down Hold the middle mouse button and move it up and/or down
Edit text selection character by character
  1. Select lines of code
  2. Hold Shift, use and to change selection size
  1. Select lines of code
  2. Hold Shift, use and to change selection size

Common Patterns with Shortcuts

Updating Variable Names

There are three common ways to update a variable name across your entire program:

  1. Use the find-and-replace tool (with Ctrl/Command + F), enter your variable name, and replace it with the new one
  2. Use the next-occurrence tool (with Ctrl/Command + D), select all the text you want to change, and type in the new variable name
  3. Use the multiple cursor tool (with Alt/Option + left-click), select all the text you want to change, and type in the new variable name

Here is a gif that showcases the third option on macOS:

a user uses multi-cursor mode to rename a variable from 'r' to 'randy'. They do this with Option + Left-click.
Here, the user is changing a variable name from r to randy. To do so, they
  1. click after one instance of r
  2. while holding Option, left-click after the second instance of r
  3. type out "andy", noting that this gets appended to both instnaces of r
  4. finally, click somewhere else to exit multi-cursor mode

More Complex Searches

Ed lets you configure your search options when you use the “find” or “find and replace” tools. When you use Ctrl/Command + F, a UI pops up:

the find-and-replace UI in ed. features a find and a replace input box, as well as options to toggle matching case, the whole world, regular expressions, preserving case, and next/previous occurrences.
Within the "find" input box, there are three options:
  1. toggle match case (default: off, case-insensitive)
  2. toggle matching the whole word (default: off)
  3. toggle using "regular expressions" (default: off)
Within the "replace" input box, there is one option: toggle preserve case (default: off).
The up and down arrows in the UI move you to the previous and next occurrence respectively.

In this class, you might not need to use any of these options (especially “regular expressions”, which are complicated!), but these are quite helpful if you continue your coding journey!

For example, in the following code snippet:

int num = 3;
int numerator = 8;
int specialNum = 9;

System.out.println(num);

If you wanted to rename just the num variable, you might want to toggle match case on and/or matching the whole word.