1

I've install both vi & vim in RedHat 6.7. Both of them are 7.4 but with different features turn on or off. I've setup a line in ~/.vimrc set mouse=a And the color scheme molokai is imported by plugin manager dein. These features are workable when I type vim, but it shows error message when I use view which is a link to /bin/vi. The error messages are

Error detected while processing /home/myname/.vimrc:    
line   21:                                            
E538: No mouse support: mouse=a                       
line  263:                                            
E185: Cannot find color scheme 'molokai'              

I'm wonder how could I write a workable .vimrc for both vi/view or vim? Here is the features about mouse on the different versions:

$ /bin/vi --version|grep mouse
+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
-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

$ /usr/bin/vim --version|grep mouse
+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
-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

2 Answers 2

1
  • For those features that are listed in :version output, you can use if has('mouse') conditionals.
  • Another built-in function that can be used for many tests is :help exists().
  • The sledgehammer method: just prepend :silent! in front of the command; it will silence any errors.
  • If vi is a different binary, you can also check the :help v:progpath variable.
0

Can you try putting that in your ~/.vimrc:

set mouse=a
set ttymouse=xterm2

My /usr/bin/vi has mouse support:

#vi --version | grep mouse
+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
-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

But vi on my system is a symlink to vim so it's not applicable.

So you answered your question, your version of vi will not support mouse.

3
  • The problem is the vi has no feature of mouse Commented Feb 2, 2017 at 1:18
  • Ok makes sense good to know.
    – Wadih M.
    Commented Feb 2, 2017 at 1:19
  • I found I can use has('mouse') to solve the setting, but I don't know how to check the colorscheme Commented Feb 2, 2017 at 2:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .