| Screenshots | API | Fonts ➶ | Patcher ➶ |
|---|---|---|---|
![]() | ![]() |
Adds filetype glyphs (icons) to other plugins such as NERDTree, vim-airline, CtrlP, powerline, unite, lightline.vim, vim-startify, vimfiler, and flagship.
Download and install a patched nerd-font (or patch your own) (» More details... «)
Install the plugin per your usual method (» More details... «)
Set font (» More details... «)
- a. vim: Set your terminal emulator font
- b. gvim: Set
guifontin yourvimrc
This plugin follows the standard runtime path structure, and as such it can be installed with a variety of plugin managers:
git clone https://github.com/ryanoasis/vim-devicons ~/.vim/bundle/vim-devicons
Add to vimrc:
NeoBundle 'ryanoasis/vim-devicons'And install it:
:so~/.vimrc :NeoBundleInstall
Add to vimrc:
Plugin'ryanoasis/vim-devicons'
And install it:
:so~/.vimrc :PluginInstall`
- copy all of the files into your
~/.vimdirectory
Add the following to your .vimrc or .gvimrc:
setencoding=utf8letg:airline_powerline_fonts=1The ONLY other configuration needed should be setting the font vim uses to a patched font.
Already patched fonts and the font patcher script are provided at: nerd-fonts
It works without configuration ONLY when used with a patched font provided in
the separate repository above. Install the font and add it to your vimrc or
gvimrc:
Linux
setguifont=<FONT_NAME><FONT_SIZE>setguifont=Droid\ Sans\ Mono\ for\ Powerline\ Plus\ Nerd\ File\ Types\ 11OS X and Windows
setguifont=<FONT_NAME>:h<FONT_SIZE>setguifont=Droid\ Sans\ Mono\ for\ Powerline\ Plus\ Nerd\ File\ Types:h11After installing the patched font and setting the vim font just open or look at any of the supported plugins you have installed (NERDTree, airline, powerline, unite, lightline.vim, vimfiler, or flagship).
NOTE: if you don't have
guifontset and are not running gvim you will need to set the terminal font.NOTE: for support of these plugins: NERDTree, vim-airline, CtrlP, powerline, unite, vimfiler, flagship you must configure vim to load those plugins before vim-devicons loads.
NOTE: for better nerdtree-git-plugin support, you should configure vim to load nerdtree-git-plugin before vim-devicons loads.
| section | preview |
|---|---|
| statusline | |
| tabline | |
| tabline | |
| fileformats symbols |
- Only supports the CtrlP active fork
- Currently only MRU file mode supported
| Support for the Original Kien CtrlP Repo has been dropped since v0.7.0 and only the active CtrlP fork is supported |
- Currently only supports
file,file_rec, andbuffer
- NOTE: flagship support is experimental because the API may be changing
- with
g:WebDevIconsNerdTreeGitPluginForceVAlignon
- with
g:WebDevIconsNerdTreeGitPluginForceVAlignoff
- gnome terminal
- Urxvt terminal
Thanks @RageZBla
- show developer file type glyphs from a font in various vim plugins, currently supports:
- NERDTree
- vim-airline (statusline and tabline)
- lightline.vim (statusline)
- see: lightline setup
- Powerline (statusline)
- see: powerline setup
- Adds a global config map of characters to file extensions (or entire filenames)
- customizable and extendable filetype detections
- ability to override predefined dictionary variable
- if you are unhappy with the default glyph used you can choose your own
- supports a range of file type extensions by default:
styl, scss, htm, html, slim, ejs, css, less, md, json, js, jsx, rb, php, py, pyc, pyd, pyo, coffee, mustache, hbs, conf, ini, yml, bat, jpg, jpeg, bmp, png, gif, twig, cpp, c++, cxx, cc, cp, c, hs, lhs, lua, java, sh, fish, diff, db, clj, cljs, edn, scala, go, dart, xul, sln, suo, pl, pm, t, rss, f#, fsscript, fsx, fs, fsi, rs, rlib, d, erl, hrl, vim, ai, psd, psb, ts, jl
- supports full filename matches, by default:
gruntfile.coffee, gruntfile.js, gruntfile.ls, gulpfile.coffee, gulpfile.js, gulpfile.ls, dropbox, .ds_store, .gitconfig, .gitignore, .bashrc, .bashprofile, favicon.ico, license, node_modules, react.jsx, procfile
- supports library pattern matches, by default:
jquery, angular, backbone, requirejs, materialize, mootools
- font patcher (nerd-fonts)
- requires: python2, python-fontforge package
- example usage
./font-patcher unpatched-sample-fonts/Droid\ Sans\ Mono\ for\ Powerline.otf
by default you should not NEED to configure anything to get the basics working
- NOTE: You NEED to use one of the patched font provided or patch your own (nerd-fonts) unless you want to configure the filetype to glyph mappings yourself for your current font
these options can be defined in your
vimrcorgvimrcthe following options are provided however for overriding
enable/disable loading the plugin (default 1)
letg:webdevicons_enable=1- enable/disable adding the flags to NERDTree (default 1)
letg:webdevicons_enable_nerdtree=1- enable/disable adding the custom source to unite (default 1)
letg:webdevicons_enable_unite=1- enable/disable adding the column to vimfiler (default 1)
letg:webdevicons_enable_vimfiler=1- enable/disable adding to vim-airline's tabline (default 1)
letg:webdevicons_enable_airline_tabline=1- enable/disable adding to vim-airline's statusline (default 1)
letg:webdevicons_enable_airline_statusline=1- enable/disable ctrlp MRU file mode glyphs (default 1)
letg:webdevicons_enable_ctrlp=1- enable/disable adding to flagship's statusline (default 1)
letg:webdevicons_enable_flagship_statusline=1- turn on/off file node glyph decorations (not particularly useful)
letg:WebDevIconsUnicodeDecorateFileNodes=1- whether or not font is using double-width glyphs (default 1, set to 0 for single character width glyphs)
- note: does not actually switch the font or try to use the correct font, just adds a space to account for a double width glyph, you have to set the correct double width glyph font in your terminal or
guifont
- note: does not actually switch the font or try to use the correct font, just adds a space to account for a double width glyph, you have to set the correct double width glyph font in your terminal or
letg:WebDevIconsUnicodeGlyphDoubleWidth=1- whether or not to show the nerdtree brackets around flags (default 1)
letg:webdevicons_conceal_nerdtree_brackets=1- the amount of space to use after the glyph character (default ' ')
letg:WebDevIconsNerdTreeAfterGlyphPadding=''- Force extra padding in NERDTree so that the filetype icons line up vertically (when nerdtree-git-plugin is present) (default 1)
letg:WebDevIconsNerdTreeGitPluginForceVAlign=1ƛis used as an example below, substitute for the glyph you actually want to usechange the default character when no match found
letg:WebDevIconsUnicodeDecorateFileNodesDefaultSymbol='ƛ'- enable folder/directory glyph flag (disabled by default with 0)
letg:WebDevIconsUnicodeDecorateFolderNodes=1- enable open and close folder/directory glyph flags (disabled by default with 0)
letg:DevIconsEnableFoldersOpenClose=1- enable pattern matching glyphs on folder/directory (enabled by default with 1)
letg:DevIconsEnableFolderPatternMatching=1- enable file extension pattern matching glyphs on folder/directory (disabled by default with 0)
letg:DevIconsEnableFolderExtensionPatternMatching=0- enable custom folder/directory glyph exact matching (enabled by default when g:WebDevIconsUnicodeDecorateFolderNodes is set to 1)
let WebDevIconsUnicodeDecorateFolderNodesExactMatches =1- change the default folder/directory glyph/icon
letg:WebDevIconsUnicodeDecorateFolderNodesDefaultSymbol='ƛ'- change the default open folder/directory glyph/icon (default is '')
letg:DevIconsDefaultFolderOpenSymbol='ƛ'- change the default dictionary mappings for file extension matches
letg:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols= {}" neededletg:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['js'] ='ƛ'- change the default dictionary mappings for exact file node matches
letg:WebDevIconsUnicodeDecorateFileNodesExactSymbols= {}" neededletg:WebDevIconsUnicodeDecorateFileNodesExactSymbols['MyReallyCoolFile.okay'] ='ƛ'- add or override individual additional filetypes
letg:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols= {}" neededletg:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['myext'] ='ƛ'- specify OS to decide an icon for unix fileformat (not defined by default)
- this is useful for avoiding unnecessary
system()call. you might see #135 to know logic further.
- this is useful for avoiding unnecessary
letg:WebDevIconsOS='Darwin'To add the appropriate icon to lightline, call the function WebDevIconsGetFileTypeSymbol() and/or WebDevIconsGetFileFormatSymbol() in your .vimrc. For example, you could set your sections to:
letg:lightline= {
\ 'component_function': {
\ 'filetype': 'MyFiletype',
\ 'fileformat': 'MyFileformat',
\ }
\ }
function!MyFiletype()
returnwinwidth(0) > 70 ? (strlen(&filetype) ? &filetype . '' . WebDevIconsGetFileTypeSymbol() : 'no ft') : ''endfunctionfunction!MyFileformat()
returnwinwidth(0) > 70 ? (&fileformat . '' . WebDevIconsGetFileFormatSymbol()) : ''endfunction- Note this is for the current Powerline not the deprecated vim-powerline
To enable for Powerline some vimrc and powerline configuration changes are needed:
vimrc changes (only required if you don't already have powerline setup for vim):
setrtp+=$HOME/.local/lib/python2.7/site-packages/powerline/bindings/vim/" Always show statuslinesetlaststatus=2" Use 256 colours (Use this setting only if your terminal supports 256 colours)sett_Co=256powerline configuration changes:
file type segment
{
"function": "vim_devicons.powerline.segments.webdevicons",
"priority": 10,
"draw_soft_divider": false,
"after": ""
}file format segment
{
"function": "vim_devicons.powerline.segments.webdevicons_file_format",
"draw_soft_divider": false,
"exclude_modes": ["nc"],
"priority": 90
}for full example see sample file
" returns the font character that represents the icon" parameters: a:1 (filename), a:2 (isDirectory)" both parameters optional" by default without parameters uses buffer nameWebDevIconsGetFileTypeSymbol(...)
" returns the font character that represents" the file format as an icon (windows, linux, mac)WebDevIconsGetFileFormatSymbol()- todo
- more filetypes to support
- customize filetype icon colors
- more customization options in general
- more specific FAQ and Troubleshooting help
I don't want to use any of the fonts provided, I want to use font ABC
try the font patcher: nerd-fonts
see font configuration above for more details
It isn't working
Are you using the patched font provided in the separate repo (nerd-fonts) or are you patching your own?
NOTE: if running vim and no font set it will default to the terminal font that is set
check what the vim/gvim font is set to, from ex mode:
:setguifont?
check if the plugin is loaded (should give '1'), from ex mode:
:echo loaded_webdeviconscheck if the plugin is enabled (should give '1'), from ex mode:
:echog:webdevicons_enable
check if the plugin is enabled for NERDTree (should give '1'), from ex mode:
- this should NOT need to be set under normal circumstances
:echog:webdevicons_enable_nerdtree
check if you are able to see the characters, from ex mode:
:echog:WebDevIconsUnicodeDecorateFileNodesDefaultSymbol
if all this looks correct you may try this to see if any files show flags
- last resort, see if you can even set the default symbol and have it display anywhere (NERDTree, vim-airline's statusline, vim-airlines's tabline), from ex mode:
:letg:WebDevIconsUnicodeDecorateFileNodesDefaultSymbol='x'
How did you get color matching based on file type in nerdtree?
my current settings are from: preservim/nerdtree#201 (comment)
" NERDTress File highlightingfunction!NERDTreeHighlightFile(extension, fg, bg, guifg, guibg) exec'autocmd FileType nerdtree highlight ' . a:extension .' ctermbg='. a:bg .' ctermfg='. a:fg .' guibg='. a:guibg .' guifg='. a:guifgexec'autocmd FileType nerdtree syn match ' . a:extension .' #^\s\+.*'. a:extension .'$#'endfunctioncallNERDTreeHighlightFile('jade', 'green', 'none', 'green', '#151515') callNERDTreeHighlightFile('ini', 'yellow', 'none', 'yellow', '#151515') callNERDTreeHighlightFile('md', 'blue', 'none', '#3366FF', '#151515') callNERDTreeHighlightFile('yml', 'yellow', 'none', 'yellow', '#151515') callNERDTreeHighlightFile('config', 'yellow', 'none', 'yellow', '#151515') callNERDTreeHighlightFile('conf', 'yellow', 'none', 'yellow', '#151515') callNERDTreeHighlightFile('json', 'yellow', 'none', 'yellow', '#151515') callNERDTreeHighlightFile('html', 'yellow', 'none', 'yellow', '#151515') callNERDTreeHighlightFile('styl', 'cyan', 'none', 'cyan', '#151515') callNERDTreeHighlightFile('css', 'cyan', 'none', 'cyan', '#151515') callNERDTreeHighlightFile('coffee', 'Red', 'none', 'red', '#151515') callNERDTreeHighlightFile('js', 'Red', 'none', '#ffa500', '#151515') callNERDTreeHighlightFile('php', 'Magenta', 'none', '#ff00ff', '#151515') callNERDTreeHighlightFile('ds_store', 'Gray', 'none', '#686868', '#151515') callNERDTreeHighlightFile('gitconfig', 'Gray', 'none', '#686868', '#151515') callNERDTreeHighlightFile('gitignore', 'Gray', 'none', '#686868', '#151515') callNERDTreeHighlightFile('bashrc', 'Gray', 'none', '#686868', '#151515') callNERDTreeHighlightFile('bashprofile', 'Gray', 'none', '#686868', '#151515')
Note: If the colors still are not highlighting, try invoking such as:
autocmd VimEnter * call NERDTreeHighlightFile('jade', 'green', 'none', 'green', '#151515')
How did you get color matching on just the glyph/icon in nerdtree?
" NERDTress File highlighting only the glyph/icon" test highlight just the glyph (icons) in nerdtree:autocmdfiletypenerdtreehighlight haskell_icon ctermbg=none ctermfg=Red guifg=#ffa500 autocmdfiletypenerdtreehighlight html_icon ctermbg=none ctermfg=Red guifg=#ffa500 autocmdfiletypenerdtreehighlight go_icon ctermbg=none ctermfg=Red guifg=#ffa500 autocmdfiletypenerdtreesynmatch haskell_icon ## containedin=NERDTreeFile " if you are using another syn highlight for a given line (e.g." NERDTreeHighlightFile) need to give that name in the 'containedin' for this" other highlight to work with itautocmdfiletypenerdtreesynmatch html_icon ## containedin=NERDTreeFile,html autocmdfiletypenerdtreesynmatch go_icon ## containedin=NERDTreeFile
Issues after re-sourcing
vimrcTry adding this to the bottom of your
vimrcifexists("g:loaded_webdevicons") callwebdevicons#refresh() endif
Artifacts after or instead of glyphs
- Dots after icons in NERDTree (on GVim), try:
autocmdFileTypenerdtreesetlocalnolist
Best ways to contribute
- Star it on GitHub - if you use it and like it please at least star it :)
- Promote
- Open issues/tickets
- Submit fixes and/or improvements with Pull Requests
Like the project? Please support to ensure continued development going forward:
Contributions and pull requests are welcome.
No real formal process has been setup - just stick to general good conventions for now.
After seeing the awesome theme for Atom (seti-ui) and the awesome plugins work done for NERDTree and vim-airline and wanting something like this for Vim I decided to create my first plugin.
- vim-airline
- nerdtree
- nerdtree-git-plugin
- seti-ui
- devicons by Theodore Vorillas
- benatespina development.svg.icons
- Steve Losh
See LICENSE

