I often like to have a copy of the file that I am working on open on a second monitor, usually to assist with writing tests. I sometimes mindlessly attempt to edit it on this monitor, rather than the most up to date one. To prevent this, I have been setting read only mode with :set ro but that doesn't prevent me from making changes, it only prevents me from saving.
I would like a lock that turns off the ability to go into insert mode. I could create a toggle that remaps all the insert mode keys, but I was wondering if there is a better solution?
Yes, it's possible. :set nomodifiable in the buffer you want to mark read-only. This is used by plugins like taglist to create non-modifiable buffers.
You can open with the argument -M. This prevents edits to the buffer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With