Visual Studio の簡易エディタ的な、Visual Studio Codeが発表されたので触った感触など。Windowsはもちろん、Mac、Linuxで動作するという優れものです。
以下が本家のサイトです。ここから情報を取得できます。
https://code.visualstudio.com/
今回検証した環境は、Hyper-V配下のUbuntu Desktop 14.04 LTS です。ちなみに、 VS Codeは、64bit版のバイナリのみの配布のようですので、OSも64bitにしましょう。
ダウンロード&インストール
上記URLからダウンロードするとZIPファイルが取得できます。適当に任意のフォルダに展開してパスを設定します。
展開したフォルダは以下のような感じです。余談ですが、展開されたフォルダをたぐっていくとJavaScriptファイルが多数みてとれます。Visual Studio Online "Monaco"由来のようです。
$ unzip VSCode-linux-x64.zip -d VSCode $ cd VSCode $ ls -al total 109952 drwxrwxr-x 4 moris moris 4096 May 7 17:07 . drwxr-xr-x 4 moris moris 4096 May 7 21:08 .. -rwxrwxr-x 1 moris moris 11224136 Mar 29 13:50 Code -rw-rw-rw- 1 moris moris 869779 Apr 28 14:37 Credits_41.0.2272.76.html -rw-rw-rw- 1 moris moris 122259 Apr 28 14:37 ThirdPartyNotices.txt -rw-rw-r-- 1 moris moris 8437142 Mar 29 13:17 content_shell.pak -rw-rw-r-- 1 moris moris 10457856 Mar 29 13:17 icudtl.dat -rw-rw-r-- 1 moris moris 76984472 Mar 29 13:50 libchromiumcontent.so -rw-rw-r-- 1 moris moris 2496440 Mar 29 13:50 libffmpegsumo.so -rw-rw-r-- 1 moris moris 520152 Mar 29 13:50 libgcrypt.so.11 -rw-rw-r-- 1 moris moris 31256 Mar 29 13:50 libnotify.so.4 -rw-rw-rw- 1 moris moris 10056 Apr 28 14:37 license.txt drwxrwxr-x 2 moris moris 4096 May 7 15:08 locales -rw-rw-r-- 1 moris moris 413533 Mar 29 13:17 natives_blob.bin drwxrwxr-x 3 moris moris 4096 May 7 15:08 resources -rw-rw-r-- 1 moris moris 985220 Mar 29 13:17 snapshot_blob.bin
起動
Code が実行ファイルです。fileするとバイナリってなってますん。
$ file Code Code: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=176e777a52b1683e73d2eb69527b98ddaebc5e6f, stripped
適当に実行してみるとVS Codeが起動します。
$ ./Code .
何か編集してみる
とりあえずNodeのなんかを編集してみたいとおもいます。node.js と npm はインストーしてください。
$ sudo npm install -g express $ sudo npm install -g express-generator $ express myapp $ cd myapp $ npm install $ node ./bin/www
上記でExpressのアプリのひな形を作成し実行してみます。Expressが起動すればOKです。
myappフォルダをVS Codeで開いてみます。jsファイルがコードハイライトされて表示されているのが確認できました。
所々で補完も効きます。
デバッグ
デバッグには、launch.jsonファイルと、mono 3.10.0 以上が必要です。launch.jsonは、.settings配下に存在するので、F5を押せばデバッグ開始ですが、環境によっては以下のようにエラーがでるでしょう。
stackoverflowにも書かれていますが、
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list sudo apt-get update sudo apt-get install mono-complete mono --version
で、さくっと最新版(この時点で、4.0.1) が入ります。
ちなみに、.setting/launch.json は以下です。
{ "version": "0.1.0", // List of configurations. Add new configurations or edit existing ones. // ONLY "node" and "mono" are supported, change "type" to switch. "configurations": [ { // Name of configuration; appears in the launch configuration drop down menu. "name": "Launch app.js", // Type of configuration. Possible values: "node", "mono". "type": "node", // Workspace relative or absolute path to the program. "program": "app.js", // Automatically stop program after launch. "stopOnEntry": true, // Command line arguments passed to the program. "args": [], // Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace. "cwd": ".", // Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH. "runtimeExecutable": null, // Environment variables passed to the program. "env": { } }, { "name": "Attach", "type": "node", // TCP/IP address. Default is "localhost". "address": "localhost", // Port to attach to. "port": 5858 } ] }
ふたたびデバッグを試してみると、以下のような感じでBreakpointを設定してデバッグできたりしました。
雑感
- VSの利用領域が広がるのはいい感じですが、久しくLinux(Unix) のデスクトップを使っていないので、どうなんでしょう。Macな人にとってはWelcomeなんでしょうか。
- Hyper-V配下で実行したんですが、エディタでマウスのスクロールボタンがうまく動きませんでした。他のアプリではキチント動作していたので、VS Code固有の問題でしょうか?
- やっぱEmacsキーバインディングが欲しい。キーバインディング含む、設定情報はすべてJSONで定義されてるので、がんばってカスタマイズすれば対応できるかもしれませんが、編集はEmacs + OmniSharpでいいのではないかという気も。