Vim勉強会#7を開催しました
4/29 にVim勉強会#7を開催しました。
@thincaさんと@kana1さんの下記 Vim script を紹介しました。
- ref
- quickrun
- smartchr
- submode
installについて
shellで
cd mkdir projects cd projects git clone http://github.com/thinca/vim-ref.git git clone http://github.com/thinca/vim-quickrun.git git clone http://github.com/kana/vim-submode.git git clone http://github.com/kana/vim-smartchr.git
Vimで
:helptags ~/projects/vim-ref/doc :helptags ~/projects/vim-quickrun/doc :helptags ~/projects/vim-submode/doc :helptags ~/projects/vim-smartchr/doc :e ~/.vimrc
.vimrc
set nocompatible set runtimepath+=~/projects/vim-ref,~/projects/vim-quickrun,~/projects/vim-submode,~/projects/vim-smartchr filetype plugin indent on syntax enable
ref
alc, man, perldoc, phpmanual, pydoc, refe を Vim から参照できるようにしてくれる Vim scriptです.
使用法 (perldoc, phpmanual は割愛)
:Ref alc (Japanese or English word) | alc の search result を Vim で参照 |
:Ref man | command list から select することで command の man を Vim で参照 |
:Ref man (command) | command の man をVim で参照 |
:Ref pydoc | module list から select することで Python の module の document を Vim で参照 |
:Ref pydoc (module name) | Python の module の document を Vim で参照 |
:Ref refe | class list から select することで Ruby の class の document を Vim で参照 |
:Ref refe (class name) | Ruby の class の document を Vim で参照 |
quickrun
buffer の内容を filetype に応じて評価し, その結果を別の buffer に出してくれる Vim script です
使用法
- :QuickRun で buffer の内容を filetype に応じて評価してくれます. visual mode で select した part のみ評価することもできます.
- Vim script の評価もできます. 勉強会ではVimスクリプト基礎文法最速マスターを参照し, Vim scriptの評価をしました.
- save 時に :QuickRun したいなら
nnoremap <Leader>w :<C-u>update<CR>:QuickRun<CR>
submode
使用法
.vimrc に下記のような Vim script を書くのが典型的な使用法です.
- tab walk
call submode#enter_with('tabwalk', 'n', '', 'gt', 'gt') call submode#enter_with('tabwalk', 'n', '', 'gT', 'gT') call submode#map('tabwalk', 'n', '', 't', 'gt') call submode#map('tabwalk', 'n', '', 'T', 'gT')
- undo branch (:help undo-branches)
call submode#enter_with('undo/redo', 'n', '', 'g-', 'g-') call submode#enter_with('undo/redo', 'n', '', 'g+', 'g+') call submode#map('undo/redo', 'n', '', '-', 'g-') call submode#map('undo/redo', 'n', '', '+', 'g+')
- adjust window size
call submode#enter_with('winsize', 'n', '', '<C-w>>', '<C-w>>') call submode#enter_with('winsize', 'n', '', '<C-w><', '<C-w><') call submode#enter_with('winsize', 'n', '', '<C-w>+', '<C-w>-') call submode#enter_with('winsize', 'n', '', '<C-w>-', '<C-w>+') call submode#map('winsize', 'n', '', '>', '<C-w>>') call submode#map('winsize', 'n', '', '<', '<C-w><') call submode#map('winsize', 'n', '', '+', '<C-w>-') call submode#map('winsize', 'n', '', '-', '<C-w>+')
smartchr
key repeat の回数に応じて insert される character を替えてくれます.