vim in Terminal.app (Basic profile) and Alacritty.app (no config) feels different.
.vimrc content is one statement: colorscheme blue (default colo).
Both are launched under bash shell without .bashrc.
Diff of envs:
< ALACRITTY_LOG=/var/folders/m6/r1vhznpx5flg71m10r0km5dw0000gp/T/Alacritty-96871.log
< ALACRITTY_SOCKET=/var/folders/m6/r1vhznpx5flg71m10r0km5dw0000gp/T/Alacritty-96871.sock
< COLORTERM=truecolor # unset COLORTERM (not helped)
< COMMAND_MODE=unix2003
10c6
< SHELL=/bin/bash
---
> SHELL=/bin/zsh # Terminal.app var, however use in profile /bin/bash --login [echo $0 -bash] (export SHELL=/bin/bash not helped)
13a10,12
> TERM_PROGRAM=Apple_Terminal
> TERM_PROGRAM_VERSION=440
> TERM_SESSION_ID=6F135ED6-6CD8-4C02-947D-FB0967EEBA1C
19,20c18
< __CFBundleIdentifier=io.alacritty
< __CF_USER_TEXT_ENCODING=0x1F6:0x0:0x0
---
> __CFBundleIdentifier=com.apple.Terminal
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Feb 28 2021 06:52:20) macOS version
What settings/env.variables/<smth_i_miss> influence on vim presentation (particularly why Alacritty gives mono-color behind the text while Terminal shows weird filling)?
Related
I use extdiff in my ~/.hgrc...
[extensions]
pager =
hgext.extdiff =
[extdiff]
# add new command that runs GNU diff(1) in 'side-by-side' mode
cmd.sdiff = sh
opts.sdiff = -c 'diff -dbB --left-column -y -W `tput cols` $0 $1'
[pager]
pager = LESS='FRX' less
attend = cat, diff, sdiff, glog, log, incoming, outgoing, lg, show, lga
This means I can use hg sdiff README and use diff in side-by-side mode for the README file; however, for some reason, the output of tput cols above still gives the shell 80 characters when I run it through hg sdiff.
If I remove sdiff from the [pager] extension, my sdiff spans the full terminal width...
[pager]
pager = LESS='FRX' less
## Removing sdiff fixes the problem with terminal width
attend = cat, diff, glog, log, incoming, outgoing, lg, show, lga
Even if I remove sdiff from the [pager] section and manually pipe through less as hg sdiff | less -FRX, the diff still spans a full terminal width. How can I get [extdiff] and [pager] to allow dynamic terminal width for side-by-side diffs?
The only workaround I have found is
[extdiff]
# add new command that runs GNU diff(1) in 'side-by-side' mode
cmd.sdiff = sh
opts.sdiff = -c 'diff -dbB --left-column -y -W `tput cols` $0 $1 | less -FRX'
I also remove sdiff from the [pager] section. This looks like a Mercurial bug at this point.
I am using Cygwin in Console2 with the following PS1
export PS1='\[\e]2;\w\a\e[1;32m\e[40m\n\w\n\d - \# > \[\e[0;00m\]'
The prompt has the correct text content, but all the colors are ignored.
~/wd
Tue Mar 18 - 01:14 PM >
Screenshot showing Console2:
When I use mintty, the colours are perfect.
TERM is set the same in both Console2 and mintty:
Tue Mar 18 - 06:29 PM > env | grep TERM
TERM=cygwin
TERMCAP=SC|screen|VT 100/ANSI X3.64 virtual terminal:\
You have not show your screenshots. So I'm not sure what do you meaning.
But I believe it is cygwin feature (bug). It thinks that ANSI is not available in Windows terminal (that is true for Console2, but of course not if you are using ANSICON or ConEmu). That means that cygwin process all ANSI sequences internally (it does not send them to the terminal). So, if any problems happens, that all is cygwin implementation problems.
I'm experiencing a very sluggish startup time with vim as well as other unrelated programs ever since I logged out and logged back in the last time. Following is the startuptime log for vim:
> times in msec clock self+sourced self: sourced script clock
> elapsed: other lines
>
> 000.005 000.005: --- VIM STARTING ---
> 000.073 000.068: Allocated generic buffers
> 000.168 000.095: locale set
> 000.180 000.012: GUI prepared
> 000.181 000.001: clipboard setup
> 000.188 000.007: window checked
> 000.621 000.433: inits 1
> 000.626 000.005: parsing arguments
> 000.627 000.001: expanding arguments
> 000.637 000.010: shell init
> 000.909 000.272: Termcap init
> 000.942 000.033: inits 2
> 001.031 000.089: init highlight
> 023.418 000.234 000.234: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/syntax/syncolor.vim
> 023.543 001.811 001.577: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/syntax/synload.vim
> 044.397 015.231 015.231: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/filetype.vim
> 044.449 025.111 008.069: sourcing /grid/common/pkgs/vim/latest/share/vim/vim73/syntax/syntax.vim
> 052.532 000.199 000.199: sourcing /grid/common/pkgsData/vim-v7.3/Linux/RHEL4.0-2007-x86_64/share/vim/vim73/syntax/nosyntax.vim
> 059.858 000.175 000.175: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/syntax/syncolor.vim
> 059.966 003.842 003.667: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/syntax/synload.vim
> 060.002 010.259 006.218: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/syntax/syntax.vim
> 069.085 000.178 000.178: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/syntax/syncolor.vim
> 072.326 000.173 000.173: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/syntax/syncolor.vim
> 076.317 000.175 000.175: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/syntax/syncolor.vim
> 076.477 013.311 012.785: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/colors/desert.vim
> 079.768 000.019 000.019: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/filetype.vim
> 080.322 065.921 017.221: sourcing $HOME/.vimrc
> 080.330 013.378: sourcing vimrc file(s)
> 106.526 000.376 000.376: sourcing /home/haitham/.vim/plugin/genutils.vim
> 111.139 001.435 001.435: sourcing /home/haitham/.vim/plugin/multiselect.vim
> 113.534 000.147 000.147: sourcing /home/haitham/.vim/plugin/omap-param.vim
> 119.245 000.073 000.073: sourcing /home/haitham/.vim/plugin/qfixtoggle.vim
> 122.821 000.696 000.696: sourcing /home/haitham/.vim/plugin/surround.vim
> 172.247 000.098 000.098: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/getscriptPlugin.vim
> 176.387 000.252 000.252: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/gzip.vim
> 179.876 000.183 000.183: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/matchparen.vim
> 182.748 000.620 000.620: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/netrwPlugin.vim
> 186.171 000.051 000.051: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/rrhelper.vim
> 189.739 000.046 000.046: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/spellfile.vim
> 193.406 000.195 000.195: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/tarPlugin.vim
> 199.206 000.060 000.060: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/tohtml.vim
> 202.299 000.152 000.152: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/vimballPlugin.vim
> 205.345 000.147 000.147: sourcing /grid/common/pkgs/vim/v7.3/share/vim/vim73/plugin/zipPlugin.vim
> 205.394 120.533: loading plugins
> 12343.581 12138.187: inits 3
> 12349.592 006.011: reading viminfo
> 18421.239 6071.647: setup clipboard
> 18421.264 000.025: setting raw mode
> 18421.270 000.006: start termcap
> 18421.293 000.023: clearing screen
> 18421.504 000.211: opening buffers
> 18421.564 000.060: BufEnter autocommands
> 18421.566 000.002: editing files in windows
> 18425.833 004.267: VimEnter autocommands
> 18425.835 000.002: before starting main loop
> 18426.587 000.752: first screen update
> 18428.334 001.747: --- VIM STARTED ---
Apparently the biggest components are "inits 3" and "setup clipboard".
Any clues what to do about it?
setup clipboard
First, try running Vim with the following command:
$ vim -X
You can try using the -X --startuptime <file> options together to see if the "setup clipboard" component is still slow.
If -X helps, you can get the same effect by adding the following line to your vimrc file:
set clipboard=exclude:.*
Explanation
If this helps what is happening is that on startup Vim is trying to connect to an X server to allow it to use the clipboard. The -X option tells Vim to not try connecting to the X server. From :help -X
-X Do not try connecting to the X server to get the current
window title and copy/paste using the X clipboard. This
avoids a long startup time when running Vim in a terminal
emulator and the connection to the X server is slow.
See --startuptime to find out if affects you.
Only makes a difference on Unix or VMS, when compiled with the
+X11 feature. Otherwise it's ignored.
To disable the connection only for specific terminals, see the
'clipboard' option.
When the X11 Session Management Protocol (XSMP) handler has
been built in, the -X option also disables that connection as
it, too, may have undesirable delays.
The clipboard option can be used to achieve the same thing more permanently via your vimrc file. From :help 'clipboard'
To never connect to the X server use:
exclude:.*
This has the same effect as using the -X argument.
Note that when there is no connection to the X server
the window title won't be restored and the clipboard
cannot be accessed.
The clipboard=exclude:.* option can be refined to only work with particular terminals, if you want Vim to connect to the X server in some instances. Check out :help 'clipboard' for more on this.
For me, this problem was happening because I had "X11 Forwarding" enabled on my ssh client but did not always have an X Server running on the ssh client machine.
When I have an X server running on the target machine, Vim is much faster starting up (though still a bit slow).
In this setup, I want to maintain the X11 Forwarding, but do not need Vim to use the X clipboard, so I added the set clipboard=exclude:.* line to my vimrc. Now Vim startup is quick for me once more.
inits 3
You seem to have already eliminated your plugins/customisations as a possible cause by trying vim -u NONE (and you said your vimrc was empty).
I am not familiar with this issue, but as suggested above, it might be to do with your viminfo file.
You can determine whether this is the case by starting Vim with the following command:
$ vim -i NONE
According to :help slow-start:
If you have "viminfo" enabled, the loading of the viminfo file may take a
while. You can find out if this is the problem by disabling viminfo for a
moment (use the Vim argument "-i NONE"). Try reducing the number of
lines stored in a register with ":set viminfo='20,<50,s10".
I'm using v7.4. The -X option increase the startup time successfuly when vim compiled with +clipboard. But, since the connection to the X now disabled, we can't copy and paste from x clipboard anymore.
Meanwhile, vim is my only way to write before send it to email, twitter, telegram, etc. So copy+paste from vim is a must. Just found the simple solution :
alias v='nvim'
Nvim use my old .vimrc automatically. clipboard feature work seamlessly without any configuration hassle.
Not provoking to using nvim. I just found it the shortest solution to my problem now.
[using MacVim 7.3 on OS X Lion]
I have a vimscript function which runs an external command. It's executing correctly, but the output displays (unwanted) control characters, such as [0m, [33m, [36m, and -1H. The relevant line in the vimscript function is:
exec ":!bundle exec rspec --color " . a:filename
Which produces:
:!bundle exec rspec --color spec/acceptance/user_logs_in.feature
[33m*[0m
Pending:
[33m User logs in [0m
[36m # the step 'the user "foo#test.host" exists' is not implemented[0m
[36m # [0m
Finished in 0.07121 seconds
[33m1 example, 0 failures, 1 pending[0m
Here's what the same command and output look like from the terminal, which is how I want it to display in vim:
$ bundle exec rspec --color spec/acceptance/user_logs_in.feature
*
Pending:
User logs in
# the step 'the user "foo#test.host" exists' is not implemented
#
Finished in 0.1161 seconds
1 example, 0 failures, 1 pending
Also, any time I execute and external command, vim displays -1H immediately after it. For example, if I type:
:ls<return>
I see:
:ls-1H
<rest of the output is as expected>
Any ideas on hiding those control characters and -1H.
(disclaimer: I'm very new to vim so please don't assume too much background knowledge on my part.)
Thanks.
Update 3/31/2012 # 17:32 PM
Sam Goldman's correct: MacVim doesn't know how to display colors, so it outputs the color codes.
I've switched to terminal vim (which supports colors, at least with iTerm), but using the version of vim that comes with MacVim, which is more up-to-date and is compiled with ruby support (among other things). The easiest way to do that is:
brew install macvim --override-system-vim
MacVim doesn't know how to display colors. Terminal vim will display the colors correctly, or you can add --no-color to your rspec command (or a .rspec file). I'm not sure about the -1H thing. Maybe some customization you have for your terminal?
I would like to have a if-else loop in .screenrc for the following codes such that it is run if my terminal supports 256 colors. Otherwise, it is not run.
attrcolor b ".I"
# tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm "Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm"
termcapinfo xterm-color "Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm"
How can you make the if-else loop in .screenrc?
This should already be set by the terminfo database file. In my case my default terminal is xterm. It uses 8 colors which is reflected in vi by using the
:set termcap
command an inspecting the t_Co item which is set to 8. If I change my terminal to another terminal type like gnome-256color which uses 256 colors then vi will show t_Co as equal to 256. I'm not sure why you need to try and set this in your .vimrc file.
I believe something like this should work if you have bash available:
#!/bin/bash
if [ "$TERM" = "xterm-256color" ]; then
# do stuff for 256
else
if [ "$TERM" = "xterm" ]; then
# do stuff for 16
else
# do something else entirely
fi
fi
My pseudo-code attempt for .screenrc
[ -e t_Co(256) ] . ColorFile
The same in English
If 256 color support, then source ColorFile.