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.
Related
I recently started working with a windows machine and installed gVim, but somehow the escape key does not work - rendering gVim practically useless.
Is it possible that my computer sends out an unusual character for the escape key? Is there any way to test this hypothesis?
Or is it a common Windows (10) issue, that escape does not work as on other devices? Did anyone else encounter this strange behaviour?
I tried on linux4windows terminal and there it had the same result yesterday, but now the escape key works fine.
I know this is an old question, but I've been suffering this and finally found some time to dedicate to it.
The answer seems to be (for me at least), that if you hit Win to open the Start Menu and then type gvim, the first option is actually gVim Easy not gVim.
The difference is 'gVim Easy' starts with the -y switch:
-y Easy mode (like "evim", modeless)
If you launch gVim (as opposed to gVim Easy) then ESC works as expected.
I guess the "modeless" in 'Easy Mode' means there aren't normal (command) or insert modes, so there's no need to use ESC to switch between them.
I had the same issue with gVim 8.0. I updated to 8.1 and left all default settings (no remapping etc..). Now the escape key works again.
Because I use vim (and obviously like it) while working in the command line, I often go through a few keystrokes before I realize I'm not in vim anymore. That's not a huge problem, but when entering a lot of commands on one line, vim-like navigation would really speed things up on the extremely rare occasion cough I make a typo. It would be great it there were a way to make command line typing act at least a little like vim (e.g. Normal mode, Insert mode, movement from the home keys, etc.)
I am open to using a different shell, but would prefer something I can use without learning a ton of new commands (e.g. command line or BASH like). I have else compiled many of my frequent command sequences into .bat files, which I would prefer not to have to change too much to get to work properly.
When using Windows, a good option would be to install Git, which gives you "Git Bash", which is their distribution of mingw.
Now that you have bash, you can use set -o vi which puts your readline in Vim mode.
https://sanctum.geek.nz/arabesque/vi-mode-in-bash/
I'm surprised nobody has mentioned Clink. It works with cmd.exe, and has support for Vim (well, technically, Vi) key mappings. Sadly, the documentation seems unfinished (to say the least); that said, I have found it to be quite stable, and have used it for a few years now. Doing a quick search yields information on how to set the default editing mode to Vi (versus Emacs).
In short Control+Alt+J switches to Vi mode (assuming one is currently in the default Emacs mode), and a standard Readline inputrc in the right place (my file path is %HOMEPATH%\AppData\Local\clink\clink_inputrc), with the right directive (set editing-mode vi) ensures that a new cmd.exe invocation starts off in Vi mode.
I am open to using a different shell, but would prefer something I can use without learning a ton of new commands (e.g. command line or BASH like)
In bash you can enter vi-mode with the command:
set -o vi
This will make shell-editing very similar to Vim-editing. For a cheat-sheet of vim-mode commands see: https://github.com/pkrumins/bash-vi-editing-mode-cheat-sheet/blob/master/bash-vi-editing-mode-cheat-sheet.txt
Numerous sources indicate that running a "bang" command such as :! wc % will display the results in Vim below the editor window. (For instance, this tip sheet states that as the expected behavior.)
Specifically, I'm following along with this Vimcast tutorial on Tim Pope's Fugitive plugin, and in that Drew Neil states that running the :Git command will allow the user to run any arbitrary git command from inside Vim--and the output of the command will be displayed within Vim at the bottom of the screen.
This is not the behavior I am experiencing. Instead my Vim session is in essence sent to the background, and I'm popped back to my terminal to see the output. It's all very disorienting--specifically because I lose the useful visual context provided by my Vim session including the "bang" command that generated the output.
I'd love it if Vim actually did display the externally generated output in Vim below the editor window. I found some similar types of questions, but in all of them the user wanted to output the content to a new buffer rather than just see it momentarily printed at the bottom of the editor window. In other words, I've not found anyone else describing the behavior I'm seeing.
I was able to get the desired behavior in gVim, but gVim isn't always a viable option, so I'd like to know whether there is a broader solution that will allow the expected behavior in terminal-based Vim.
I'm using Vim 8.0 on Ubuntu 16.04. My terminal is gnome-terminal with the zsh shell. I tried some other terminals on my machine and the bash shell, and I'm experiencing this behavior regardless of which combination I use.
Here are two screenshots that demonstrate the behavior I'm seeing. On the left is a terminal-based Vim, and on the right is gVim. Notice how running :! wc % has the expected/desired behavior in gVim on the right, but not in regualar Vim on the left.
Screenshot before running command:
Screenshot after running command:
Is anyone else experiencing this? Does anyone else get the desired behavior from their terminal-based Vim? (Perhaps this is all some kind of documentation oversight and terminal-based Vim was never expected to behave in the desired way?)
Thanks!
It's GVim (or MacVim) that shows the output of external command at the bottom of the window because it comes with a very minimal terminal emulator. Plain Vim is incapable of doing that.
You could emulate that behavior with tmux via any of the many Vim plugins that provide tmux integration or, since you are using Vim 8.0, the new built-in :help :terminal emulator.
For your example:
:term wc %
An alternative that I stumbled across is to use AsyncRun from this plugin. It acts as alternative to the shebang command, runs the command in the background, and sends the output to the quickfix window.
While I still think the accepted answer is the right one (i.e. that a TUI Vim always outputs to the terminal shell instead of the internal shell), someone else coming across this thread might find AsyncRun to be a better alternative to "that's just how it works".
(edit: I am using zsh, if that matters)
I'm pretty baffled right now. Here's the relevant part of my vimrc (I'm using Vundle).
set t_Co=256
set background=dark
colorscheme PaperColor
(the full vimrc if you are curious, it's pretty short)
And here's what vim in Cygwin displays (with all Cygwin's terminal color stuff set to their out-of-box defaults):
If I comment out the t_Co=256, I get this:
Which is better, but not when you consider that the PaperColor theme is supposed to look like what's shown here.
I've read this answer here to a similar question, but that isn't a very good workaround for me -- I don't want to have to change Cygwin's terminal colors manually every time I change a color scheme, and would that even work if my vim uses one set of colors while my zsh uses another? Why can't Cygwin just display all the colors my monitor can -- does it really not have that ability? Or am I just messing something up with my configs? From what I've googled, the amount of information about how Cygwin colors work is surprisingly scarce. I expected hundreds of links with people having the exact same problem, but there's really only a few.
I found my problem.
Long ago when I switched to zsh from bash, I altered my Cygwin launcher .bat file to launch zsh.exe. Doing so opens up a very stripped-down terminal running zsh, but it is NOT the mintty terminal, which Cygwin normally uses (and which supports much more features like better colors).
I just had to switch my Cygwin launcher shortcut to open up the mintty terminal instead (and then login to zsh within Mintty).
I've just added vim to my current Cygwin installation, and it doesn't work properly.
The problem is: when I type vim <Enter> it opens Vim with the help splash screen (in color) - OK.
I then try to exit with :q , and it sleeps a couple of seconds, then it exits but when I type a character at the command line it pre-pends a spurious string (6c6c). Other similar issues when I try to edit a file in vi instead of exiting right away.
I suppose it is a color/TERM issue, but I don't have much experience in that kind of stuff.
Thanks for any help.
What terminal are you launching vim from? I'd suggest using rxvt. This solves many issues with ncurses type programs.
Sometimes people change their TERM variable. Generally, you shouldn't do this, so long as your environment has the correct termcap installed, this isn't needed. If your use rvxt your TERM variable will default to 'rxvt-cygwin-native'.