list 如何获取 Vim 中所有已安装配色方案的列表?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7331940/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 01:42:29  来源:igfitidea点击:

How to get the list of all installed color schemes in Vim?

listvimcolor-scheme

提问by tunnuz

Is there a way to get a list of all installed color schemes in Vim? That would make very easy to select one without looking at the .vimdirectory.

有没有办法获得 Vim 中所有已安装配色方案的列表?这将很容易在不查看.vim目录的情况下选择一个。

回答by Xavier T.

Type

类型

:colorschemethen Spacefollowed by TAB.

:colorscheme然后SpaceTAB.

or as Peter said,

或者正如彼得所说,

:colorschemethen Spacefollowed by CTRLd

:colorscheme然后Space紧随其后CTRLd

The short version of the command is :coloso you can use it in the two previous commands, instead of using the "long form".

该命令的简短版本是:colo为了您可以在前两个命令中使用它,而不是使用“长格式”。

If you want to find and preview more themes, there are various websites like Vim colors

如果您想查找和预览更多主题,可以使用各种网站,例如Vim 颜色

回答by Fabien

You can see the list of color schemes under /usr/share/vim/vimNN/colors(with NNbeing the version, e.g. vim74for vim 7.4).

您可以在下面看到配色方案列表/usr/share/vim/vimNN/colorsNN版本,例如vim74vim 7.4)。

This is explained here.

这是解释here

On the linux servers I use via ssh, TABprints ^Iand CTRLdprints ^D.

在我通过 ssh、TABprints^ICTRLdprints使用的 linux 服务器上^D

回答by runlevel0

Just for convenient reference as I see that there are a lot of people searching for this topic and are too laz... sorry, busy, to check themselves (including me). Here a list of the default set of colour schemes for Vim 7.4:

只是为了方便参考,因为我看到有很多人在搜索这个主题并且太懒了......对不起,忙,检查自己(包括我)。这里列出了 Vim 7.4 的默认配色方案:

blue.vim
darkblue.vim,
delek.vim
desert.vim
elflord.vim
evening.vim
industry.vim                                                                                                                                                 
koehler.vim                                                                                                                                                  
morning.vim                                                                                                                                                  
murphy.vim                                                                                                                                                   
pablo.vim                                                                                                                                                    
peachpuff.vim                                                                                                                                                
ron.vim                                                                                                                                                      
shine.vim                                                                                                                                                    
slate.vim                                                                                                                                                    
torte.vim                                                                                                                                                    
zellner.vim 

回答by John C Earls

If you are willing to install a plugin, I recommend https://github.com/vim-scripts/CycleColor.

如果你愿意安装插件,我推荐https://github.com/vim-scripts/CycleColor

to cycle through all installed colorschemes. Nice way to easily choose a colorscheme.

循环浏览所有已安装的配色方案。轻松选择配色方案的好方法。

回答by chappar

Here is a small function I wrote to try all the colorschemes in $VIMRUNTIME/colors directory.

这是我编写的一个小函数,用于尝试 $VIMRUNTIME/colors 目录中的所有颜色方案。

Add the below function to your vimrc, then open your source file and call the function from command.

将以下函数添加到您的 vimrc,然后打开您的源文件并从命令调用该函数。

function! DisplayColorSchemes()
   let currDir = getcwd()
   exec "cd $VIMRUNTIME/colors"
   for myCol in split(glob("*"), '\n')
      if myCol =~ '\.vim'
         let mycol = substitute(myCol, '\.vim', '', '')
         exec "colorscheme " . mycol
         exec "redraw!"
         echo "colorscheme = ". myCol
         sleep 2
      endif
   endfor
   exec "cd " . currDir
endfunction

回答by nperson325681

If you have your vim compiled with +menu, you can follow menus with the :helpof console-menu. From there, you can navigate to Edit.Color\ Schemeto get the same list as with in gvim.

如果你用 编译了你的vim +menu,你可以跟随带有:helpof 的菜单console-menu。从那里,您可以导航到Edit.Color\ Scheme以获取与 in 相同的列表gvim

Other method is to use a cool script ScrollColorsthat previews the colorschemes while you scroll the schemes with j/k.

另一种方法是使用一个很酷的脚本ScrollColors,它可以在您使用j/k.

回答by roy

Looking at my system's menu.vim (look for 'Color Scheme submenu') and @chappar's answer, I came up with the following function:

查看我系统的 menu.vim(查找“配色方案子菜单”)和 @chapar 的答案,我想出了以下功能:

" Returns the list of available color schemes
function! GetColorSchemes()
   return uniq(sort(map(
   \  globpath(&runtimepath, "colors/*.vim", 0, 1),  
   \  'fnamemodify(v:val, ":t:r")'
   \)))
endfunction

