Sublime Text and Atom Keyboard Shortcuts

作者: shisaq 日期: April 26, 2016

This article is from Udacity, see link: Sublime Text and Atom Keyboard Shortcuts.

这篇文章摘自Udacity,见原文链接:Sublime Text and Atom Keyboard Shortcuts

Using keyboard shortcuts is one of the easiest ways to improve your workflow and become a coding ninja in the process… and it makes sense.

You’re faster with keyboard shortcuts than you are with a mouse. Try them out and unlock your full potential!

keyboard-shortcuts-meme

Every editor comes with a ton of keyboard shortcuts that help cut down on the amount of time you spend writing code. It would be almost impossible to list all of them here, so for brevity we’ve highlighted the most useful commands for Sublime Text and Atom.

Other editors have keyboard shortcuts too! Check out:

Commands

Cut, Copy, Paste

Mac

  • Cut: ⌘ + X

  • Copy: ⌘ + C

  • Paste: ⌘ + V

Windows/Linux

  • Cut: Ctrl + X

  • Copy: Ctrl + C

  • Paste: Ctrl + V

The classics! Stop typing the same thing over and over again. Use cut, copy, and paste.

1

Undo, Redo

Mac

  • Undo: ⌘ + Z

  • Redo: ⌘ + ⇧ + Z or ⌘ + Y

Windows/Linux

  • Undo: Ctrl + Z

  • Redo: Ctrl + ⇧ + Z or Ctrl + Y

Make a mistake? Need to redo what you just did? No problem, just use the undo and redo commands.

2

Duplicate

Mac

  • ⌘ + ⇧ + D with or without text highlighted

Windows/Linux

  • Ctrl + ⇧ + D with or without text highlighted

If you’ve got text highlighted, you will copy that text specifically. If you don’t have any text highlighted, you will duplicate the line your cursor is on.

3

Select

Mac

  • Select Word: ⌘ + D

  • Select Line: ⌘ + L

  • Select All: ⌘ + A

  • Select Every Instance: ⌘ + Ctrl + G

Windows/Linux

  • Select Word: Ctrl + D

  • Select Line: Ctrl + L

  • Select All: Ctrl + A

  • Select Every Instance: Alt + F3

Need to select a word, line, or entire file? Use one of these commands. If you select a word and want to continue selecting the same word, keep pressing ⌘ + D (Mac) or Ctrl + D (Windows/Linux). Want to select every instance of the same word? Press ⌘ + Ctrl + G (Mac) or Alt + F3 (Windows/Linux) to select all instances of the same word.

4

Move Cursor

Mac

  • Move Cursor to Previous Word: Alt + ←

  • Move Cursor to Next Word: Alt + →

  • Move Cursor to Start of Line: ⌘ + ←

  • Move Cursor to End of Line: ⌘ + →

  • Move Cursor to Start of Document: ⌘ + ↑

  • Move Cursor to End of Document: ⌘ + ↓

Windows/Linux

  • Move Cursor to Previous Word: Home

  • Move Cursor to Next Word: End

  • Move Cursor to Start of Line: Ctrl + ←

  • Move Cursor to End of Line: Ctrl + →

  • Move Cursor to Start of Document: Ctrl + Home

  • Move Cursor to End of Document: Ctrl + End

Use the move cursor commands to quickly traverse a document without using a mouse. Also, if you hold ⇧ (Shift) down while using the commands then the text within the move will be selected.

5

Jump

Mac

  • Jump to Opening/Closing Parentheses, Brackets, Braces: Ctrl + M

  • Jump to Definition: ⌘ + R

Windows/Linux

  • Jump to Opening/Closing Parentheses, Brackets, Braces: Ctrl + M

  • Jump to Definition: Ctrl + R

The jump commands are useful for snapping to places in code fast! Try them out.

6

Indent, Unindent

Mac

  • Indent: Tab or ⌘ + ]

  • Unindent: ⇧ + Tab or ⌘ + [

Windows/Linux

  • Indent: Tab or ⌘ + ]

  • Unindent: ⇧ + Tab or ⌘ + [

Make your code easier to read by leveraging the indent and unindent commands.

7

Toggle Comment

Mac

  • ⌘ + /

Windows

  • Ctrl + /

Leave comments in your code with the toggle comments command. You’ll thank yourself later! Also, this is great for quickly debugging.

8

Tab Management

Mac

  • New Tab: ⌘ + N

  • Switch Tab Left: ⌘ + ⇧ + [

  • Switch Tab Right: ⌘ + ⇧ + ]

  • Close Tab: ⌘ + W

  • Reopen Tab: ⌘ + ⇧ + T

Windows

  • New Tab: Ctrl + N

  • Switch Tab Left: Ctrl + PgUp

  • Switch Tab Right: Ctrl + PgDn

  • Close Tab: Ctrl + W

  • Reopen Tab: Ctrl + ⇧ + T

Look like a dynamo creating new tabs, swapping between tabs, and closing tabs. Check out these commands for tab management.

Also, try using these commands in your browser. They work there too! Only difference is ⌘ + N (Mac) or Ctrl + N (Windows/Linux) will open a new window in the browser and ⌘ + T (Mac) or Ctrl + T (Windows/Linux) will open a new tab.

9

Quick Open

Mac

  • ⌘ + P

Windows/Linux

  • Ctrl + P

Try opening a folder inside Sublime or Atom. Notice how you can see all the files in the sidebar? That’s a project! Use the sidebar or the quick open command to open the file you want to work on.

10

Find

Mac

  • ⌘ + F

Windows

  • Ctrl + F

Looking for a word in a file? Use the find command to search for it. Want to search the entire project? Add ⇧ (Shift) to the command.

11

Want to See More?

For an entire list of Sublime’s or Atom’s keyboard shortcuts, visit the links below.

Sublime Text

Atom