This happened when I start the vim in my Macbook:
huzi:~ huzi$ vim
Error detected while processing /usr/share/vim/vim73/syntax/synload.vim:
line 19:
E185: Cannot find color scheme huzi_python
Press ENTER or type command to continue
When in synload.vim, it is:
" Set the default highlighting colors. Use a color scheme if specified.
if exists("colors_name")
exe "colors " . colors_name
else
runtime! syntax/syncolor.vim
endif
You need to put the "huzi_python.vim" into your ".vim" folder into the subfolder "colors".
After that you have to set the following in your ".vimrc":
colorscheme huzi_python
If you want a dark background within the editing area and syntax highlighting you cann add the following:
set background=dark
Related
I am using ipython 5.8.0 on Debian 10
Following screenshot shows the colors of normal command, and a command when my cursor moves to a parenthesis and matching parenthesis are highlighted:
This color scheme is unfortunate. Where can I change this?
You can create ipython profile if not exists and override style
check if ipython_config.py presents under ~/.ipython/profile_default/ if not then you can run this command to create it
ipython profile create
open ipython_config.py file in any editor of your like and uncomment and update this option
from pygments.token import Token
c.TerminalInteractiveShell.highlighting_style_overrides = {
Token.MatchingBrackets.Other : '#FF00FF', # nested brackets color
Token.MatchingBracket.Other : '#FF00FF', # bracket color
Token.MatchingBracket.Cursor : '#4b3588', # on cursor over bracket color
Token.MatchingBrackets.Cursor : '#4b3588', # on cursor over nested matching brackets color
}
For Build in token check here, for Styling info check here
For how i get to know ipython uses pygments for customization check here
You can create ipython profile if not exists and change theme
check if ipython_config.py presents under ~/.ipython/profile_default/ if not then you can run this command to create it
ipython profile create
open ipython_config.py file in any editor of your like and uncomment and update these options as you like
c.InteractiveShell.color_info = True
c.InteractiveShell.colors = 'Linux'
c.TerminalInteractiveShell.highlighting_style = 'monokai'
c.TerminalInteractiveShell.highlight_matching_brackets = True
In your Terminal, click Edit > Profile Preferences > Colors
See the Text and Background Color.
I have a global statusline set, but it would be useful if each split window had the current filename in its own statusline.
OK, the default setting is empty so I added the following setting for stock console vim that seems to play nice with the NERDTree and Syntastic plugins:
" [buffer number] followed by filename:
set statusline=[%n]\ %t
" for Syntastic messages:
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
" show line#:column# on the right hand side
set statusline+=%=%l:%c
I am keeping notes in console vim on my laptop, and
I want to add syntax highlighting to my notes in order
to enhance them. However, I don't want to add a
million different filetypes for every area of knowledge
(for example my notes on compilers would have different
keywords than my notes on the FHS), and I also want to
make it easy to share these notes. After doing some
research, I discovered that I can get the behavior I
want, but it doesn't seem like a very elegant solution.
I added the following lines to my .vimrc:
if (filereadable("./.custom_syntax.vim")
let mysyntaxfile = "./.custom_syntax.vim"
syntax enable
else
syntax enable
endif
I don't really like this solution because it still
requires me to ask them to modify their .vimrc, but I
suspect that there's no way to do this without changing
anything on their system. Additionally, if I have any
files in the directory that aren't notes, vim will still
highlight them with the .custom_syntax.vim file because
I don't know what the filetype is.
Is there any better way to accomlish this?
Instead of using the old mysyntaxfile variable, I'd just :syntax enable (once) and then :source the syntax file. You can define an :autocmd that looks for an eponymous Vimscript file next to the original:
" Automatically source an eponymous <file>.vim or <file>.<ext>.vim if it exists, as a bulked-up
" modeline and to provide file-specific customizations.
function! s:AutoSource()
let l:testedScripts = [expand('<afile>') . '.vim']
if expand('<afile>:e') !=# 'vim'
" Don't source the edited Vimscript file itself.
call add(l:testedScripts, expand('<afile>:r') . '.vim')
endif
for l:filespec in l:testedScripts
if filereadable(l:filespec)
execute 'source' fnameescape(l:filespec)
endif
endfor
endfunction
augroup AutoSource
autocmd! BufNewFile,BufRead * call <SID>AutoSource()
augroup END
You do need this or something like this in your Vim configuration, though.
I am using gvim 7.3 on Windows 7. I want to set the "Courier_New" font in bold style.
How to do that? I tried the following but it failed.
if has("gui_running")
if has("gui_gtk2")
set guifont=Inconsolata\ 12
elseif has("gui_macvim")
set guifont=Menlo\ Regular:h14
elseif has("gui_win32")
set guifont=Courier_New\ Bold:h12:cANSI
endif
endif
An almost exactly identical example is available at the bottom of :help 'guifont':
:set guifont=courier_new:h12:w5:b:cRUSSIAN
so the following should do what you want:
:set guifont=courier_new:h12:b:cANSI
Always start with :help.
Additionaly, you can use :set guifont=* to open the font choosing dialog, select your font, and then use :set guifont? to see how the option was set.
In response to this question on SuperUser, I wrote a small vimscript that will detect the filetype of a symbolic link and change the syntax highlighting:
au BufNewFile,BufRead * if &syntax == '' | silent! execute (':set filetype='.matchstr(resolve(#%),'.[^.]*$')[1:]) | endif
So if I open a symbolic link with no extension, it will look at the extension of the file it points to.
It works, but an unintended consequence is that now the syntax highlighting of my .vimrc file is gone. By default, my .vimrc file has vim syntax highlighting (:echo &syntax returns vim).
But when I add the above line, :echo &syntax returns vimrc (an invalid type).
I don't know why this is happening. Shouldn't &syntax=='' evaluate to false, and thus keep &syntax==vim? I suspect that my code is executing before the syntax highlighting is set to vim. But how (and when) exactly is the syntax highlighting set to vim for .vimrc? Additionally, how can I make my script behave the way it should?
Look in Vim's runtime area for filetype.vim. You can bring it up in vim with:
:e $VIMRUNTIME/filetype.vim
In my version, it looks like this line does the trick:
" Vim script
au BufNewFile,BufRead *vimrc* call s:StarSetf('vim')
Perhaps you want to put your autocmd in ~/.vim/after/filetype.vim. I believe this will cause it to be registered after the system ones, and then &syntax should be set up correctly.
jszakmeister's answer diagnoses the problem accurately: filetype.vim sets the filetype for vimrc.
An alternative solution though, to keep everything contained in in your .vimrc file, is to use:
au BufNewFile,BufReadPre * if &syntax == '' | silent! execute (':set filetype='.matchstr(resolve(#%),'.[^.]*$')[1:]) | endif
Note the change from BufRead to BufReadPre. The change causes this line to execute before filetype.vim. The syntax will be changed to vimrc, but then subsequently changed to vim. The upshot is that the script works as it should, but syntax highlighting for vimrc is preserved.
When the current file is ~/.vimrc, this part of your code
matchstr(resolve(#%),'.[^.]*$')
returns your file name: .vimrc.
I have no idea how you could imagine that /home/username/.vimrc would produce vim.
This is rather obviously a bad approach for the problem you tried to solve but there's no bug: you get exactly what you ask for. Using the filename/extension for filetype can't work reliably (js vs javascript, py vs python…).
You will probably need a filename/filetype list or many if/elseif if you want your code to do what you want.
See :h syntax-loading.