LoginSignup
0
2

More than 5 years have passed since last update.

VS Codeからqfixhowmを起動する

Posted at

QfixHowmを使いたい

  • VIMとVSCodeを行ったり来たり移動する を書いてから早半年、やっぱりVSCodeからQfixHowmを使いたい
    • よくよく考えると、QfixHowmルールで新規メモが作りたい
    • 調べるとVS CodeでShell実行できる
    • qfixhowmのソースを見ると、call qfixmemo#EditNew()を呼べばよさげ

ツール

検証

  • vim起動Optionでqfixhowmを叩く
vim -c "call qfixmemo#EditNew()"

VIM側

  • いけそうなので、前回記事を使いまわし「保存->閉じる->VSCODEオープン」をするVimScript準備
    • (qfixhowmで開いたあと、保存することでVIMを閉じたいだけです。)

"open vscode"{{{
if has('win32')
  nnoremap <silent> <leader>v :<c-u>call <SID>OpenVSCode()<CR>
  function! s:OpenVSCode()
    " target file
    let l:targetfile  = expand("%:p")
    let l:lastfolderid = strridx(targetfile,"/")
    let l:targetfolder = l:targetfile[0:l:lastfolderid]
    " command line
    "let l:cmd = '!code ' . l:targetfolder
    let l:cmd = '!code ' . l:targetfile
    silent execute 'write'
    silent execute 'quit'
    silent execute l:cmd
  endfunction
  command! -nargs=0 OpenVS call s:OpenVSCode()
endif
"}}}

VS Code側

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "qfixNewMemo",
            "type": "shell",
            "command": "vim",
            "args": ["-c call qfixmemo#EditNew()","-c w","-c OpenVS"]
        }
    ]
}

VS Codeショートカット

  • 作成したTaskをショートカット登録
// Place your key bindings in this file to override the defaults
[
  {
    "key": "Ctrl+n",
    "command": "workbench.action.tasks.runTask",
    "args": "qfixNewMemo",
  }
]

Ctrl+Nを実行すると、QfixHowmで新しいメモを作成して、VSCodeで開きなおします。

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