Make alias in your rc file.
alias view="vim -M"
Which do you use command for read files?
- less
- cat
- more
I thought sometimes "I wanna use vim for read file" "but i don’t want to miss editing".
Use view
command.
view
command is equivalent to Ireadonly mode vim. (vim -R
).
You can use all behaiviour of VIM while reading file. ( e.g. keyword search, move keystroke and more. )
Actually you can input text.
But unable to save it. ( :w
)
If you edited text, force quite required for escape from vim. ( :q!
)
$ vim -M
is "stronger" readonly mode.
$ vim --help | grep \\-M
-M Modifications in text not allowed
Register alias in your profile file is good. ( e.g ~/.zshrc
~/.bashrc
)
alias view="vim -M"
:set write ma
it means
:set write modifiable