To solve this problem I have researched eVim program (Vim in eVim mode). I started testing on my Windows 7 PC where is my day to day Vim.exe installed.
So starting Vim in eVim mode from command line:
vim -y myfile
Now Vim becomes eVim (you know dummy insert mode all the time and using classic CTRL+action key like in Notepad for Windows). Now I can use:
CTRL+C to copy text
CTRL+X to cut text
CTRL+V to paste text
SHIFT+arrow_keys to select text
CTRL+A to select whole file
CTRL+S to save a file
CTRL+L to get into command mode and type :q to exit eVim
CTRL+O to get into command mode just for one command and then back to insert mode
All this works fine on Vim for Windows, but does not work at all in Vim for Ubuntu and Suse. All Vim's version are 7.4.
Now the question:
I have logged to Ubuntu 14.04 (also on Suse SLES) server and started the "vim -y myfile" command and CTRL+action commands just don't work.
How to make eVim to work on Ubuntu (or Suse)?
P.S. Bonus question: Is there any quicker way to exit eVim beside CTRL+L and :q ?
Thanks
> vim -y myfile
>
> Now Vim becomes eVim (you know dummy insert mode all the time and using classic CTRL+action key like in Notepad for Windows). Now I can use:
> CTRL+C to copy text
> CTRL+X to cut text
> CTRL+V to paste text
> SHIFT+arrow_keys to select text
> CTRL+A to select whole file
> CTRL+S to save a file
> CTRL+L to get into command mode and type :q to exit eVim
> CTRL+O to get into command mode just for one command and then back to insert mode
V>
> All this works fine on Vim for Windows, but does not work at all in Vim for Ubuntu and Suse. All Vim's version are 7.4.
I'm on Kubuntu 13.10. If I start vim with
vim -u NONE -N -y file
all those commands work. But if I just use vim -y some of them don't, so I think my .vimrc and .gvimrc get in the way. I suggest you try moving .vimrc and .gvimrc aside and use empty versions of them initially.
> P.S. Bonus question: Is there any quicker way to exit eVim beside CTRL+L and :q ?
Er, close the window? In KDE that defaults to Alt-F4, just like windows.
Zyx commented:
> This part has nothing to do with evim. These mappings are defined in $VIMRUNTIME/mswin.vim which is for some reason sourced by default on windows.
evim.vim sources mswin.vim, even when not on windows.
Regards, John Little
@John Little, I tried starting "vim -u NONE -y file" but still no success, the only shortcuts working is CTRL+A and CTRL+arrow_keys. The same problem on Ubuntu/Suse. Exactly the same as with only "vim -y myfile".
@John Little, about "bonus question": I can't just close down with ALT+F4, I am using headless = no GUI = terminal only server.
Additional test:
I have now also checked the same on "Ubuntu 14.04 Desktop" and having exactly the same problem with both starting commands (vim -y myfile and vim -u NONE -y myfile), exactly the same problem. I have also added only "set nocompatible" command in .vimrc file.
ON MY VIM FOR WINDOWS 7:
====================================
C:\>vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 10 2013 14:33:40)
MS-Windows 32-bit console version
Compiled by mool@tororo
Big version without GUI. Features included (+) or not (-):
+arabic +ex_extra -mouseshape +tag_binary
+autocmd +extra_search +multi_byte +tag_old_static
-balloon_eval +farsi +multi_lang -tag_any_white
-browse +file_in_path -mzscheme -tcl
++builtin_terms +find_in_path -netbeans_intg -tgetent
+byte_offset +float +path_extra -termresponse
+cindent +folding -perl +textobjects
+clientserver -footer +persistent_undo +title
+clipboard +gettext/dyn -postscript -toolbar
+cmdline_compl -hangul_input +printer +user_commands
+cmdline_hist +iconv/dyn -profile +vertsplit
+cmdline_info +insert_expand -python +virtualedit
+comments +jumplist -python3 +visual
+conceal +keymap +quickfix +visualextra
+cryptv +langmap +reltime +viminfo
+cscope +libcall +rightleft +vreplace
+cursorbind +linebreak -ruby +wildignore
+cursorshape +lispindent +scrollbind +wildmenu
+dialog_con +listcmds +signs +windows
+diff +localmap +smartindent +writebackup
+digraphs -lua -sniff -xfontset
-dnd +menu +startuptime -xim
-ebcdic +mksession +statusline -xterm_save
+emacs_tags +modify_fname -sun_workshop -xpm_w32
+eval +mouse +syntax
system vimrc file: "$VIM\vimrc"
user vimrc file: "$HOME\_vimrc"
2nd user vimrc file: "$HOME\vimfiles\vimrc"
3rd user vimrc file: "$VIM\_vimrc"
user exrc file: "$HOME\_exrc"
2nd user exrc file: "$VIM\_exrc"
Compilation: cl -c /W3 /nologo -I. -Iproto -DHAVE_PATHDEF -DWIN32 -DFEAT_CSCOPE -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 /Fo.\ObjCi386/ /Ox /GL -DNDEBUG /Zl /MT -DDYNAMIC_ICONV
-DDYNAMIC_GETTEXT -DFEAT_BIG /Fd.\ObjCi386/ /Zi
Linking: link /RELEASE /nologo /subsystem:console /LTCG:STATUS oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib comdlg32.lib ole32.lib uuid.lib /machine:i386 /nodefaultlib
libcmt.lib user32.lib /PDB:vim.pdb -debug
====================================
ON MY UBUNTU 14.04 HEADLESS SERVER
====================================
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 2 2014 19:39:32)
Included patches: 1-52
Modified by pkg-vim-m...@lists.alioth.debian.org
Compiled by buildd@
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 +viminfo
+cscope +lispindent -python3 +vreplace
+cursorbind +listcmds +quickfix +wildignore
+cursorshape +localmap +reltime +wildmenu
+dialog_con -lua +rightleft +windows
+diff +menu -ruby +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: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -o vim -lm -ltinfo -lnsl -lselinux -lacl -lattr -lgpm -ldl -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions
====================================
$VIM/vimrc on Ubuntu 14.04
====================================
" All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by
" the call to :runtime you can find below. If you wish to change any of those
" settings, you should do it in this file (/etc/vim/vimrc), since debian.vim
" will be overwritten everytime an upgrade of the vim packages is performed.
" It is recommended to make changes after sourcing debian.vim since it alters
" the value of the 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim
" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
syntax on
endif
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark
" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
" au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"endif
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
" filetype plugin indent on
"endif
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
"set showcmd " Show (partial) command in status line.
"set showmatch " Show matching brackets.
"set ignorecase " Do case insensitive matching
"set smartcase " Do smart case matching
"set incsearch " Incremental search
"set autowrite " Automatically save before commands like :next and :make
"set hidden " Hide buffers when they are abandoned
"set mouse=a " Enable mouse usage (all modes)
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
====================================
I have looked at the file /etc/vim/vimrc.local and it does not exists.
Any idea?
/usr/share/vim/vim74/evim.vim on Ubuntu 14.04:
=============================
" Vim script for Evim key bindings
" Maintainer: Bram Moolenaar <Br...@vim.org>
" Last Change: 2006 Mar 29
" Don't use Vi-compatible mode.
set nocompatible
" Use the mswin.vim script for most mappings
source <sfile>:p:h/mswin.vim
" Vim is in Insert mode by default
set insertmode
" Make a buffer hidden when editing another one
set hidden
" Make cursor keys ignore wrapping
inoremap <silent> <Down> <C-R>=pumvisible() ? "\<lt>Down>" : "\<lt>C-O>gj"<CR>
inoremap <silent> <Up> <C-R>=pumvisible() ? "\<lt>Up>" : "\<lt>C-O>gk"<CR>
" CTRL-F does Find dialog instead of page forward
noremap <silent> <C-F> :promptfind<CR>
vnoremap <silent> <C-F> y:promptfind <C-R>"<CR>
onoremap <silent> <C-F> <C-C>:promptfind<CR>
inoremap <silent> <C-F> <C-O>:promptfind<CR>
cnoremap <silent> <C-F> <C-C>:promptfind<CR>
set backspace=2 " allow backspacing over everything in insert mode
set autoindent " always set autoindenting on
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set incsearch " do incremental searching
set mouse=a " always use the mouse
" Don't use Ex mode, use Q for formatting
map Q gq
" Switch syntax highlighting on, when the terminal has colors
" Highlight the last used search pattern on the next search command.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
nohlsearch
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" For all text files set 'textwidth' to 78 characters.
au FileType text setlocal tw=78
endif " has("autocmd")
" vim: set sw=2 :
=============================
/usr/share/vim/vim74/mswin.vim
=============================
" Set options and add mapping such that Vim behaves a lot like MS-Windows
"
" Maintainer: Bram Moolenaar <Br...@vim.org>
" Last change: 2012 Jul 25
" bail out if this isn't wanted (mrsvim.vim uses this).
if exists("g:skip_loading_mswin") && g:skip_loading_mswin
finish
endif
" set the 'cpoptions' to its Vim default
if 1 " only do this when compiled with expression evaluation
let s:save_cpo = &cpoptions
endif
set cpo&vim
" set 'selection', 'selectmode', 'mousemodel' and 'keymodel' for MS-Windows
behave mswin
" backspace and cursor keys wrap to previous/next line
set backspace=indent,eol,start whichwrap+=<,>,[,]
" backspace in Visual mode deletes selection
vnoremap <BS> d
" CTRL-X and SHIFT-Del are Cut
vnoremap <C-X> "+x
vnoremap <S-Del> "+x
" CTRL-C and CTRL-Insert are Copy
vnoremap <C-C> "+y
vnoremap <C-Insert> "+y
" CTRL-V and SHIFT-Insert are Paste
map <C-V> "+gP
map <S-Insert> "+gP
cmap <C-V> <C-R>+
cmap <S-Insert> <C-R>+
" Pasting blockwise and linewise selections is not possible in Insert and
" Visual mode without the +virtualedit feature. They are pasted as if they
" were characterwise instead.
" Uses the paste.vim autoload script.
" Use CTRL-G u to have CTRL-Z only undo the paste.
exe 'inoremap <script> <C-V> <C-G>u' . paste#paste_cmd['i']
exe 'vnoremap <script> <C-V> ' . paste#paste_cmd['v']
imap <S-Insert> <C-V>
vmap <S-Insert> <C-V>
" Use CTRL-Q to do what CTRL-V used to do
noremap <C-Q> <C-V>
" Use CTRL-S for saving, also in Insert mode
noremap <C-S> :update<CR>
vnoremap <C-S> <C-C>:update<CR>
inoremap <C-S> <C-O>:update<CR>
" For CTRL-V to work autoselect must be off.
" On Unix we have two selections, autoselect can be used.
if !has("unix")
set guioptions-=a
endif
" CTRL-Z is Undo; not in cmdline though
noremap <C-Z> u
inoremap <C-Z> <C-O>u
" CTRL-Y is Redo (although not repeat); not in cmdline though
noremap <C-Y> <C-R>
inoremap <C-Y> <C-O><C-R>
" Alt-Space is System menu
if has("gui")
noremap <M-Space> :simalt ~<CR>
inoremap <M-Space> <C-O>:simalt ~<CR>
cnoremap <M-Space> <C-C>:simalt ~<CR>
endif
" CTRL-A is Select all
noremap <C-A> gggH<C-O>G
inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
cnoremap <C-A> <C-C>gggH<C-O>G
onoremap <C-A> <C-C>gggH<C-O>G
snoremap <C-A> <C-C>gggH<C-O>G
xnoremap <C-A> <C-C>ggVG
" CTRL-Tab is Next window
noremap <C-Tab> <C-W>w
inoremap <C-Tab> <C-O><C-W>w
cnoremap <C-Tab> <C-C><C-W>w
onoremap <C-Tab> <C-C><C-W>w
" CTRL-F4 is Close window
noremap <C-F4> <C-W>c
inoremap <C-F4> <C-O><C-W>c
cnoremap <C-F4> <C-C><C-W>c
onoremap <C-F4> <C-C><C-W>c
" restore 'cpoptions'
set cpo&
if 1
let &cpoptions = s:save_cpo
unlet s:save_cpo
endif
=============================
Any additional idea?
Sorry, vim -y starts the GUI on my system, despite having no "g", so I thought it would for you, too.
If I start vim with vim -y -v -u NONE -N, I see some of your trouble; I can't start a selection with <shift-left> and <shift-right>, but shift up, down, end, and home work, as does cut, copy (albeit silently) and paste. Investigating why <shift-left> and <shift-right> don't work, by using <ctrl-q> before typing them, I find that vim is being passed nothing. This is in konsole, the KDE terminal emulator, so I fired up xterm, and <shift-left> and <shift-right> work there. (After using stty to get a ctrl-q back (stty start ^@ stop ^@) I see vim getting ^[[1;2C and ^[[1;2D.)
The point behind the above (somewhat tediously detailed) is that your problems may stem from the key presses not being passed to vim by whatever it's running in. You might tell us that, and how your users connect to the servers.
You can check for this trouble by pressing <ctrl-q>; if you get a "^" with the cursor on it, then use a key press you're having trouble with, like <shift-left>. If nothing appears, vim is not getting it, or if something does appear, you have a terminal capability problem, see :help termcap, and consult the documentation for what vim is running in. <ctrl-q> might not work without some set up at the user end, like I had to with xterm.
A better approach altogether might be to use netrw, and run vim locally to the user. Can work brilliantly, particularly if the servers are "distant".
HTH, and regards, John Little