Quantcast
Channel: Vimタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 5698

【Vim】カーソルキーでの移動を禁止する設定(ドラゴン付き)。

$
0
0

事前インストール

cowsayとslコマンド必要なので予めインストールが必要
brew install cowsay sl

設定方法

.vimrcに以下を設定する。

設定するとAAのドラゴンが丁寧に教えてくれる。

function TeachKey(message)let summon =join([!clear; cowsay -f dragon “,a:message,“を押すのだ”])
    exec summon
endfun
nnoremap <buffer><Left><Esc>:call TeachKey(h)<CR>
nnoremap <buffer><Right><Esc>:call TeachKey(l)<CR>
nnoremap <buffer><Up><Esc>:call TeachKey(k)<CR>
nnoremap <buffer><Down><Esc>:call TeachKey(j)<CR>
nnoremap <buffer><PageUp><Esc>:call TeachKey(‘Ctrl+B’)<CR>
nnoremap <buffer><PageDown><Esc>:call TeachKey(‘Ctrl+F’)<CR>
inoremap <buffer><Left><Esc>:call TeachKeyBi)ding(h)<CR>
inoremap <buffer><Right><Esc>:call TeachKey(l)<CR>
inoremap <buffer><Up><Esc>:call TeachKey(k)<CR>
inoremap <buffer><Down><Esc>:call TeachKey(j)<CR>
inoremap <buffer><PageUp><Esc>:call TeachKey(‘Ctrl+B’)<CR>
inoremap <buffer><PageDown><Esc>:call TeachKey(‘Ctrl+F’)<CR>
vnoremap <buffer><Left><Esc>:call TeachKeyBi)ding(h)<CR>
vnoremap <buffer><Right><Esc>:call TeachKey(l)<CR>
vnoremap <buffer><Up><Esc>:call TeachKey(k)<CR>
vnoremap <buffer><Down><Esc>:call TeachKey(j)<CR>
vnoremap <buffer><PageUp><Esc>:call TeachKey(‘Ctrl+B’)<CR>
vnoremap <buffer><PageDown><Esc>:call TeachKey(‘Ctrl+F’)<CR>

nnoremap <buffer><Del><Esc>:<C-u>!sl<CR>
inoremap <buffer><Del><Esc>:<C-u>!sl<CR>
vnoremap <buffer><Del><Esc>:<C-u>!sl<CR>set backspace=0

確認方法

設定されるとこんなのが出る。

image.png

参考URL

vi(vim)で完全にカーソルキーを無効化させたい - スタック・オーバーフロー

development/vim


Viewing all articles
Browse latest Browse all 5698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>