(未解決)VSCode上で、関数を別のファイルに移動して、参照されてるpathも修正したい
未解決

関数に限らず、移動を楽にする方法ないかな?

普通にやると以下の手順を踏まないといけない
ファイル内の1つの 関数F
を選択
移動先を指定して、 F
を移動
F
をimportしていた別のファイルたちのimportのpathも変更
F
を参照しているファイルを全部開く
F
をimportしている部分のimport文を消す
importし直す
F
を参照されている箇所が多いほど手間が増えてダルい

現状の楽にする方法
「参照しているファイルを全部開くのがダルい」を解消する方法
「シンボルの名前を変更」で適当に F2
とかにrenameして確定する
すると、それを参照しているファイルが自動で開かれる
ctrl-z
でrenameを戻す
これでファイル自体は開かれたので、importを直していく
全てのimport文を絶対パスにする
こういう設定になっていれば、grepで置換できる
VSCodeの機能に「Move to new file」というのがある
関数を選択して、「リファクタ」を選ぶとその中にある
でもこれだと微妙で、
to new file
ではなくて、
to existing file
をしたい

めちゃくちゃおなじようなissueが作られまくって、duplicateのリンクでここに来てる
move to another (existing) file
下の方のコメントで紹介されている拡張
これの機能に
Move to Existing File
があるけど、なんか動かなかった

特に進展しなかった...
