Every time I use a colorscheme for vim(WSL) from Github it shows some trailing colors normally within the first 10 lines and sometimes for the entire code like in the link. At first, I thought that it was just highlighting the trailing spaces, but even after removing them, it reverts to its original form on changing cursor locations. Pretty new to vim, so please help me.
My .vimrc:
set nocompatible
set clipboard=unnamed
set clipboard=unnamedplus
syntax on
set tabstop=4
set shiftwidth=4
set autoindent
set smartindent
set shortmess+=I
set number
set termguicolors
set relativenumber
set laststatus=2
set backspace=indent,eol,start
set hidden
set ignorecase
set smartcase
set incsearch
nmap Q <Nop> " 'Q' in normal mode enters Ex mode. You almost never want this.
set noerrorbells visualbell t_vb=
set mouse+=a
colorscheme pablo
nnoremap <Left> :echoe "Use h"<CR>
nnoremap <Right> :echoe "Use l"<CR>
nnoremap <Up> :echoe "Use k"<CR>
nnoremap <Down> :echoe "Use j"<CR>
inoremap <Left> <ESC>:echoe "Use h"<CR>
inoremap <Right> <ESC>:echoe "Use l"<CR>
inoremap <Up> <ESC>:echoe "Use k"<CR>
inoremap <Down> <ESC>:echoe "Use j"<CR>
Update: Just found out after messing with stuff that it happens everytime I use ^D or ^U for page up - down. Now it happens even for the inbuilt colors. However does not happen if I use j or k. The only change I did with the .vimrc was adding the set termguicolors.
figured out that all my issues happens because of the termguicolors.
but this is included from every github has that and so all of them show this random colours. is there any way this can be fixed?
So, apparently the problem lies with windows, or the WSL to be precise. WSL does not seem to support the set termguicolors which is responsible for the weird colors appearing on screen. And because this is essential for several colorschemes (otherwise they look very different). So unless WSL2 provides this feature I don't think it is possible for windows to have any of the fancy colorschemes. The best option is to probably use a virtual machine and run linux or dual-boot your device.
Related
I'd like to use gvim to view files with long lines. It's a table, so I'm not wrapping the lines.
Is this possible to configure gvim so arrows navigation will be like in "most" tool? Arrow key will move the whole screen 1 character lef/right/top/bottom?
Thanks a lot.
I think this should do what you want.
set nocompatible
set nowrap
set virtualedit=all
nnoremap <Left> zh
nnoremap <Right> zl
nnoremap <Up> <C-y>
nnoremap <Down> <C-e>
If you want the same behavior in insert mode, add the same mappings again as a second set, but use inoremap instead of nnoremap.
The virtualedit setting will allow the cursor to move beyond the end of the line and continue on as if the line had infinite whitespace to the right.
NOTE: virtualedit is only available if Vim was compiled with that feature. You can check with :version. If this feature is available, you should see a + next to it, e.g. +virtualedit.
I've been trying to take my vim/neovim game to the next level and one of the things I've been trying to do is fix the highlighting issues I've been having. The gist of it is that at times, syntax, visual selection, and search highlighting use the same/similar color for the highlighting as the original text, making it difficult to see what has been highlighted. Does anyone know how i might be able to fix this? based on the first screenshot, it looks like its completely capable of doing so, I just can't seem to find a config option to make it consistent.
Here are some examples (while I was using neovim in these, the behavior is the same w/ vim):
note how the some of the text is almost impossible to read while highlighted? (it was whitish before highlighting) the places highlighted in red/blue are much more how i would have expected highlighting to work all the time (the highlight color more or less matches the original text color, but when highlighted, the text color was changed to make the selection readable).
all occurrences of "if" are highlighted. again, note how the text and highlighting are pretty much indistinguishable.
note how the syntax highlighting (of the [ ] pair in this case) mostly hides what the 2 surrounding characters are. this also happens with (, ), {, and }.
.vimrc (init.vim essentially identical):
syntax enable
:color peachpuff
set nocp
set wildmenu
set relativenumber
set number
set ignorecase
set smartcase
set incsearch
set nowrap
set tabstop=4
set softtabstop=4
set expandtab
set shiftwidth=4
set showcmd
set clipboard=unnamed
set laststatus=2
set clipboard+=unnamedplus
set directory=~/.vim/tmp
"sudo after opening:
cmap w!! w !sudo tee >/dev/null %
"formatting brackets and such:
inoremap {<Tab> {}<Esc>i
inoremap {<CR> {<CR>}<Esc>ko<Tab>
inoremap (<Tab> ()<Esc>i
inoremap (<CR> (<CR>)<Esc>ko<Tab>
inoremap [<Tab> []<Esc>i
inoremap [<CR> [<CR>]<Esc>ko<Tab>
Just try a different colorscheme. This plugin has loads:
https://github.com/flazz/vim-colorschemes
I'd recommend gruvbox, twilight or apprentice, but there are lots of great ones, find one that works for you.
You can install this plugin to be able quickly switch to the next colorscheme:
https://github.com/xolox/vim-colorscheme-switcher
Edit: here is a list of the colorschemes that you probably have installed by default in your vim:
https://github.com/vim/vim/tree/master/runtime/colors
If you want to try some without installing any plugins or anything, just do e.g. :colorscheme evening and see how they look. If you type :colorscheme <CTRL-D> you'll be shown which colorschemes are available.
In vim editor, I want to switch cursorline on and off on demand.
I already have this in my .vimrc:
set nocursorline
noremap <F3> :set cursorline! <CR>
But this only works in normal mode. How to change, so the F3 key works in insert mode too?
I don't want to have cursorline at opening a new file directly, so "set nocursorline" is OK for me.
I'll assume by "edit mode" you mean "insert mode". The trick for running normal mode commands from insert mode is to prefix them vith CTRL-O. Try this:
set nocursorline
nnoremap <F3> :set cursorline!<CR>
inoremap <F3> <C-o>:set cursorline!<CR>
map imap cmap noremap ... all do not solve my problem. Generally I want to use a key mapping definition which works in ex mode and edit mode at once.
When I make a .vimrc entry,
nnoremap <silent> <leader>c :colorscheme <tab>
The tab is applied if I understand the terminalogy, as a literal, that is, upon typing ,c, I get in Vim command line,
:colorscheme ^I
I tried to internet the search terms, but mostly I get results about remapping Vim Tabs; the closest I found was somebody putting quotes around their <tab>, but I think that is for a different desired outcome.
I also have this, which is why I want the tab in my shortcut,
set wildmenu
set wildmode=longest:list,full
You'll need the 'wildcharm' option:
set wildcharm=<C-z>
nnoremap <silent> <leader>c :colorscheme <C-z>
See :help 'wildcharm'.
As a side note, I use that option with great effect for switching buffers:
nnoremap <leader>b :buffer <C-z><S-Tab>
and a file-opening variant would be just as easy and just as useful:
nnoremap <leader>e :edit <C-z><S-Tab>
I have a little problem with mapping vim shortcuts for my mouse wheel. I can't make this work :
set mouse=a
set nowrap
noremap <C-ScrollWheelUp> 3zh
noremap <C-ScrollWheelDown> 3zl
On the other hand, the following is working (but not convenient, i just tested it to see if ScrollWheelUp/Down was working) :
set mouse=a
set nowrap
noremap <ScrollWheelUp> 3zh
noremap <ScrollWheelDown> 3zl
What is my problem ?