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 |
|
|
Indent multiple lines |
|
|
Unindent multiple lines |
|
|
Search for word(s) on Ed See: more complex searches |
|
|
Replace specific word(s) on Ed See: more complex searches, updating variable names |
|
|
Select next occurrence of word(s) on Ed See: updating variable names |
|
|
Type on multiple lines (“multi-cursor”) See: updating variable names |
|
|
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 |
|
|
Common Patterns with Shortcuts¶
Updating Variable Names¶
There are three common ways to update a variable name across your entire program:
- Use the find-and-replace tool (with Ctrl/Command + F), enter your variable name, and replace it with the new one
- Use the next-occurrence tool (with Ctrl/Command + D), select all the text you want to change, and type in the new variable name
- 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:
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:
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.