Stray for Mac: A Detailed User Guide

Source: Love Mac  |  Software download link: Stray for Mac

Stray is a modern, lightweight code editor designed specifically for macOS, favored by developers for its exceptional performance, elegant interface, and high degree of customizability. It focuses on delivering a smooth coding experience, making it particularly suitable for front-end development, scripting, and everyday text processing. This article provides an in-depth introduction to its core interface, complete workflow, and practical tips.

I. Detailed Overview of the Core Interface and Workspace

Stray’s interface follows a minimalist design philosophy and is mainly divided into the following areas:

  • Title Bar and Menu Bar: A standard macOS bar at the top, containing all function menus.
  • Sidebar (Resource Manager): Located on the left side of the window, opened/closed by default via the shortcut Cmd+Shift+E or by clicking the sidebar icon. It displays all files and subfolders in the currently open project folder in a tree structure and is the core of project navigation.
  • Editor Area: The core area in the center of the window, used to display and edit open documents. It supports multi-tab (Tab) management, allowing you to create a new tab with Cmd+T and close the current tab with Cmd+W.
  • Status Bar: Located at the bottom of the window, it displays the current file’s row and column information, encoding format, language mode, Git branch status (if the project is in a Git repository), and more.
  • Panel Area: Usually located below or to the right of the editor area, it can be opened via the menu bar’s “View” -> “Panel”. It includes:
    • Problems Panel: Displays errors and warnings in the code.
    • Output Panel: Displays the output results of task runs or extensions.
    • Debug Console: Used for debugging code.
    • Terminal: Integrated terminal (Ctrl+` to open/close), allowing you to execute command-line operations directly within the editor.
  • Activity Bar: The vertical icon bar on the far left, containing quick access to main features such as Resource Manager, Search, Source Control (Git), Extensions, and Debugging.

II. Complete Workflow: From Creating a Project to Exporting

1. Launch and Initial Setup

When you launch Stray for the first time, a welcome page will appear, providing quick entry points such as “New File” and “Open Folder”. It is recommended to close the welcome page and first configure your basic preferences:

Steps: Click the menu bar Stray -> Preferences -> Settings (or use the shortcut Cmd+,) to enter the settings interface. Here you can configure fonts, themes, auto-save, indentation, and more.

2. Create/Open a Project

Stray manages projects on a “folder” basis.

  • Create a new project: Click the menu bar File -> New Window (Cmd+Shift+N), then click File -> Open Folder… (Cmd+O), select an empty folder or create a new folder and open it.
  • Open an existing project: Simply use Cmd+O and select the project root folder.

Once opened, the sidebar will display the complete structure of that folder.

3. Create and Edit Files

  • Create a new file: Right-click the target parent folder in the sidebar and select “New File”, or simply use the shortcut Cmd+N to create an untitled file and then save it.
  • Save a file: For the first save, use Cmd+S to choose the location and file name. The file extension (e.g., .js, .html, .py) automatically determines the language mode and highlighting scheme.
  • Editing operations: Type directly in the editing area. Common shortcuts:
    • Duplicate line: Cmd+Shift+D
    • Delete line: Cmd+Shift+K
    • Move line up/down: Option+↑/↓
    • Toggle line comment: Cmd+/
    • Format document: Option+Shift+F

4. Search and Navigation

  • Search within a file: Cmd+F opens the search box; enter keywords to search. Cmd+G finds the next match.
  • Global Search (cross-file): Cmd+Shift+F opens the search panel, where you can specify the search scope and filter conditions.
  • Quick file navigation: Cmd+P opens the “Quick Open” panel; type part of a file name to quickly locate and open it.
  • Go to definition: Place the cursor on a function or variable and press F12.

5. Using Version Control (Git)

If the opened folder is a Git repository, the “Source Control” icon in the activity bar will show the number of changes.

  • View changes: Click the Source Control icon in the activity bar (or Ctrl+Shift+G); the sidebar will switch to the Source Control panel, showing all changed files.
  • Stage and commit: Click the “+” next to a changed file to stage it. Enter a commit message in the input box at the top, then click the checkmark icon or press Cmd+Enter to commit.
  • Push and pull: Buttons such as Sync, Pull, and Push are available at the bottom of the panel.

6. Running and Debugging

For supported languages (such as Python and JavaScript), you can configure run tasks.

  • Run a simple script: Use the integrated terminal (Ctrl+`) to enter commands directly and run them, such as python script.py.
  • Configure debugging: Click the “Run and Debug” icon in the activity bar (or Cmd+Shift+D), click “create a launch.json file”, and select an environment (such as Node.js or Python). After configuration, press F5 to start debugging, and F9 to toggle a breakpoint on the cursor line.

