2
0

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 3 years have passed since last update.

【VSCode】拡張機能無しでbrタグのショートカット追加

Posted at

rectangle_large_type_2_969247d7d006986fbd588cca5e651ed4.png

あらすじ

デザイン上のテキストをpタグなどにコピペして、それぞれの行にbrタグ入力して…ってやっていたけど流石にメンドすぎたので、ハックをGoogle.

white-space: pre-line; とかにしても良かったけど、開きタグの次は改行するっていうポリシーがあったのでやっぱやめた。

wpautop に慣れすぎるといけないな(でもやっぱり好きWordPress)

キーバインディングの追加

br タグショートカットといえども、機能的には「任意のキーを押したとき「<br>」という文字列を出力する」というモノなので、あしからず。

まずは「Ctrl + P」でコマンドパレットを開き

keyboard

と入力します。

そして、「基本設定: キーボード ショットカットを開く(JSON)」をクリックします。

すると、keybindings.json というJSON形式のユーザー用設定ファイルが表示されると思いますので、そちらに追記します。

公式ドキュメントより(というか以下のコードコピペでよいけど)

{
    "key": "ctrl+enter", 
    //Ctrl + Enterを押したとき macはCmdでも○
    "command": "type", 
    //argsの内容をもとに入力
    "args": {
        "text": "<br>" 
        //入力内容は<br> 改行タグ
    },
    "when": "editorTextFocus && editorLangId == 'html'" 
    //発動できるのはエディタ内がフォーカスされている && HTML形式のファイルを開いているときのみ
}

を追記します。

保存してCtrl + Enterを押してbrタグが入力されることを確認します。

めでたし!

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?