Technology Sharing

Sublime usage

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Quick format: control command j (prerequisite: Pretty JSON plugin is installed)
Select multiple lines to edit: option command directly moves the bar to select

The multi-cursor editing feature performs the same operation on all lines. Here are some commonly used methods:
1. Select multiple rows using the mouse and keyboard
Hold down Ctrl (Windows/Linux) or Cmd (Mac) and click each row you want to edit, or hold down the Alt key and drag your mouse to select multiple rows.
Enter text in the selected locations and they will update synchronously.


In Sublime Text, you can use a plugin to quickly format JSON text. Here are the specific steps:

Installing Package Control
Open Sublime Text.
Press Ctrl + Shift + P (Windows/Linux) or Cmd + Shift + P (Mac) to bring up the Command Palette.
Type “Install Package Control” and press Enter. If it is already installed, you can skip this step.
Install Pretty JSON plugin
Press Ctrl + Shift + P (Windows/Linux) or Cmd + Shift + P (Mac) again to bring up the Command Palette.
Type “Package Control: Install Package” and press Enter.
Search for "Pretty JSON" in the pop-up input box and select it to install.
Format JSON text using Pretty JSON
Select the JSON text you need to format, or make sure the current file type is JSON.
Press Ctrl + Alt + J (Windows/Linux) or Cmd + Ctrl + J (Mac) to format the JSON text.
If the default shortcut keys don't work or you want to customize them, you can follow these steps:

Custom shortcut keys
Open Sublime Text's preferences: Preferences > Key Bindings
Add the following configuration to set shortcut keys, for example, bind Ctrl + Alt + F to Pretty JSON:
json
copy
[
    { "keys": ["ctrl+alt+f"], "command": "pretty_json" }
]
Now you can use the Ctrl + Alt + F shortcut to format JSON text.

Additionally, if you want to format the JSON text via the menu, you can also:

Right-click in the editing area, select Pretty JSON, and then select Format JSON.
With these methods, you can easily format JSON text in Sublime Text.