I would like to ask for your help regarding the setting up of the VI environment under Windows 10. I successfully downloaded VIm for windows (vim82 on the official website). I want to modify the color scheme. I downloaded a scheme from: https://vimcolors.com/ (let's say for example the scheme "nebula" which is located on page 4 between results 31 and 40 on the vimcolors webpage) and put it in the "colors" subdirectory of the main vim directory: C:\Program Files (x86)\Vim\vim82\colors.
Then I edit the "_vimrc" file located at: C:\Program Files (x86)\Vim_vimrc and simply add the line:
colorscheme nebula
The complete _vimrc file then looks like:
" Vim with all enhancements
source $VIMRUNTIME/vimrc_example.vim
" Use the internal diff if available.
" Otherwise use the special 'diffexpr' for Windows.
if &diffopt !~# 'internal'
set diffexpr=MyDiff()
endif
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg1 = substitute(arg1, '!', '\!', 'g')
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg2 = substitute(arg2, '!', '\!', 'g')
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let arg3 = substitute(arg3, '!', '\!', 'g')
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
if empty(&shellxquote)
let l:shxq_sav = ''
set shellxquote&
endif
let cmd = '"' . $VIMRUNTIME . '\diff"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
let cmd = substitute(cmd, '!', '\!', 'g')
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
if exists('l:shxq_sav')
let &shellxquote=l:shxq_sav
endif
endfunction
" PERSONAL ENVIRONMENT "
colorscheme nebula
and when I open a text file with VI then this is the message I get - pardon my french - (and the default colorscheme gets loaded up):
Erreur détectée en traitant C:\Program Files (x86)\Vim\vim82\colors\nebula
.vim :
ligne 6 :
E477: Le ! n'est pas autorisé: <!DOCTYPE html>
ligne 7 :
E488: Caractères surnuméraires: <html lang=
ligne 8 :
E488: Caractères surnuméraires: <head>
ligne 9 :
E488: Caractères surnuméraires: <meta charset=
ligne 10 :
E488: Caractères surnuméraires: <link rel=
ligne 11 :
E488: Caractères surnuméraires: <link rel=
ligne 12 :
E488: Caractères surnuméraires: <link rel=
ligne 13 :
E488: Caractères surnuméraires: <link rel=
ligne 14 :
E488: Caractères surnuméraires: <link rel=
ligne 15 :
E488: Caractères surnuméraires: <link rel=
ligne 16 :
E488: Caractères surnuméraires: <link rel=
ligne 20 :
E488: Caractères surnuméraires: <link crossorigin=
ligne 21 :
E488: Caractères surnuméraires: <link crossorigin=
ligne 22 :
E488: Caractères surnuméraires: <link crossorigin=
ligne 29 :
E488: Caractères surnuméraires: <meta name=
ligne 31 :
E488: Caractères surnuméraires: <title>vim-nebula/nebula.vim at master
· stillwwater/vim-nebula · GitHub</title>
And it goes like that for almost every line... VI does find the color scheme file as you can see at the beginning of the error message because the path is correct. I did not do any modifications in the colorscheme file. Does anyone have any idea ? Thanks a lot for your help.
Regards,
Ronan.
The problem is solved thanks to Light. On the webpage of the selected colorscheme, I was simply right-clicking on the nebula.vim presented under the colors sub-directory and selecting "save as..." and yes, I was saving not the file itself but the github webpage... in case that happens to someone else (even though I think I would be the only one stupid enough to do that), you should open the colorscheme.vim that you want, select all, copy, and paste under a filename of the same name in your local vim/colors/ directory.
Apologies...
And thanks for the help.
Regards.
Related
I've searched high and low but cannot get the correct syntax etc. I'd like to set my vim_rc file so I'm using the evening theme and 16pt Lucida console text as a default. I've tried many combinations and I am not having much joy on the web. At present, I'm receiving the following error:
Error detected while processing C:\Program Files
(x86)\Vim\_vimrc:
line 47:
E518: Unknown option: Console\ 14
and my vim file (based on web advice) looks like the following
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
if empty(&shellxquote)
let l:shxq_sav = ''
set shellxquote&
endif
let cmd = '"' . $VIMRUNTIME . '\diff"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
let cmd = substitute(cmd, '!', '\!', 'g')
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
if exists('l:shxq_sav')
let &shellxquote=l:shxq_sav
endif
endfunction
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent
set textwidth=80
set guifont=Lucida Console\ 14
You have to escape spaces with a backslash. You've already done so for the space after "Console". You just need to also escape the one before "Console".
set guifont=Lucida\ Console\ 14
in _vimrc file:
set guifont=Lucida_Console:h14
TDLR; I am unable to edit gvim using the _vimrc file
Basically, I want to change some default settings (like background color) in the GUI version of vim (gvim). However, when I make changes to my .vimrc file, my gvim does not react to the changes.
I already have
if has("gui_number")
set number
colorscheme desert
endif
in my .vimrc file, and from what I've read that should make changes in my GVIM, but it doesn't.
I even tried to type some random stuff in the .vimrc file to see if GVIM would display an error, which it did not.
So i think the problem may be my gvim isn't reading my .vimrc file at all. So this may be a pathing problem?
This below is my .vimrc file
source $VIMRUNTIME/vimrc_example.vim
jhgfjhgjhg (This here was to test for an error)
if has('gui_running')
set number
colorscheme desert
endif
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg1 = substitute(arg1, '!', '\!', 'g')
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg2 = substitute(arg2, '!', '\!', 'g')
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let arg3 = substitute(arg3, '!', '\!', 'g')
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
if empty(&shellxquote)
let l:shxq_sav = ''
set shellxquote&
endif
let cmd = '"' . $VIMRUNTIME . '\diff"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
let cmd = substitute(cmd, '!', '\!', 'g')
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
if exists('l:shxq_sav')
let &shellxquote=l:shxq_sav
endif
endfunction
Here is my .GVIMRC file
version 6.0
if &cp | set nocp | endif
let s:cpo_save=&cpo
set cpo&vim
map! <S-Insert> *
vmap "*d
map Q gq
vmap [% [%m'gv``
vmap ]% ]%m'gv``
vmap a% [%v]%
vmap gx <Plug>NetrwBrowseXVis
nmap gx <Plug>NetrwBrowseX
vnoremap <silent> <Plug>NetrwBrowseXVis :call netrw#BrowseXVis()
nnoremap <silent> <Plug>NetrwBrowseX :call netrw#BrowseX(expand((exists("g:netrw_gx")? g:netrw_gx : '<cfile>')),netrw#CheckIfRemote())
vmap <C-Del> "*d
vmap <S-Del> "*d
vmap <C-Insert> "*y
vmap <S-Insert> "-d"*P
nmap <S-Insert> "*P
inoremap u
let &cpo=s:cpo_save
unlet s:cpo_save
set backspace=indent,eol,start
set backup
set diffexpr=MyDiff()
set display=truncate
set guioptions=egmrLT
set helplang=En
set history=200
set hlsearch
set incsearch
set langnoremap
set nolangremap
set nrformats=bin,hex
set ruler
set runtimepath=~/vimfiles,C:\\Program\ Files\ (x86)\\Vim/vimfiles,C:\\Program\ Files\ (x86)\\Vim\\vim81,C:\\Program\ Files\ (x86)\\Vim\\vim81\\pack\\dist\\opt\\matchit,C:\\Program\ Files\ (x86)\\Vim/vimfiles/after,~/vimfiles/after
set scrolloff=5
set ttimeout
set ttimeoutlen=100
set undofile
set wildmenu
" vim: set ft=vim :
I would hope that my gvim would display lines and a different background, but nothing happens.
edit: should my _vimrc file look exactly like my gvimrc?
I figured it out guys.
So apparently I was supposed to create a _vimrc file in my home directory.
If you are on windows 7 and having the problem where you cant edit your _vimrc file in your VIM directory to change gvimrc, then its because you are trying to edit the wrong _vimrc!! You need to make a different user one in your home directory!
Windows 7:
Open vim, type in :e $HOME/_vimrc
And then put the new settings and save (then reopen GVIM)
I have an annoying problem with vim which I have googled to death to no avail. I would like vim to stop scrolling right when I am typing in insert mode. I do not have this problem when I enlarge the vim window, but I would like to keep the window small and compact for my own purposes.
Thanks in advance!
Edit:
As requested by merlin2011 here is the contents of my .vimrc file.
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let cmd = '""' . $VIMRUNTIME . '\diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction
I had this issue as well and I think I managed to fix it, but it wasn't a vim issue. Could you try right clicking on your cmd prmpt window, go into properties and make sure this has been checked? When I checked that box vim stopped locking onto my cursor and scrolling sideways when I typed. Let me know if that works.
I just installed VIM and a few plugins, one of which is vim fireplace. A problem I have is that fireplace can't find my clojure code. I put my clojure code under vimfiles/bundle (I'm running windows).
I followed these instructions:
http://kevinmccarthy.org/blog/2013/10/12/setting-up-vim-for-clojure/
When I run a sample clojure function in the command line (which I get to using cqc), I get the following error:
Error detected while processing function <SNR>20_inputeval... foreplay#echo_session_eval..foreplay#session_eval...<SNR>20_eval...6:
line 38
E605: Exception not caught: Error running clojure:Error:Could not find or load main class clojure.main^#
Error detected while processing function <SNR>20_inputeval:
line 4
E71:missing :endif
Here is my .vimrc:
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
syntax on
filetype plugin indent on
execute pathogen#infect()
set nobackup
set nowritebackup
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let cmd = '""' . $VIMRUNTIME . '\diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction
fireplace is not able to set classpath which may be because you are not working with a lein project. But that is not a requirement, you can always connect to a running nrepl ( which can be launched via lein repl) and connect to it from vim using :Connect nrepl://localhost:port.
Let's say I have these two blocks:
1
23
456
hello..
world world
codecode
And then I need this block (between 1 and hello.., without any spaces between):
1hello..
23world world
456codecode
What is the best fast way?
I used gvim7.3.46 on windows xp and windows 7
this is my _vimrc
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let cmd = '""' . $VIMRUNTIME . '\diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction
I used C-r", but that did not work.
1
23
456
hello..
world world
codecode
I used C-q, y, C-p, the result is:
1
23
456
1 hello..
23 world world
456codecode
Place the cursor on 1.
Hit <C-v> to enter visual-block mode.
Move the cursor down to 456 and hit $ to select the whole block.
Hit y to yank that block.
Place the cursor on the h in hello.
Hit P.
I would use visual block mode. Do like this:
At the start of the first block, press <C-v> to enter visual block mode.
Select the relevant lines, and press $ to extend the selection to the end of the line.
Press d to delete the first block. This will also copy it.
Then press P at the beginning of the second block to paste the first block before the second block with no spaces in between.
The first line range will then be empty, so you will have to delete those lines if you don't want them.
Using a recursive macro to jump back and forth between to two blocks, deleting and joining lines:
qq}jdd''pkgJj#qq
Notable keystrokes:
'' jumps back to the line where you jumped from the most recently
#q calls the macro q from inside the definition of q
gJ joins two lines without a space between them