Cursor code/cursor コマンド

Cursor は Visual Studio Code (VS Code) をベースにしたモダンなコードエディタであり、VS Code の強力な機能を継承しています。例えば、この記事で紹介するcodeコマンドです。

Visual Studio Code では、code 或 cursorコマンドは、VS Code をすばやく開き、コードに関連するいくつかの操作を実行するためのコマンドラインツールです。

code コマンドは、開発者がターミナルやコマンドプロンプトから VS Code を直接起動したり、特定のタスクを処理したりするのに役立ちます。

最も一般的な方法は、code 或 cursorコマンドを使用してコマンドラインから直接ファイルディレクトリを開くことです。この場合、まず code コマンドをインストールする必要があります。

Cursor はターミナル起動コマンドをcodeまたは cursor に設定して、エディタをすばやく起動できます。ローカルに VS Code がすでにインストールされている場合、codeコマンドは通常 VS Code で使用され、Cursor ではcursorコマンドを使用します。

Cursor の code コマンドを有効にするのは非常に簡単です。まずコマンドパレットを開きます:

  • macOS システムのショートカットキー:⇧⌘P(command + shift + p)
  • Windows/Linux のショートカットキー:Ctrl + Shift + P

検索してインストール >shell command:

次に選択します:PATH に "cursor" コマンドをインストール - Shell Command: Install 'cursor' command in PATHこれでシステムの PATH パスにcursorコマンドの参照が追加されました。

コマンドラインを使用して、ファイルを開いたり、拡張機能をインストールしたり、表示言語を変更したり、診断情報を表示したりすることができます。

次のコマンドcursor --versionでバージョン情報を確認します:

# cursor --version
0.45.14
906121b8c0bdf041c14a15dac228e66ab5505260
arm64

以下はよく使われるコマンドラインオプションです。次のcursor --helpコマンドで確認できます:

Cursor 0.45.14

Usage: cursor [options][paths...]

To read from stdin, append '-' (e.g. 'ps aux | grep code | cursor -')

Options
  -d --diff <file> <file>                    Compare two files with each
                                             other.
  -m --merge <path1> <path2> <base> <result> Perform a three-way merge by
                                             providing paths for two modified
                                             versions of a file, the common
                                             origin of both modified versions
                                             and the output file to save merge
                                             results.
  -a --add <folder>                          Add folder(s) to the last active
                                             window.
  -g --goto <file:line[:character]>          Open a file at the path on the
                                             specified line and character
                                             position.
  -n --new-window                            Force to open a new window.
  -r --reuse-window                          Force to open a file or folder in
                                             an already opened window.
  -w --wait                                  Wait for the files to be closed
                                             before returning.
  --locale <locale>                          The locale to use (e.g. en-US or
                                             zh-TW).
  --user-data-dir <dir>                      Specifies the directory that user
                                             data is kept in. Can be used to
                                             open multiple distinct instances
                                             of Code.
  --profile <profileName>                    Opens the provided folder or
                                             workspace with the given profile
                                             and associates the profile with
                                             the workspace. If the profile
                                             does not exist, a new empty one
                                             is created.
  -h --help                                  Print usage.

コマンドラインで次のcursor .コマンドを使用して、フォルダを Cursor で開くことができます:

コマンド 機能の説明
code <路径> ファイルまたはフォルダを開く
cursor . 現在のディレクトリをワークスペースとして開く
cursor --new-window 新しいウィンドウで開く
cursor --diff 2つのファイルの内容を比較する
cursor --wait ウィンドウが閉じるのを待ってからターミナルに戻る
cursor --disable-extensions すべての拡張機能を無効にして VS Code を実行する
cursor --install-extension <扩展名> 指定した拡張機能をインストールする
cursor --list-extensions インストールされているすべての拡張機能を一覧表示する
cursor --uninstall-extension <扩展名> 指定した拡張機能をアンインストールする
その他の拡張機能