3
3

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

ページャーとして使うVim

Last updated at Posted at 2015-01-13

emacsのview.elは、Emacsをページャーとして簡単な操作を与え、
ファイル観覧中など一時的に編集したくない時にそれを防ぐのに便利でしたので
簡易的にVimに移植しました。
Space で ページ送り
b で 1ページ戻る
q で quit
,r で 通常とview-modeのトグル

.vimrc
" read only Mode
autocmd! BufEnter,BufNewFile * call s:read_only_mode()
nnoremap ,r :call <SID>myRO()<CR>
function! s:myRO()
    :set readonly!
    :call s:read_only_mode()
endfunction

function! s:read_only_mode()
  if &readonly
    nnoremap <buffer><silent> <Space> <PageDown>
    nnoremap <buffer><silent> b <PageUp>
    nnoremap <buffer><silent> q :q<CR>
  else
    nnoremap <buffer><silent> <Space> <Space>
    nnoremap <buffer><silent> b b
    nnoremap <buffer><silent> q q
  endif
endfunc

3
3
2

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?