Monday, January 25, 2016

Atom Editor Tips and Tricks




https://github.com/atom/bracket-matcher
Use ctrl-m to jump to the bracket matching the one adjacent to the cursor. It jumps to the nearest enclosing bracket when there's no adjacent bracket,
Use ctrl-cmd-m to select all the text inside the current brackets.
Use alt-cmd-. to close the current XML/HTML tag.
https://flight-manual.atom.io/using-atom/sections/moving-in-atom/
  • Alt+Left or Alt+BCtrl+Left - Move to the beginning of word
  • Alt+Right or Alt+FCtrl+Right - Move to the end of word
  • Cmd+Left or Ctrl+AHome - Move to the first character of the current line
  • Cmd+Right or Ctrl+EEnd - Move to the end of the line
  • Cmd+UpCtrl+Home - Move to the top of the file
  • Cmd+DownCtrl+End - Move to the bottom of the file
You can also move directly to a specific line (and column) number with Ctrl+G. This will bring up a dialog that asks which line you would like to jump to. You can also use the row:column syntax to jump to a character in that line as well.


https://stackoverflow.com/questions/29106145/how-to-set-keybinding-to-move-rearrange-tabs-in-atom
I found that Atom has a native keybinding set for this under as:

https://flight-manual.atom.io/using-atom/sections/snippets/
Multi-line Snippet Body
You can also use CoffeeScript multi-line syntax using """ for larger templates:
https://discuss.atom.io/t/create-multi-line-snippet/3446/2
'.source.scss':
    'Comment':
        'prefix': 'cmnt'
        'body': """
            /*------------------------------------*
            ::$1
            \*------------------------------------*/
            $2
            """
Atom stores unsaved files in its IndexedDB 620. If the changes didn’t come back when you reopened Atom with the same project folder, they’re probably gone

Fuzzy Finder

  • Select Preserve Last Search
Preferences -> Tree View -> Hide Ignored Names
Edit: This’ll hide whatever you have listed in Preferences -> Settings -> Core Settings -> Ignored Names
it's a command palette package setting, Preserve Last Search

06. Reach content fast

For very long documents, you can create something called a bookmark with cmd+F2. This will place a special icon in the gutter, and if you hit ctrl+F2 you’ll open up a dialog box where you can see a list and search through your bookmarks quickly.  F2  will move you forwards through your bookmarks and shift+F2 backwards.
Another great way to navigate is to use symbols by using cmd+R. Atom will analyse the current document and build you a quick outline based on its contents. 

08. Master multiple cursors

 cmd+click  will let you add new cursors anywhere. My favourite way to create new cursors when I need to choose something at the same position above or below the current cursor is ctrl+shift+up/down. Be careful, because those might already be taken over by mission control on a Mac, so may have to use custom keybindings.
atom.commands.add 'atom-workpace', 'me:personalize-whitespace', ->
  view = atom.views.getView(atom.workspace.getActiveTextEditor())
  atom.commands.dispatch(view, 'whitespace:convert-all-tabs-to-spaces')
  .then () -> atom.commands.dispatch(view, 'whitespace:remove-trailing-whitespace')
  .then () -> atom.commands.dispatch(view, 'line-ending-selector:convert-to-LF')
Auto Reveal Tree-view
  • cmd-\ to open/close the tree view, ctrl-0to focus it
  • a, shift-a, m, or delete to add, move or delete files and folders
  • Find Tree-view package, select “Auto Reveal”
  • up/down arrow keys to preview files
    • need reload the window
Make 'preview files' to work with up/down arrow keys
atom.commands.add '.tree-view', 'custom:expand-item-down': ->
  fs = require 'fs'
  item = atom.workspace.getActivePaneItem()
  atom.commands.dispatch(item.element, 'core:move-down')
  if fs.lstatSync(item.selectedPath).isDirectory()
    return
  else
    item.openSelectedEntry(pending: true, activatePane: false)
    return
atom.commands.add '.tree-view', 'custom:expand-item-up': ->
  fs = require 'fs'
  item = atom.workspace.getActivePaneItem()
  atom.commands.dispatch(item.element, 'core:move-up')
  if fs.lstatSync(item.selectedPath).isDirectory()
    return
  else
    item.openSelectedEntry(pending: true, activatePane: false)
    return
'.tree-view':
  'down': 'custom:expand-item-down',
  'up': 'custom:expand-item-up'
And if you go into Settings -> Keybindings and search for “window:focus”, you will see all the keybindings for changing focus.
https://flight-manual.atom.io/using-atom/sections/basic-customization/#_customizing_keybindings
Atom keymaps use selectors to associate key combinations with events in specific contexts. Here's a small example, excerpted from Atom's built-in keymap:
'atom-text-editor':
  'enter': 'editor:newline'

'atom-text-editor[mini] input':
  'enter': 'core:confirm'
This keymap defines the meaning of Enter in two different contexts. In a normal editor, pressing Enter triggers the editor:newline command, which causes the editor to insert a newline. But if the same keystroke occurs inside a select list's mini-editor, it instead triggers the core:confirm command based on the binding in the more-specific selector.
remove trailing whitespace doesn't work for markdown file
There was a new configuration option (whitespace.keepMarkdownLineBreakWhitespace) introduced by af9edc6 that you have to edit, and right now it allows any whitespace greater than 1 character, rather than the previous stripping of anything that isn't 2 trailing spaces.
When you open a new file by single-clicking in the Tree View, it will open in a new tab with an italic title. This indicates that the file is "pending". When a file is pending, it will be replaced by the next pending file that is opened. This allows you to click through a bunch of files to find something without having to go back and close them all.
You can confirm a pending file by doing any of the following:
  • Double-clicking the tab of the file
  • Double-clicking the file in the tree view
  • Editing the contents of the file
  • Saving the file
You can enable column selection mode using Ctrl+Shift+↑/↓. This will allow you to extend the cursor to multiple rows. Once you have selected all rows, release the keys, and use the Delete key to remove the text you want to replace. Once you're done, press the Esc key to release the cursors.

How to Disable Mission Control (conflicting) Key Bindings (Mac)

Locate the key bindings for Mission Control and Applications windows:
Just Select the text, use command palette (cmd + shift + P) > delete-whitelines:toggle or alt+shift+D(for MAC & windows) to remove empty lines within the selected text area.
apm install
Confiugration
Under your Atom Preferences go to Packages tab and search for whitespace. Click on the whitespace package and uncheck Ensure Single Trailing Newline option
Shortcuts:
Toggle Tree View ⌘-\
Fuzzy Find Files ⌘-t
Increase Font Size cmd-+
Decrease Font Size cmd—
Find String in Current File ⌘-f
Find String in All Project Files ⇧-⌘-f
Replace String in Current File ⌥-⌘-f
Select Grammar ⌃-⇧-L
Delete Line ⌃-⇧-k
Toggle Autocomplete ⌃-space
Convert Line Endings To -> Unix Format / Windows Format / Old Mac Format
Or, in Command Palette (cmd-shift-p or ctrl-shift-p), type
Convert To Unix Format, or Convert To Windows Format, or Convert to Old Mac Format
Spell-Check
Use cmd+shift+: to bring up the list of corrections when your cursor is on a misspelled word.
It's a pretty common tab switching convention in OSX to use Cmd+Shift+{ and Cmd+Shift+} to switch between tabs, which is what it uses by default
Not sure why anyone would prefer Ctrl-Tab and Ctrl-Shift-Tab over Cmd-Shift-{ and Cmd-Shift-}.
Change the setting to enable it. - disabled by default
Already there. Check the Whitespace package:
https://discuss.atom.io/t/feature-request-find-and-replace-in-selection/8665
https://discuss.atom.io/t/manually-install-package/9251
You can download the package, unzip or decompress, go to that folder and run: apm link that will create a symbolic link from that package to your ~/.atom/packages folder.
You should never use npm to install or maintain an Atom package. While it worked in some cases historically, it is working in fewer and fewer cases as apm diverges from npm.
Also, manually installing an Atom package is generally a bad idea for the same reason. The process to manually install was simple at one point, but it is getting more complex as the needs of Atom grow.
Find and Replace in selection is available with the following box enabled:
You can toggle the Tree View with the "Tree View: Toggle" command, Cmd+\ on OS X or Ctrl+\ on other platforms.

Labels

Review (572) System Design (334) System Design - Review (198) Java (189) Coding (75) Interview-System Design (65) Interview (63) Book Notes (59) Coding - Review (59) to-do (45) Linux (43) Knowledge (39) Interview-Java (35) Knowledge - Review (32) Database (31) Design Patterns (31) Big Data (29) Product Architecture (28) MultiThread (27) Soft Skills (27) Concurrency (26) Cracking Code Interview (26) Miscs (25) Distributed (24) OOD Design (24) Google (23) Career (22) Interview - Review (21) Java - Code (21) Operating System (21) Interview Q&A (20) System Design - Practice (20) Tips (19) Algorithm (17) Company - Facebook (17) Security (17) How to Ace Interview (16) Brain Teaser (14) Linux - Shell (14) Redis (14) Testing (14) Tools (14) Code Quality (13) Search (13) Spark (13) Spring (13) Company - LinkedIn (12) How to (12) Interview-Database (12) Interview-Operating System (12) Solr (12) Architecture Principles (11) Resource (10) Amazon (9) Cache (9) Git (9) Interview - MultiThread (9) Scalability (9) Trouble Shooting (9) Web Dev (9) Architecture Model (8) Better Programmer (8) Cassandra (8) Company - Uber (8) Java67 (8) Math (8) OO Design principles (8) SOLID (8) Design (7) Interview Corner (7) JVM (7) Java Basics (7) Kafka (7) Mac (7) Machine Learning (7) NoSQL (7) C++ (6) Chrome (6) File System (6) Highscalability (6) How to Better (6) Network (6) Restful (6) CareerCup (5) Code Review (5) Hash (5) How to Interview (5) JDK Source Code (5) JavaScript (5) Leetcode (5) Must Known (5) Python (5)

Popular Posts