Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim reopen current file into read-only?

Tags:

vim

I have searched through couple of places but wasn't able to find any answer. The title states it all, is there a command to close the current file and re-open it right away in read-only mode?

like image 542
PBJ Avatar asked Nov 16 '25 05:11

PBJ


1 Answers

say your file is hello.sh which you opened in vim with

vim hello.sh

now to close and open it in read-only, press ESC and type

:view!
like image 145
sa77 Avatar answered Nov 17 '25 21:11

sa77



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!