4
4

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.

VimのチートシートをVim内に表示するコマンド作ってみた

Last updated at Posted at 2020-06-02

Vimのコマンドを調べるのに、わざわざブラウザ立ち上げたりとか、PDFのチートシートを開いたりとかが面倒だったので、Vim内にチートシートを表示するコマンドを作ってみた。

こんな風に動くよ

Vimの編集モードで:Cheatと入力すると、、、
image1.png

ウインドウを分割し、チートシートが表示される!(ReadOnlyで)
image2.png

それだけです。シンプルイズベスト。
ちなみに、:qで終了し元の編集ファイルに移動する。

コード

以下を.vimrcに追加する。
(チートシートのファイル名は適宜変更ください)

" :Cheatコマンド
function! Cheat()
  :vsplit
  :wincmd w
  execute 'view' '~/.vimcheatsheet.md'
endfunction
:command! Cheat call Cheat()

ちなみに、下記環境です。

  • Vim version 8.1.2292
  • MacOS Catalina 10.15.4

感想

プラグインでもっと高機能なものもありそうだけど、
まずはこれくらいのシンプルさでやってみようかなと思います。

4
4
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
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?