1

view is the readonly mode of vim. I would like view to read the exact same .vimrc file for its initialization as vim already does.

view does not seem to read ~/.vimrc by default (I checked by adding echo "hello, world" at the bottom). Using view -u ~/.vimrc does not work for me either. Reading :help initialization it seems that there are special files for evim and eview, but not for view.

Unsurprisingly, vim -R reads .vimrc files. How do I make view do the same?

Version info

vim

$ vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 14 2019 11:41:55)
Included patches: 1-160, 399, 402-403, 1099
Modified by <bugzilla@redhat.com>
Compiled by <bugzilla@redhat.com>
Huge version without GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
-balloon_eval    +float           +mouse_urxvt     -tag_any_white
-browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
-clientserver    -hangul_input    +netbeans_intg   +title
-clipboard       +iconv           +path_extra      -toolbar
+cmdline_compl   +insert_expand   +perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python/dyn      +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             +rightleft       +windows
+diff            +menu            +ruby/dyn        +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
+emacs_tags      -mouseshape      -sniff           -xsmp
+eval            +mouse_dec       +startuptime     -xterm_clipboard
+ex_extra        +mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/etc"
 f-b for $VIMRUNTIME: "/usr/share/vim/vim74"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D__linux__ -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L. -Wl,-z,relro -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,--enable-new-dtags -Wl,-rpath,/usr/lib64/perl5/CORE  -Wl,-z,relro  -L/usr/local/lib -Wl,--as-needed -o vim        -lm -lnsl  -lselinux  -lncurses -lacl -lattr -lgpm -ldl   -Wl,--enable-new-dtags -Wl,-rpath,/usr/lib64/perl5/CORE  -fstack-protector  -L/usr/lib64/perl5/CORE -lperl -lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc

view

$ view !$
view --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 14 2019 11:42:11)
Included patches: 1-160, 399, 402-403, 1099
Modified by <bugzilla@redhat.com>
Compiled by <bugzilla@redhat.com>
Small version without GUI.  Features included (+) or not (-):
+acl             -farsi           -mouse_sgr       -tag_old_static
-arabic          -file_in_path    -mouse_sysmouse  -tag_any_white
-autocmd         -find_in_path    -mouse_urxvt     -tcl
-balloon_eval    -float           -mouse_xterm     +terminfo
-browse          -folding         +multi_byte      -termresponse
+builtin_terms   -footer          -multi_lang      -textobjects
-byte_offset     +fork()          -mzscheme        -title
-cindent         -gettext         -netbeans_intg   -toolbar
-clientserver    -hangul_input    -path_extra      -user_commands
-clipboard       +iconv           -perl            -vertsplit
-cmdline_compl   -insert_expand   -persistent_undo -virtualedit
+cmdline_hist    +jumplist        -printer         +visual
-cmdline_info    -keymap          -profile         -visualextra
-comments        -langmap         -python          -viminfo
-conceal         -libcall         -python3         -vreplace
-cryptv          -linebreak       -quickfix        +wildignore
-cscope          -lispindent      -reltime         -wildmenu
-cursorbind      -listcmds        -rightleft       +windows
-cursorshape     -localmap        -ruby            +writebackup
-dialog          -lua             -scrollbind      -X11
-diff            -menu            -signs           -xfontset
-digraphs        -mksession       -smartindent     -xim
-dnd             -modify_fname    -sniff           -xsmp
-ebcdic          -mouse           -startuptime     -xterm_clipboard
-emacs_tags      -mouse_dec       -statusline      -xterm_save
-eval            -mouse_gpm       -sun_workshop    -xpm
-ex_extra        -mouse_jsbterm   -syntax
-extra_search    -mouse_netterm   -tag_binary
   system vimrc file: "/etc/virc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/etc"
 f-b for $VIMRUNTIME: "/usr/share/vim/vim74"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D__linux__ -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -Wl,-z,relro  -L/usr/local/lib -Wl,--as-needed -o vim        -lm  -lselinux -lncurses -lacl -lattr -ldl
8
  • 2
    Is you view actually from Vim, and not something else (say, heirloom vi)? What do view --version and vim --version report?
    – muru
    Oct 16, 2019 at 9:54
  • 1
    @muru both report VIM - Vi IMproved 7.4 at the top. However, view reports Small version without GUI compared to vim's Huge version without GUI. Nothing in the lists of included features (which are obviously different) suggest that initialization would be different. Both commands print similar list of vimrc files with view reporting one more than vim: system vimrc file: "/etc/virc". I'll add both outputs to the question.
    – andrybak
    Oct 16, 2019 at 10:20
  • 1
    You should consider that view is reading your .vimrc file but you're not seeing the effects of it. For example, if you expected to see syntax highlighting, that's disabled on the "small" version of Vim in RHEL/CentOS 7. Use :scriptnames to check which Vim script files were read by Vim (or view), that might tell you more or confirm whether .vimrc is being read or not...
    – filbranden
    Oct 16, 2019 at 10:31
  • 1
    if your view binary is provided by Vim, it should read your :vimrc. Check the output of :scriptnames to make sure. Oct 16, 2019 at 10:39
  • 1
    If the vim is without +eval, then echomsg() won't work as well. @andrybak, you might need to link view to your vim binary (the huge version). Or use update-alternatives, which is for Debian, so use the correct alternative for Redhat/CentOS Oct 16, 2019 at 11:20

1 Answer 1

0

My view --version showed that it's using $HOME/.virc So I linked $HOME/.vimrc to $HOME/.virc

$ cd
$ ln -s .vimrc .virc
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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