7. Final Export or Build

Stray itself does not directly “export” finished products, but you can complete builds through integrated tools.

  • Build with Terminal: For front-end projects, run commands such as npm run build in the terminal.
  • Configure Tasks: Click the menu bar Terminal -> Run Task… to configure and run custom build tasks (such as via Gulp, Make, etc.).
  • Save All Files: Before building, use Cmd+Option+S to save all open files.

III. Advanced Tips for Common Features

1. Multi-Cursor Editing

  • Hold the Option key and click with the mouse to add multiple cursors.
  • After selecting a word, press Cmd+Shift+L to add cursors to all matching items.
  • Hold Option and drag the mouse to perform column selection (rectangular selection).

2. Code Snippets and Quick Input

After entering a language-specific prefix, press the Tab key to quickly expand code snippets. For example, in an HTML file, enter ! and then press Tab to automatically generate the basic HTML5 structure.

3. Command Palette (Universal Action Entry Point)

Press Cmd+Shift+P to open the Command Palette, enter any feature name (such as “Change Language Mode” or “Rename Symbol”) to execute it quickly, with no need to remember menu locations.

4. Custom User Snippets

Press Cmd+Shift+P and type “Configure User Snippets”, select a language, and you can define your own snippets in the JSON file that opens.

IV. Common Issues and Solutions

Issue 1: Sidebar File List Not Refreshing

Symptom: Files are added or deleted externally, but the sidebar does not immediately reflect the changes.
Solution: Right-click on an empty area in the sidebar and select “Refresh”, or use the shortcut Cmd+R (when the sidebar is focused).

Issue 2: Terminal Cannot Accept Input or Fails to Start

Symptom: After pressing Ctrl+`, the terminal panel is blank or unresponsive.
Solution: Check the default Shell settings. Go to Stray -> Preferences -> Settings, search for “terminal.integrated.shell.osx”, and make sure the path is correct (e.g., /bin/zsh or /bin/bash).

Issue 3: Garbled Characters in File Encoding

Symptom: Some text files display garbled characters when opened.
Solution: Click the encoding indicator in the bottom-right corner of the status bar (e.g., “UTF-8”), select “Reopen with Encoding”, and try selecting the correct encoding (e.g., GBK, GB2312).

Issue 4: Extension Installation Slow or Failing

Symptom: Downloading and installing extensions from the extension marketplace gets stuck.
Solution: Check your network connection, or try switching to a different download mirror for the extension marketplace. You can configure this via the "extensions.gallery.proxy" setting.

V. Stray for Mac Keyboard Shortcuts Summary

Function Category Action Description Shortcut (Mac)
General Operations Open Command Palette Cmd+Shift+P
File Management New File Cmd+N
Open Folder Cmd+O
Save Current File Cmd+S
Editing Operations Undo Cmd+Z
Duplicate Current Line Cmd+Shift+D
Delete Current Line Cmd+Shift+K
Toggle Line Comment Cmd+/
Navigation & Search Quick Open, Go to File Cmd+P
Find in File Cmd+F
Find Across Files Cmd+Shift+F
Interface Controls Toggle Sidebar Show/Hide Cmd+B
Toggle Integrated Terminal Ctrl+`
Toggle Full Screen Ctrl+Cmd+F
Windows & Tabs New Editor Tab Cmd+T
Close Current Editor Cmd+W
Source Control (Git) Open Source Control Panel Ctrl+Shift+G
Debugging Start Debugging F5
Preferences Open Settings Cmd+,

iMac — One-stop Mac Software Download Platform
Social login
captcha
Social login