I want to open file with modifiable buffer set noma
ON by default for this specific file.
for example something like this:
vi file1.txt noma
vi file2.txt ma , # default
OR at least inside vim:
:tabnew file1.txt noma
Thanks
I want to open file with modifiable buffer set noma
ON by default for this specific file.
for example something like this:
vi file1.txt noma
vi file2.txt ma , # default
OR at least inside vim:
:tabnew file1.txt noma
Thanks
You can add that to your .vimrc
, which will set the flag if the file has that name:
augroup ReadOnly
autocmd!
autocmd BufReadPost file1.txt set noma
augroup END
That will set it both if the file exists (BufReadPost
).
Edit: The view
command allows you to open a file in readonly mode.
For reference: :help autocmd-groups
and :help autocmd-define
You can use the -R
command-line option to open a file in 'readonly'
mode (which includes 'nomodifiable'
and also other options that are useful when viewing files.)
$ vim -R file1.txt
The view
command is usually available as a shortcut to vim -R
, so this is often also possible:
$ view file1.txt
If you already have a Vim running and want to use it to open a file in read-only mode in a new tab, you can use this sequence:
:tab sview file1.txt
The :view
command opens a file in read-only mode, the :sview
command does so in a split and the :tab
modifier has Vim do so in a new tab instead.