No products in the cart.
Below is a list of some of my favorite commands in the Atom Text Editor. These commands can help speed up workflow and I find myself using these almost every day.
Comment Out Single Lines or Code Blocks
First up is the command to comment out single line or code blocks in HTML. When I’m coding in HTML, it’s helpful to comment out single lines or blocks of code. With a section highlighted, you can press Cmd + / for Mac or Ctrl + / for Windows/Linux. This will comment out your highlighted block.
If you’ve ever had to create a list, then this command is perfect for you. Instead of copying a line, using copy, and then paste, you can use Cmd + Shift + D on a Mac or Ctrl + Shift + D on a Windows/Linux to duplicate a line. This is a huge time saver for creating the same code line over and over again.
I tend to use this command to tighten up short if/then statements. You can use Cmd + J on a Mac or Ctrl + J on a Windows/Linux to join two lines. The line below your marker will be appended to the current line. In the screenshot below, I used Join Line twice to combine all three list items.
Sometimes, you just need to get rid of a few lines. If you use Ctrl + Shift + K on a Mac and I believe the same is true on Windows/Linux, you can delete an entire line in your code. If you have a series of list items, switch statements, or another block of code, you can use this keyboard shortcut to save time.
When I get to 500 lines, 1,000 lines, or more, I tend to find myself referring back to previously written functions to make adjustments. Atom text editor provides bookmarks to mark certain lines. You can then fly between bookmarks to quickly make adjustments. On a Mac, the command is Cmd + F2 and Ctrl + Alt + F2 on a PC. The command varies from keyboard to keyboard. On the Apple Keyboard, I have to press Cmd + fn + F2 to activate the function command.
Once you have a bookmark in your code, you can press F2 to go to the next bookmark. Shift + F2 will jump to the previous bookmark. You can also see all bookmarks by pressing Ctrl + F2.
There are two commands I’d like to cover here Select Next and Split into Lines. Select Next will highlight the next element that matches the currently selected elements. For example, if I highlight the word list and press Cmd + D on a Mac or Ctrl + D on a Windows/Linux, the next instance of the word list would be highlighted. Below is a screenshot of when I pressed Cmd + D twice with the word list highlighted.
Next up is the command for Split into Lines. On a Mac, it’s Cmd + Shift + L. I’m not aware of the key binding for a PC, so if you know what it is, please let me know in the comments. Split into Lines will place a cursor on every selected line.
Here’s a real world example: you have to modify a list that’s 10 items long. The list already exists and it’s up to you to add the class clothingInventory to each list item. Sure, you can go to each one and add the class, but with split into lines, you can edit all 10 lines at once. You would select each list item, use Cmd + Shift + L, and then you could type in class=”clothingInventory” once instead of 10 times.
And these are some of my favorite commands! If you haven’t downloaded the Atom text editor, check it out at atom.io. Let me know what your favorite commands are in the comments below.