It does the following:

它执行以下操作:

  1. Gets the list of available color scheme scripts under all runtime paths (globpath, runtimepath)
  2. Maps the script paths to their base names (strips parent dirs and extension) (map, fnamemodify)
  3. Sorts and removes duplicates (uniq, sort)
  1. 获取所有运行时路径下的可用配色方案脚本列表(globpath、runtimepath)
  2. 将脚本路径映射到它们的基本名称(剥离父目录和扩展名)(map、fnamemodify)
  3. 排序并删除重复项(uniq、sort)

Then to use the function I do something like this:

然后使用该功能我做这样的事情:

let s:schemes = GetColorSchemes()
if index(s:schemes, 'solarized') >= 0
   colorscheme solarized
elseif index(s:schemes, 'darkblue') >= 0
   colorscheme darkblue
endif

Which means I prefer the 'solarized' and then the 'darkblue' schemes; if none of them is available, do nothing.

这意味着我更喜欢“solarized”和“darkblue”方案;如果它们都不可用,则什么都不做。

回答by William Barrett

A great solution, and my thanks to your contributors. For years I've been struggling with a totally crappy color scheme -- using SSH under Windows Vista to a Redhat system, terminal type xterm. The editor would come up with a black background and weird colors for various keywords. Worse -- that weird color scheme sticks in the xterm terminal after leaving Vim.

一个很好的解决方案,感谢您的贡献者。多年来,我一直在为一个完全蹩脚的配色方案而苦苦挣扎——在 Windows Vista 下使用 SSH 到 Redhat 系统,终端类型为 xterm。编辑器会为各种关键字提供黑色背景和奇怪的颜色。更糟糕的是——离开 Vim 后,那个奇怪的配色方案仍然存在于 xterm 终端中。

Really confusing.

真的很混乱。

Also, Backspace failed during an insert mode, which was nasty to remember -- though Delete did the same thing.

此外,Backspace 在插入模式期间失败,这很难记住——尽管 Delete 做了同样的事情。

The cure --

治愈 -

  1. In the SSH monitor, select Edit/Settings.

    a. Choose Profile Settings/Colors

    b. check 'enable ANSI colors'

    c. The standard Text colors are probably OK

  2. Add these lines to $HOME/.vimrc:

    colorscheme default

    if &term == "xterm"

    set t_kb=^H

    fixdel

    endif

  3. NOTE: the ^H MUST be typed as ctrl-V ctrl-H. Seems peculiar, but this seems to work.

  1. 在 SSH 监视器中,选择编辑/设置。

    一种。选择配置文件设置/颜色

    湾 选中“启用 ANSI 颜色”

    C。标准文本颜色可能没问题

  2. 将这些行添加到 $HOME/.vimrc:

    默认颜色方案

    如果 &term == "xterm"

    设置 t_kb=^H

    固定删除

    万一

  3. 注意:^H 必须输入为 ctrl-V ctrl-H。看起来很奇怪,但这似乎有效。

回答by Brady Trainor

Try

尝试

set wildmenu
set wildmode=list:full
set wildcharm=<C-z>
let mapleader=','
nnoremap <leader>c :colorscheme <C-z><S-Tab>

in your ~/.vimrc.

在您的~/.vimrc.

The first two lines make possible matches appear as lists. You can use either or both.

前两行使可能的匹配显示为列表。您可以使用其中一个或两者。

The fourth line makes leader ,instead of the default \.

第四行是领导者,而不是默认的\

The last line allows you to simply type ,cto get a list and a prompt to change your colorscheme.

最后一行允许您简单地键入,c以获取列表和更改颜色方案的提示。

The third line effectively allows for Tabs to appear in key maps.

第三行有效地允许Tabs 出现在关键映射中。

(Of course, all of these strategies I've learned from the internet, and mostly SO, very recently.)

(当然,所有这些策略都是我最近从互联网上学到的,而且大部分都是如此。)

回答by nitinr708

Another simpler way is while you are editing a file - tabe ~/.vim/colors/ENTERWill open all the themes in a new tab within vim window.

另一种更简单的方法是在编辑文件时 - tabe ~/.vim/colors/ENTER将在 vim 窗口的新选项卡中打开所有主题。

You may come back to the file you were editing using - CTRL + W + WENTER

您可以使用 - ENTER返回您正在编辑的文件CTRL + W + W

Note: Above will work ONLY IF YOU HAVE a .vim/colorsdirectory within your home directory for current $USER(I have 70+ themes)

注意:只有当.vim/colors您的主目录中有当前目录$USER(我有 70 多个主题)时,上述内容才有效

[user@host ~]$ ls -l ~/.vim/colors | wc -l

72

[user@host ~]$ ls -l ~/.vim/colors | wc -l

72