I use vim and ZSH. When I open a document, the background seems to not be correct at the end of each lines as you can see here :
I tried with different colorscheme and it do the same thing. It works with bash.
What is the solution?
These visual problems usually occur when Vim cannot fully control the terminal: Basic stuff like screen updates work, but things that are handled differently in different terminals (like setting the background color) do not.
Check and compare the values for $TERM in bash and zsh; it's likely the latter one is wrong. You shouldn't hard-code them in a startup file like ~/.bashrc; instead, this variable should be set by your terminal emulator(s). This way, you can also work when you connect remotely via a different terminal emulator (e.g. PuTTY on Windows).
Related
I've been trying to get my head around how terminal control codes/colors work, and as part of that I'm setting up bash scripts to have all my color schemes working correctly on all the machines I use, plus when ssh-ing into any of them. I noticed something funny about running colortest-16 over ssh:
At my work machine, I run colortest-16 and get this output:
I'm using Windows Terminal as my terminal emulator, and I don't actually have a bold font turned on for it, but plain bold text (\e[0;1m) comes out black in any case, as per the left column.
However, if I ssh into my home machine and run colortest-16 in the remote shell, I get this:
Plain bold text (\e[0;1m) seem to be bright white: if you zoom into the left column of the image you can just barely see the bold text, and colorpicking on a screenshot confirms it is a different color from the background, which is off-white. Reverse doesn't work correctly. Underline doesn't work, although interestingly, if I run the color test again, underline does start working (but still not reverse or bold).
I have verified that $TERM is the same on both machines (xterm-256color). Note that I'm running both of these in a local tmux session (no tmux on the server when ssh-ing in), but I get the same results even without tmux.
If I run colortest-16 | vim - locally and over ssh, I can see that the exact same terminal codes are being output in both cases. If I run ssh user#home-machine colortest-16, I get working output from the remote machine. Does this seems to suggest that the remote shell is somehow messing up the escape sequences? What other reasons would there be for this output to be different? Would the output from stty be helpful here?
Further notes: ssh -t user#home-machine colortest-16 does cause issues, so it seems like the pty allocation is somehow contributing to the issue.
Setting TERM has no effect on the script (it is hard-coded). What does have an effect is the actual terminal used to display the results. Some terminals (such as xterm) render bold colors as bright colors. Some (such as Windows Terminal) reportedly do not.
(This colortest-16 manual page appears to refer to some reuse of a script named 16colors.sh from xterm's sources).
Turns out it was this bug in the pty in the Win32 OpenSSH server component.
Recently after updating my VS Code I saw the following image in the Release Notes (in the Split terminal feature section)
I can't figure out a way to add such Syntax Highlighting in my terminal. Obviously, this is bash in the integrated terminal. Well, I'm using Command prompt and I don't seem to find any satisfying answer for getting colored text on my terminal (that does not mean just foreground or background color). Mine looks like...
Is there a way to fill this dull terminal with interesting text colors.
The upper one is the output of something called "node"
the second one is your terminal
so the first one is an outputstream of e.g. an program which formats stuff a bit else, also is output of an program in a terminal displayed differently than just the shell
and now to your question, the shell inside vscode has the same theme like your standard shell
so windows -> cmd, ubuntu bash, ...
I have been trying to set the title of my Terminal appropriately, but I haven't had any success. Currently, it looks like this, and if I were to change directory, to say the desktop, it would become this.
I would prefer if the title only had the current folder and process. I've tried various methods, such as here, but to no success.
I'm using the default Terminal app in Yosemite, and am running zsh.
If you don't want anything in the window title other than the current directory and process (which is there by default in Terminal.app), you can do the following at the end of your ~/.zshrc:
precmd () {print -Pn "\e]0;\a"}
Example:
I'm afraid you can't get rid of that terminal size though since it appears to be hard-coded into Terminal.app (maybe I'm wrong).
For more information, see How to change the title of an xterm: Examples for different shells.
By the way, I recommend iTerm2 instead of Terminal.app. The Swiss army knife of terminal emulators, infinitely better then Terminal.app, highly customizable.
I searched some old answers on stackoverflow, some of them seem relevant, but none of the solutions work on my macbook (with mountain lion). e.g. The shortcuts mentioned in answers here do not work on my computer: How do I run a terminal inside of Vim?
So I'm wondering if it's because vim on mac/unix is different from a normal linux one. I don't think so, but I'm not sure.
Since I can split the screen with :sp, I'm wondering if it's possible to use one split as terminal and another as the regular vim editor, just like emacs. If so, what's the correct way to do it? (Maybe particularly for mac) If not, it's sad.
Why don't you do things the other way around?
You can use a terminal multiplexer such as Tmux and split a terminal window into two panes using C-b %.
Inside the second pane you can run macvim inside a terminal with $ mvim -v
You can navigate between the two panes with C-b o, (And do much more, but I'll leave it up to you to discover!)
Doing things this way around is much more sane in my opinion, you get the full power of both the terminal and vim without having to hack around with Vim too much (Plus Tmux is very handy for many other uses).
I hope doing things this way around is appealing enough for you!
Having a terminal inside of vim would go against the author's philosophy and design so no: that feature will probably never appear nativelyly in vim.
There are a couple of plugins that more or less work like conqueterm, try them if you really want that feature. Or simply use a separate terminal window like everybody.
You should definitely look at programs like tmux or screen.
But an even simpler solution is to use C-z (which halt vim) to access the terminal and fg to bring back vim into the foreground.
I want to be able to use Option-left and Option-right to skip words (and Cmd-left/right to go to beginning and end of lines) within Vim as it does at my shell prompt. My Iterm2 preferences have mappings to do this (e.g. Option-left to Esc-H and a one for option-right to Esc-F to skip over words), and this works in the shell locally or when ssh'd to a remote server.
When I use Vim locally or remotely, option-left works, but option-right does not. I suspect this is because Vim naturally listens for Esc-H, but not Esc-F. I am able to get around this by modifying .vimrc file to Esc-b to b and Esc-f to f, but I don't want to do this to every server I'm connecting to.
Similarly, I have the same desired setup for Cmd-left/right for going to beginning and end of a line. I can get this working in the shell via Iterm2 mappings (e.g. Cmd-left to Esc-[h), but Vim doesn't respond at all to this unless I map keys again (e.g. Esc-[h to ^).
Update: I just figured out how to get option-left/right working. I changed mapping in iTerm2 for these to be escape-[1;5D and escape-[1;5C respectively. I still want to solve the Cmd-left/right problem though (I changed my question's title to reflect this). Any ideas?
To mimic OS X's behavior of sending Cmd-left/right to the beginning/end of a line, I add the following mappings in iTerm2:
Cmd-left to escape-sequence [1~
Cmd-right to escape-sequence [4~
To mimic OS X's behavior of sending Option-left/right to the previous/next word, I add the following mappings in iTerm2:
Option-left to escape-sequence [1;5D
Option-right to escape-sequence [1;5C
Special thanks to this blog post for tracking down what I was missing with the cmd-left/right mappings
I'm using iTerm2 3.4.2 and there's actually a preset that you can select for your profile that enables this.
FWIW, dolan's answer didn't work for me on iTerm 2 1.0.0.20120203 on Mac OS X 10.7.3. His solution only inserted ~ and 5D/5C into my terminal when I pressed the shortcut keys.
Instead, I used the following solutions:
Cmd-left/right:
iTerm 2: How to set keyboard shortcuts to jump to beginning/end of line?
Option-left/right as well as option-delete:
http://hackaddict.blogspot.co.at/2007/07/skip-to-next-or-previous-word-in-iterm.html
YMMV, not sure why one set of solutions would work and not the other
I don't have MacOS, so I cannot exactly know your situation, but I recognize the problem from other OSes.
Basically, it would mean that the terminal sends keycodes that aren't understood by vim. I fixed it in the past by doing
TERM=something
export TERM
before invoking vim
E.g. in order to get all keys and syntax highlighting working on AIX 5.3 across Putty/screen, I needed to use
TERM=iris-ansi vim
There is a list of builtin terminal types if you pass a bad TERM