2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VSCodeをVimのように楽々オープン

Last updated at Posted at 2018-12-29

はじめに

Vimのように、簡単にVSCodeを開きたいと考えていたところ、すごく簡単に実現出来たので、その方法をご紹介します。

Project Managerよりも楽にディレクトリを開くことが出来る方法です。

具体的には、コマンド一つで、即座に現在のカレントディレクトリを開くことが出来るようになります。

codeコマンドのインストール

まずは、CLIからVSCodeを操作出来るように、codeコマンドをインストールします。

Screen Shot 2018-12-29 at 15.22.27.png

Command Palette(Shift + Command + P)を開き、shellと入力すると、「Shell Command: Install 'code' command in PATH」が表示されるので、それをクリックして実行します。

以下のコマンドでバージョンを取得出来ればインストール完了です。

$ code --version                                                                                                           
1.29.1
xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
x64

コマンド作成

以下のどちらかのコードを.zshrcに記載します。

前者は、zshの無名関数を使用しているため、bashなどでは使用出来ない

alias vc='(){ code $(pwd) }'

または

function vc() {
  code $(pwd)
}

Zshに新たなコマンドを反映させます。

source ~/.zshrc

まとめ

これで、即座にVSCodeでカレントディレクトリを開くコマンドが出来ました。

非常に簡単な設定ですが、ストレスなく開発レポジトリを切り替えられるようになります。

ちなみに、以下の記事のghq + peco + hubなどと組み合わせるとより楽になるのでやってみて下さい。

[ghq, peco, hubで快適Gitライフを手に入れよう!] (https://qiita.com/itkrt2y/items/0671d1f48e66f21241e2)

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?