Seemingly randomly, when I press dw to delete a word, it will go into insert mode instead of staying in normal mode. I cannot figure out the logic behind this switch and it's getting real annoying
I first noticed this on the the VS Code Vim extension. I then went to Vim itself and found that it was also doing this anomaly. This also works with multiple keyboards and multiple computers.
Note that my installation of vanilla Vim is through Git for Windows, through cmder.
Is there a rhyme or reason to this? If so, what is it and why does it do that?
Edit: Turns out I was actually hitting cw instead of dw. Thanks to mMontu for helping me figure out my mental issues. lol
tl;dr: Nothings wrong, just a EBKAC error.
As noted in the comments, it is this is happening on completely different editors. My guess is that you (or your keyboard) are inserting some other command.
You could leave the recording turned on, and when you notice the issue again you can check what keys where sent to vim:
qa -> start recording on register a
<use vim until the issue happens>
q -> stop recording
:register a -> list the keys recorded
Another option is to save all the keys typed in a separated file (which may be better if it take a long time to reproduce the issue:
vim -w script file.txt ...
More details about this approach at :help -w and at the end of :help 26.4.
It is worth trying to reproduce the issue without any settings or plugins,
vim -u NONE -U NONE -N -i NONE
, as explained in :help faq-2.5. As you are on Windows, you will need to open a cmd.exe and enter something like <path to executable>/vim.exe -u NONE -U NONE -N -i NONE (or gVim.exe).
You also mentioned are installing Vim from Git. If everything else fails, check if it also happens with the binary available from Vim website.
Related
I'm a Neovim user
and I want to move by page for fast movement.
I found these commands, but for me only ctrl-u(half-page up) is working
I reference this page
Ctrl-D move half-page down
Ctrl-U move half-page up
Ctrl-B page up
Ctrl-F page down
How can I figure out the problem?
The problem is except ctrl-U, nothing works
where can I check these default key map in my setting?
I suggest starting your vim with no configuration to know if the problem is on vim or in your config files:
nvim -u NONE -U NONE -N -i NONE
Now test your shortcuts, if everything goes well try analyzing your settings
I also suggest a second test, try opening your vim in another terminal emulator, this issue can also be caused by your terminal. (These final paragraph was also in the comments and helped figuring out the problem)
I am using Vim as my main editors for a few days now.
Using http://www.github.com/astrails/dotvim as the base of my installation.
The problem I am having is that when I run the specs, the result of the specs is not delayed on the screen and I can't see what is going on.
to further explain this, I have a video to demo the situation:
http://www.youtube.com/watch?v=gUB48XwNq0M&feature=plcp
I need to hide vim with CTRL+Z and then fg to show it again, that's obviously not good.
Would love help on this
** Edit **
I posted about the problem in more detail here:
http://avi.io/blog/2012/08/05/problem-with-running-spec-in-vim/
I would first check if this is the same behavior for any shell command you run, or just when you run spec files.
E.g. how does a simple run of 'ls' from within VIM behave?
:!ls
If the above waits for 'Enter', I would guess that you have a trailing space (or similar) in the mapping that runs your spec.
For example, adding this line to your .vimrc will map Leader-l to the 'ls' command and will prompt for 'Enter'.
nmap <leader>l :!ls<cr>
However if you add the same line with a trailing space at the end, it will exit the console immediately:
nmap <leader>l :!ls<cr>
So I would check the mapping you use to run the specs.
This might have something to do with :help more, but I think the best solution for this sort of thing is a combination of tmux and turbux.vim. See the video here.
I'm having a problem with Vim (I've had it many times before, and now I finally must post it). I don't believe its just a vim thing, but maybe a combination with running it on ssh. Here is a video showing my problem:
http://screencast.com/t/gGoOuJ7wcLA5
I didn't know a way to explain it, so I took the video. If you can't tell, in the video all I do is move my cursor up and down with the j and k keys for vim. For some reason, vim adds on other { signs when my cursor is over the { sign. Vim garbles a lot of other code that I write too, but I'm hoping this example is good enough. Btw, vim does not actually change this. If I quit vim and reopen the text, the characters written are not there. Could it have anything ot do with my $TERM? I have xterm-256color. I've tried xterm originally too.
I'm running this in iTerm on Mac OSX Lion 10.7 accessing a machine over ssh with a Debian OS.
The problem was that the $TERM in in the Debian OS I was accessing was different than the $TERM for iTerm. Once I made them the same (xterm-256color in my case), the weird problem I had went away.
In case anyone doesn't know how to change that, I ran the following command in my Debian/Ubuntu machine:
export TERM=xterm-256color
and for iTerm on Mac, I went to Preferences -> Profiles -> Terminal -> Report Terminal Type -> Choose xterm-256color or xterm.
Since the check for TERM is done at the beginning of logging onto ubuntu, you may want to include the export command into your bashrc (or equivalent file for another terminal shell).
Does :redraw! remove the rubbish characters?
If so, I would try to solve your problem by trying to download the source of the matchparen.vim plugin (easy to find on google), add redraw! to it, just after the critical bit, where it says "setup match highlighting" and try to load it and use it instead of the original one.
Is there a command which shows what was the last command in normal mode?
Suppose I accidently hit random key and got some unexpected result.
Sure I can undo it, but could I reveal what key was pressed and how it was interpreted?
Hit the colon (:) and then use the up arrow to start going back through previous commands. You can use the up/down arrows too to move around the list.
q: will show you command history in Vim.
q/ will show you history of searches.
And must importantly, :q will quit the mode.
The text from the last command is stored in the . register. You can see all registers by :display. Unfortunately it doesn't say what the started the normal command.
To see commands from : (command mode) you can use :hist or q: which is limited to the last 20 (by default).
Another ability is to save the undo buffer :wundo undo.bin -- but the undo buffer is binary.
But none of these actually answer your question. I'm curious if it can be done.
Entering colon : then ctrl+p shows your previous command, i.e., moving backward through your vim command history. ctrl+n moves forward.
This is very convenient if you're used to using the command line and prefer not to change your keyboard hand positioning to use arrow keys.
It is difficult to know it. You can play with the variables:
v:operator
v:count (and v:prevcount)
v:register
But you cannot fully get the last normal mode command issued.
However if you want to systematically record everything you type while in Vim, you can launch vim -W ~/.vim-last-scriptout (a Windows version: vim -W "%HOMEPATH%\Vim\.last-scriptout) You can alias it in your shell on a UNIX machine. Every single key, or control-key, will be recorded into that file. Note that if you happen to use gvim or vim -g (the GUI) you might encounter this bug.
If you want to replay this file you can use :source! (with the exclamation mark) or the -s option from the command line.
On Windows I have set gvimportable.exe -W gvim_directory\last_scriptout as my default editor in my Commander program (FreeCommander). This way I can always remember what I have typed to do something and repeat a sequence of commands on another file. Of course I have another shortcut for opening Vim and playing the scriptout.
Note that the file might be written only when Vim exits, so you have to lose your session to know what you've done.
I have vimx installed, so I can copy in vimx to the x clipboard by using "+y and the like, which works well as long as I can keep the current vimx running.
However, I also love to be able to switch to the current running shell with ctrl-z and be able to paste what I copied from vim into the shell. Does anyone know how to do this, because as soon as I suspend vim with ctr-z the x-clipboard becomes empty, until I put vim into the fg again.
ok,
After about an hour of head bashing this issue, I have decided to use a different approach to do the same thing.
I will detail what I did here for the benefit of those with the same issue.
If you have wxcopy on your system that is enough to get copy/paste support on your system between vim and other apps. If you want to copy from vim, select the text using v or V or whatever method you prefer, then use the command :tee >(wxcopy). This will copy that code into the oldschool X11 cut buffer. This buffer has the added bonus of not requiring the parent application to be running for pasting to work, hence my problem goes away.
I realize it may be hard to get your hands on wxcopy, under fedora the package that provides it is:
WindowMaker
This isn't an answer as much as a push in the right direction, but start here:
:help quoteplus
:help x11-cut-buffer
Specifically the second help text has some interesting notes about suspending vim. It claims to write the buffer into PRIMARY and CUT_BUFFER0 so you can still use middle click after you've suspended. Maybe you've deleted those or a plugin is interfering? Maybe you are running an old version of vim (I'm running 7.2.182).
My suggestion is to disable all plugins you've manually installed and try vanilla vim. If that doesn't work, consider using vim's -V (verbose) flag and see if it will try to put the buffer into PRIMARY or CUT_BUFFER0 before it actually gets suspended.
I don't have vim compiled with X (vimx) so I can't actually test this myself. Hopefully that gets you in the right direction.