In vim I can open a file in a vertical split by using the command vs myfile.txt
and I can open a file in a new editor, in read only mode with vim -R myfile.txt
.
I want to combine these to commands, ideally vs -R myfile.txt, but of course I've already discovered that doesn't work. I want to open the file this way because I have the file open in a different tab and I want to be sure that I don't accidently edit the file.
Splitting Vim Screen Vertically Press the keyboard combination Ctrl + w , followed by the letter 'v' .
Just open your file by using :tabe <filename> , then enter :view . It will automatically switch to read-only mode.
To open a new VIM window next to the existing one, press <Ctrl>+<w> then press <v>. You can move to the left window again by pressing <Crtl>+<w> and then pressing <h>. To open a new VIM window on the bottom of the currently selected window, press <Ctrl>+<w> then press <s>.
The command to view a file in "readonly mode" is :view
. You can split the current window and run :view
:
:vs|view file
And here is a variant:
:vert sview
If you want one file to be editable and only one read-only.Then
vim writablefile.txt
:vs | view readonlyfile.txt
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