Atom packages (plugins) ช่วยเพิ่ม productivity มีเยอะมาก ตัวไหนควรใช้? พร้อม keyboard shortcuts ที่มีประโยชน์
Best Atom Packages
ติดตั้งจาก Settings (Ctrl+,) → Install tab
1. Atom Runner
รันโค้ดใน editor เอง output แสดง split window ด้านขวา (หรือล่างใน Atom 1.17+) ติดตั้งค้นหา "atom runner" กด Alt+R (Ctrl+R Mac) ต้องตั้ง file type = Ruby
เพิ่ม font size output: เปิด stylesheet (Ctrl+Alt+P → "osty") เพิ่ม .stdout { font-size: 18px !important; }
2. Block Convert
แปลง do...end ↔ { ... } ใส่ cursor ในบล็อก → Command Palette (Ctrl+Alt+P) → "converter" → เลือก "to do end" หรือ "to curly brackets"
3. Toggle Quotes
สลับ single/double quotes ใส่ cursor ระหว่าง quotes กด Ctrl+" (Cmd+" Mac)
4. Linter Ruby
Linting ชี้ syntax errors หา error เร็วกว่ารัน tests ติดตั้ง "linter-ruby"
Other Packages
- ruby-block
- color-picker
- teletype.atom.io (pair programming)
Atom Keyboard Shortcuts
| Shortcut | Description |
|---|---|
| Ctrl+D | Multi Selection |
| Ctrl+F | Search in file |
| Ctrl+P | Quick open files |
| Ctrl+B | Switch open files |
| Ctrl+Alt+7 | Toggle comments |
| Ctrl+Up/Down | Move line up/down |
| Ctrl+Shift+K | Delete line |
Atom Snippets เพิ่ม Productivity
พิมพ์ trigger + Enter → template โค้ด ตัวอย่าง built-in Ruby snippets:
| Snippet | Description |
|---|---|
| if | if/end |
| ife | if/else/end |
| def | def/end |
| cla | class/end |
| mod | module/end |
| ea | each { ... } |
| beg | begin/rescue/end |
| r | attr_reader |
| rw | attr_accessor |
ERB snippets: = → <%= %>, - → <% %>
สร้าง custom snippets: Command Palette → "osni" → แก้ไฟล์ snippets.cson
".source.ruby":
"Initialize":
prefix: "init"
body: "def initialize\n\t$1\nend"
$1 = cursor position หลัง insert Tab ไป $2, $3...
Auto Indent
Select code → Command Palette → "auto" → Auto Indent
Built-In Git Integration
Atom 1.18+ มี Git integration กดมุมล่างขวา (นับไฟล์) → Git panel → stage, commit message, commit
Summary
เรียนรู้ packages, shortcuts, snippets ทำให้เป็น Ruby developer ที่ productive กว่า!