I installed cygwin on Windows 7. When I start vim in cygwin terminal it starts in interactive mode. I can't change mode to command one by pressing ESC. What could be the reason?
UPDATE:
Also vim prints these varnings at start:
Vim: Warning: Output is not to a terminal
Vim: Warning: Input is not from a terminal
If by interactive mode you mean insert mode (where keypresses are inserted as text, just as in other editors), then your Vim is in easy mode.
In it, you can temporarily execute normal mode commands via Ctrl + O. But I guess you don't want this strange beginner's mode. To turn it off, check whether Vim has been invoked with the -y argument or as evim (is there a shell alias?). Or, if you find a :set insertmode command in a .vimrc, remove it. (By default, at least in my Cygwin installations, Vim is not configured for easy mode, so it must be something in your configuration.)
Try to
Press “ESC” and "shift" and ":" together;
You should find the place that you can type command line in vim;
Related
I have recently switched to vim style key binding for my terminal by placing set -o vi in my .zshrc file. When using it I find myself in this "excute:_" mode after pressing Esc and then : , the terminal then looks like this:
[I] ➜
execute: _
What is this mode and how do I exit it?
I have looked here and here for answers to no avail. I also asked in the vim stack exchange and got told to move.
I think it's called the vicmd mode. You can execute commands from the ZLE (Zsh Line Editor).
For example, you can type ed then TAB for completion which should write edit-command-line and if you run it, it will open your editor to edit the current line (as the name suggest).
You can go back to normal mode with ctrl + c
In my init.vim for Neovim, I have the same line as in my .vimrc in Vim, which, when pressing F12, runs the file currently in the buffer using the python3 interpreter:
autocmd FileType python nnoremap <silent> <F12> :!clear;python3 %<CR>
Now I'm trying to run this tiny "test.py" script by pressing F12 in normal mode:
import IPython
IPython.embed()
Works fine in Vim:
But doesn't work in neovim despite exactly the same line in my ~/config/nvim/init.vim:
So it does run IPython, but then immediately (red arrow) inexplicably asks if I want to exit. It's also got a bunch of weird escape sequences inserted (yellow arrow) which I suspect are the reason why it wants to exit, and which don't appear with normal vim.
I don't really like the internal neovim terminal, so how can I get neovim to behave exactly like vim in this case?
This is a known limitation of NeoVim, :! is non-interactive and it will not allocate a pseudo-terminal which is typically required for full-screen applications such as IPython to run properly.
See issue #1496 for details.
An alternative is to use NeoVim's (or Vim 8's) support for terminal, with the :terminal command, or with a function such aa termopen() (in NeoVim) or term_start() (in Vim 8) to run full-screen applications such as IPython.
In your case, something as simple as :term python3 %, running the command in a terminal in a split, might be an adequate replacement.
You might also find the vim-bang-terminal plug-in interesting. It replaces a :! command with a similar command invocation that runs inside a Vim/NeoVim terminal instead.
Accidentally I typed vim -y install python-requests instead of yum ... and I do not know how to exit from vim now. Standard option with shift + : + q! does not work. Are there any options how to exit from vim without killing it?
With -y (easy mode), Vim defaults to insert mode, and you cannot permanently exit to normal mode via <Esc>. However, like in default Vim, you can issue a single normal mode command via <C-O>. So to exit, type <C-O>:q!<CR>.
Alternatively, there's a special <C-L> mapping for easy mode that returns to normal mode.
-y option makes vim start in easy mode, you can type CTRL-L to return to normal mode and then type :q! to exit.
I use the gVim Easy, and it works for me to add the set im! in the .gvimrc.
gVim Easy v.s. gVim
It's good to remember that vim and vim -y (gVim Easy) are almost identical except for these differences:
vim starts out in NORMAL mode; vim -y starts out in INSERT mode.
Esc, Ctrl-[, and Ctrl-C exit INSERT mode in vim. However, these do not work in vim -y. Instead, these have been replaced with Ctrl-L.
And it's good to remember this important similarity as well:
In INSERT mode, both vim and vim -y will allow you to use the Ctrl- commands that work during INSERT mode. Examples include:
Ctrl-T to indent the current line.
Ctrl-D to dedent (that is, un-indent) the current line.
Ctrl-N and Ctrl-P to auto-complete the word currently being typed.
Ctrl-R x to paste the contents of register x where the cursor is.
and, relevant to this thread:
Ctrl-O to temporarily enter NORMAL mode to issue one NORMAL-mode command (after which you'll immediately return to INSERT mode).
Hopefully you'll see that this last one (the Ctrl-O command) will allow you to save (with :w), save-and-quit (with :wq), discard unsaved changes (with :e!), as well as simply quit-without-saving (with :q!).
You can also use Ctrl-O followed by a non-ex command, like u (for "undo"), dd (to delete the current line), ZZ (to save-and-quit), and ZQ (to quit-without-saving).
So if you're not familiar with using Ctrl- commands in vim's INSERT mode, I strongly recommend learning at least the Ctrl-O command, as remembering that will help you figure out how to exit (and save documents in) vim -y. (While knowledge of Ctrl-L will help with vim -y, knowledge of Ctrl-O will help in both vim -y and vim.)
Key Takeaways
If there are only two things you remember from this post, remember these:
vim's normal way of exiting INSERT mode (that is, Esc, Ctrl-[, and Ctrl-C) have been replaced with Ctrl-L in vim -y (Vim Easy).
The INSERT mode command of Ctrl-O works just as well in vim -y (Vim Easy) as it does in vim. So you can use it to your advantage to execute any NORMAL commands you want.
I want to copy text from vim buffer to the system clipboard by using the command "*y but when I press the double quote sign in command mode, it doesn't seem to get fired at all as I don't see anything in the status bar (nothing gets copied also even if I blindly continue with the command). I can see all other commands in the status bar in vim. I'm using Ubuntu 12.04 and I have clipboard support enabled in my vim version.
You should press "+y in NORMAL (or VISUAL) mode.
If you love to do it in command line, do this:
:y +
(same for "*y)
:echo has('clipboard') returns 1, but whenever I execute "+yy" or "*yy" nothing seems to be in those registers. If I use regular yy to copy another line of text, then try to paste from the register using CONTROL+V nothing happens. If I try "+p vim pastes the line of text I copied using the regular yy command.
What's going on here? I'm on FreeBSD by the way.
Your vim version may not be compiled with X11 clipboard integration.
In vim run the :version command and look for xterm_clipboard in the output. It will be prefixed with a + (supported) or - (unsupported) sign.
What worked for me in Ubuntu 20.04 and Vim 8.1.2269
sudo apt install vim-gtk3
Explanation
This package adds support for the x_term_clipboard in vim if not present already.
For more info: Click Here, #blankblank's answer.
Another thing that could be going on is your DISPLAY environment variable is not being set correctly. This could happen sometimes if you're running vim from tmux or screen.
Try opening a new terminal, running echo $DISPLAY, and then from the terminal running vim, leave vim, execute export DISPLAY=:0 (but replace :0 with the output from your other terminal), and then re-enter vim and see if clipboard works by doing "+p.
If you have copy something to clipboard and paste that in vim, you can use "+p.
+ is a quoteplus, which means CLIPBOARD documented X selection. :help quoteplus for more information.
If you want to copy something in vim to clipboard and paste the content in the other place by Ctrl+v, you can do "+yy, this will copy the current line to clipboard.
more information about vim register:
:help registers
:help quotestar
I also met this problem.
My case is that DISPLAY is not set properly in tmux.
And I found a script to automatically update tmux DISPLAY.
My problem was my input source English (US, intl., with dead keys), in addition to vim not being compiled with x-clipboard.
I don't face the same issue on windows, but on Ubuntu 20.04 I have to press "<space>+y with this input source.
Edit:
Seems I can fix this by switching the input source to English (Intl. with AltGr dead keys)