I use /bin/view as it is a safe way to view text files and not have accidental changes persist once I am finished.

/bin/view seams to be lack features that normal vim has. Is there a way to start vim in read only mode, or start /bin/view with visual mode.

I want to be able to select text and paste it with out having to use my mouse. Visual mode make it so easy to do that.

The problem I am having is related to CentOS / redhat Linux distros, is the -visual in view.

# vim --version | grep visual
+user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace 
# view --version | grep visual
-textobjects -title -toolbar -user_commands -vertsplit -virtualedit -visual
  • view is a link (usually symbolic these days) to vim that runs vim in read-only mode. Your view seems to be linked to a different vim than the one you get from executing "vim". Take a look at the update-alternatives(8) man page to see how to fix that. – garyjohn Feb 28 '12 at 17:11

See $ vim --help for Vim's many launch arguments.

For launching Vim in read only mode that would be:

$ vim -R filename


$ view and $ vim -R seem to be one and the same by way of symbolic links. I'm not sure what features you'll gain from running $ vim -R that you don't have with $ view.

Here, on Ubuntu, I can visually select stuff in both.

  • In centos view and vim -R are not the same. view is compiled with -visual for some reason. – nelaaro Mar 1 '12 at 6:43

If you forgot the -R option when start up vim, you can use:

:set ro

If your goal is simply not to overwrite the original file, you can vim's read from stdin feature:

cat filename | vim -

As @garyjohn mentioned, view is often symbolically linked to either vi or vim. Depending on which Linux distribution you are using and how vi or vim were installed this could vary. On my RHEL 6 system the output of ls -l `which view` shows that /bin/view is symbolically linked to vi.

So if you want the features of vim in read-only mode you would either need to alias view to vim or use vim -R <filename> solution provided by @kev (assuming you don't have privileges to change the symbolic links on the system in question).

  • This is what I did, and it works perfectly (where vim is any version/flavour of Vim). Now I can have a read-only window for viewing side-by-side diffs in vim, with another window also editing the actual file at the same time. – Benjamin R Mar 6 '18 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.