LoginSignup
7
3

More than 5 years have passed since last update.

VSCode&Rubyでctagメソッドジャンプ導入

Last updated at Posted at 2019-03-08

VSCode&Rubyでctagメソッドジャンプ導入

前提:Macでの導入

ctag:

クラスの宣言元にジャンプするために必要なtagsファイル、それを作るのがctagsコマンド。

gem:ripper-tagsを導入

$ gem install ripper-tags

ripper-tagsのFilePathを確認

$ which ripper-tags
=> ***  # 後程FilePathの指定のとき使う

あとはvscode-ruby-ctagsに従って、導入する。

VSCodeのエディタ設定ファイルを修正

Cmd + ,: 設定画面を開く
右上 {}をクリック:settings.jsonを編集

settings.json
"ctags": {
    "executePath": "/home/username/.rbenv/shims/ripper-tags",
    "options": "--tag-file=.tags --recursive --force --exclude=/assets/ --exclude=.bundle --exclude=.git/ --exclude=coverage/ --exclude=.arcanist-extensions/ --exclude=log/ --exclude=tmp/ --exclude=bin/",
    "fileName": ".tags"
}

プロジェクトフォルダを開く

コマンドプロンプト表示

fn + F1

Generate file of ctag

$ CTAGS:Generate Ruby tags

Generate Ctags

=> Cmd + Option + g
(※少し時間を要する)

Search ctags with selection of the words

Cmd + Option + t

その他

ファイル名検索でvendor/bundle も検索対象にしたい

Cmd + ,
{}
下記の内容を追加

settings.json
+    "search.useIgnoreFiles": false

参考:

vscode-ruby-ctagsがうまく設定できない時
Ctags - Wikipedia

Ctags(英: Ctags)はソース及びヘッダ内にある名前のインデックス(又はタグ)ファイルを生成するプログラム。様々なプログラミング言語に対応している。言語に依存するが、サブルーチン(関数)、変数、クラスのメンバ、マクロ等がインデックス化される。これらのタグによりテキストエディタなどのツールで高速かつ容易に定義を参照できる。相互参照ファイルを出力でき、また名前についての情報を人が読みやすい形で列挙した言語ファイルを生成することもできる。

7
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
3