I'm trying to render strikethrough for markdown files in terminal vim. However, with the current plug-ins and colorscheme it either colors the text or underlines it. I'm nit-picky and I'd like the rendering of strikethrough.
Running :so $VIMRUNTIME/syntax/hitest.vim in a markdown file rightly shows the highlights including the underline/coloring, but also the groupname which is htmlStrike.
So I try adding the following to my init.vim(having read :h attr-list):
function s:ApplyStrikethrough()
highlight htmlStrike cterm=strikethrough
endfunction
autocmd FileType md call s:ApplyStrikethrough()
I've also tried the above without the autocmd, e.g. just highlight htmlStrike cterm=strikethrough. I've also tried highlight htmlStrike gui=strikethrough guisp='Red'. All I can accomplish is having no highlight at all...
I know my terminal (Kitty) is capable of rendering strikethrough, having run echo -e "\e[9mstrikethrough\e[0m".
OS: Manjaro Linux x86_64
WM: i3
shell: zsh 5.7.1
Vim: NVIM v0.4.3
Term: kitty 0.15.1
Any help is greatly appreciated, thank you!
I just ran into the same problem, and found a solution for normal vim after a while of researching.
I have put the following in my .vimrc
if &term =~ 'xterm\|kitty\|alacritty\|tmux'
let &t_Ts = "\e[9m" " Strikethrough
let &t_Te = "\e[29m"
let &t_Cs = "\e[4:3m" " Undercurl
let &t_Ce = "\e[4:0m"
endif
This will enable strikethrough and undercurl for xterm, kitty, alacritty and tmux terminals (identified by the TERM environment variable). Ideally the if-test should perhaps rely on the smxx, rmxx (standard) and So (kitty extension) capabilities from the terminfo database, but I don't know how to query it from a vim script.
This can be tested by for instance formatting the status line, or with the highlight group htmlStrike as in the question.
:hi StatusLine cterm=strikethrough`.
The trick for undercurl is mentioned in :help undercurl. :help terminal-output-codes lists the terminal codes vim knows about, which also reveals strikethrough. Note that the escape code for strikethrough is defined in ECMA-48 (called "Crossed-out"), while undercurl is defined by Kitty in its protocol extensions.
A quick note on neovim: For me, strikethrough worked out of the box with neovim, but undercurl fell back to normal underline. I have not investigated this beyond noting that neovim does not have the terminal-output-codes help topic.
Related
I want to change my colorscheme to this: earthsong on http://daylerees.github.io/
but it changes color something srange. like this (up: molokai, down: earthsong)
I try :colorscheme earthsong in vim, it gives same result.
I using vim on mac (latest version)
I got .vim code from https://github.com/daylerees/colour-schemes/blob/master/vim/colors/earthsong.vim
Can I get some help?
The very first place to look for help with an open source project is its issue tracker if it exists.
That colorscheme only uses your terminal palette. This means that you must adjust it to the colors used in the colorscheme which don't seem to be listed anywhere else than in the colorscheme itself.
If you use Vim 8 and an up-to-date iTerm you could tell Vim to use your GUI colors in the terminal with:
set termguicolors
System = OSX 10.9.4
I am trying to turn on syntax highlighting in vim while using the terminal. However, I am unable to get it to work properly.
Things I've tried:
located the vimrc file and added the following code:
set ai " auto indenting
set history=100 " keep 100 lines of history
set ruler " show the cursor position
syntax on " syntax highlighting
set hlsearch " highlight the last searched term
filetype plugin on " use the file type plugins
Located vimrc under directory:
cd /usr/share/vim/
The interesting thing is that once I add the code to the vimrc using vim, followed by exiting (x), and re-opening the file again, syntax is correctly highlighted in the vimrc.
However, when I try to make a new vim file called "test", copy the same code, save and exit. Re-open it, the syntax is not highlighted at all.
It appears that syntax highlighting only works when I open the actually vimrc file---and not when I try to create a new one or open another file that should have syntax highlighting.
I've also tried to create a .vimrc (exact copy) under the ~/ (directory). No success.
Made a new file called "test" and tried turning it on while active as well:
vim test
"then within vim"
:syntax on
I am really confused as to why this partially works.
Any help is much appreciated.
Cheers!
p.s. I have followed these instructions as well from: http://geekology.co.za/article/2009/03/how-to-enable-syntax-highlighting-and-other-options-in-vim
*I am aware of macvim, but would like a solution for the native vim in terminal. Thanks.
NEVER do anything in $VIM as it will work only by luck, cause unexpected behaviors and likely be overwritten next time Vim is updated.
What you have put in /usr/share/vim/vimrc should be in ~/.vimrc.
filetype on and syntax on are the bare minimum you need in your ~/.vimrc for syntax highlighting to work.
$ vim ~/.vimrc gives you syntax highlighting because the file is recognized by Vim as a vim file. Filetype detection is mostly dependent on file extensions so you can't expect any syntax highlighting in a file called test.
$ vim test.py, on the other hand, should give you syntax highlighting.
If the filetype is not detected, you can force it with :set filetype=python.
You most probably want to enable indentation along with syntax highlighting, so add these to lines to ~/.vimrc
filetype plugin indent on
syntax on
Steps with screenshots can be found here
http://osxandiosdaily.com/how-to-enable-vim-syntax-highlighting-on-mac-osx/
Inside of your file, enter command mode and enter the command
:syntax on
I downloaded the Dark.vim color scheme from here:
http://vimcolorschemetest.googlecode.com/svn/html/index-c.html (Click on Dark.vim to see the code)
Then put it in ~/.vim/colors.
I also did the same for 256-jungle.vim and af.vim.
:colorscheme Dark, :colorscheme af, etc. all work (i.e. they change vim's syntax highlighting) but none of them look like the screenshots in the link above.
Instead, they look like this (ordered af.vim, 256-jungle.vim, Dark.vim): http://imgur.com/a/NsmHy
At first I thought this might be a problem with the color-settings in my terminal, so I followed tips from a "256 colors in vim" Vim wiki-doc page, which told me to add the following to my ~/.bash_profile :
TERM=xterm-256color
# for enabling 256 color, as per http://vim.wikia.com/wiki/256_colors_in_vim
if [ -e /usr/share/terminfo/x/xterm-256color ]; then
export TERM='xterm-256color'
else
export TERM='xterm-color'
fi
This didn't work.
Also, here's what's in my ~/.vimrc file:
set tabstop=2
set t_Co=256
colorscheme 256-jungle
colorscheme Dark
syntax on
let $VIM='~/.vim/'
Any thoughts on what's causing this disparity between what the colorschemes "should" look like and what's actually being displayed in my terminal? I'm running Mac OS X 10.8.2.
Thanks in advance for any help.
The Dark colorscheme you tried to use in terminal is actually a scheme for GUI (if you take a look at it's code, you'll see only 'guifg, guibg' etc. definitions). To run gui colorschemes in a terminal you can try CSApprox plugin.
I'm having difficulty getting my colorscheme to change. I've opened both ~/.vimrc and /usr/share/vim/vimrc and added:
colorscheme desert
...and nothing. I noticed the color schemes are here:
/usr/share/vim/vim72/colors/desert.vim (...along with a bunch or others)
which seems like the wrong place so I:
cp /usr/share/vim/vim72/colors/desert.vim ~/.vim/colors/
and still no go.
Try setting your terminal colours in your .bashrc/.bash_profile to:
export TERM=xterm-256color
& in your .vimrc
let g:"your_colourscheme"_termcolors=256
& that should stick. Bit of a kludge I know but it should work.
Saves typing
:colorscheme whatever everytime you start Vim
Custom colorschemes should go in ~/.vim/colors/, and adding the colorscheme line in your ~/.vimrc should work. So it sounds like you're doing that right.
Double-check that you don't have some other colorscheme line lower down in your vimrc or in an included config file that might be overriding it.
Also double-check that your .vimrc is being loaded as expected. One easy way to tell is by trying to load a nonexistant colorscheme name - if the line is being parsed, then you should get an error like:
E185: Cannot find color scheme foobarbaz
If your colorscheme line is being correctly parsed, you need to check if your terminal is correctly configured to display the colors.
The situation with terminals is a mess when it comes to colors and fonts. It is quite probable that your terminal emulator (gnome-terminal? kterm?) and vim aren't using the same encodings for colors, or one is partially overriding the settings of the other. When it comes to the eternal war between console apps and modern colors and font rendering, your three options are:
Side with the old school, switch to xterm or rxvt, where the colors are more likely to just work, but got help you if you want antialiased fonts.
Side with the new school, sidestep the console entirely and use gvim, where fonts and colors will likely both just work.
Get caught in the middle and forever fight with getting fonts and colors to work properly for old console programs running in new terminal emulators, i.e. gnome-terminal, kterm, etc...
apt-get install vim or yum install vim <-- need full vim vs mini vim
ls /usr/share/vim/vim ##/colors <-- ## 72 or 73, etc list color schemes
cd ~
vi .vimrc
# Add the following two lines if the don't exist
syntax on
colorscheme elflord
# replace elfloard with what ever color scheme you like
If you are using vim-tiny in Ubuntu (the default one). Try to install vim-nox, vim-gtk or vim-gnome.
make sure that you are enabling syntax with :syntax enable.
Currently, using Ubuntu and VIM 8, I did this:
Browse to your user directory:
cd ~
Create and open a .vimrc file:
vim .vimrc
Click i for insert mode.
Type the following command below to enable syntax and give a specific colorscheme. This example uses the desert colorscheme:
syntax on
colorscheme desert
Hold Shift and hit : then type wq! to save and quit the file.
You should now be able to use vi and the colorscheme you choose to edit files on your Grid.
Below the default set of colour schemes for Vim 8:
blue
darkblue
delek
desert
elflord
evening
industry
koehler
morning
murphy
pablo
peachpuff
ron
shine
slate
torte
zellner
Our dev team is looking for an IDE like vi or nano or even textpad for windows that has the capability to autocomplete and error correction for bash or shell script for linux. Basically something similar to .NET autocompletion where you will be able to see if an
if[ $# -ne 5 ]; then
has no space between the 5 and the ] will tell you.
I hope this question is simple and easy to answer. I have seen that vi in RHE use some coloring but in CentOS5 it does not shows the different colors. Non of them use error detection or auto-completion.
Like most questions of this sort, the One True Answer is EMACS.
However, TextMate, BBEdit, and SubEthaEdit do nicely too.
In vim, apart from adding syntax highlighting to show incorrect syntax (the "if" example would not highlight the if correctly) you can add this to your .vimrc:
autocmd FileType sh set makeprg=bash\ -n\ '%'
autocmd FileType sh let &efm = "%E%f:\ line\ %l:\ %m," . &efm
Now when you run :make it will check the syntax and jump to errors. Map :make to F5 and syntax checking is just a key press away.
Red Hat splits up the VIM RPM's into vim-minimal, vim-enhanced and then some. You need the vim-enhanced RPM's to do syntax highlighting. As CentOS is nothing more than repackaged RHEL, the same goes for CentOS. And if it has to be for Windows: GVim is readily available.
You could see the syntax highlighting by itself as a form of error detection. If you make an error in parenthesis, curly braces or something, you'll see that you syntax highlighting breaks, showing you that there's something wrong and where it went wrong.
As for the completion: most commands in Bash are really short, but CTRL-N will autocomplete anything in a file you have used before in that file.
You could try Griffon which is an IDE specifically designed for BASH scripting. Its features include autocomplete, syntax highlighting, error detection, and more.