Advertisement
FocusedWolf

Vim: Scrolling through colorschemes with Alt + MouseWheel

Jan 30th, 2025 (edited)
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 3.80 KB | None | 0 0
  1. " For completeness, Ctrl + MouseWheel font zooming from this other code: https://pastebin.com/yLqkSd6p
  2.  
  3. " WARNING: If you scroll too fast you will get a seizure.
  4.  
  5. " Bind Alt + MouseWheel to cycle color schemes {{{
  6.  
  7. " Online post: https://pastebin.com/8uxUNfKL
  8.  
  9. let g:colorschemes = sort(getcompletion('', 'color'), 'i') " SOURCE: https://stackoverflow.com/a/63059578 # GetColorSchemes()
  10. let g:current_colorscheme_index = 0
  11.  
  12. function! CycleColorSchemes(direction)
  13.     let g:current_colorscheme_index = (g:current_colorscheme_index + a:direction + len(g:colorschemes)) % len(g:colorschemes)
  14.     call ResetColorScheme() " Fix for issue where not all color schemes clear colors defined by other color schemes.
  15.     exec 'colorscheme ' . g:colorschemes[g:current_colorscheme_index]
  16.     " Display the current color scheme name.
  17.     " if exists('g:colors_name')
  18.     "     redraw | echomsg g:colors_name
  19.     " endif
  20.     "
  21.     " Instead of relying on g:colors_name (which can be the same for different versions of a theme or undefined) this is more reliable.
  22.     redraw | echomsg g:colorschemes[g:current_colorscheme_index]
  23. endfunction
  24.  
  25. function! ResetColorScheme()
  26.     " SOURCE: https://www.reddit.com/r/vim/comments/5pwohr/comment/dcugrge/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
  27.     set background=dark
  28.     hi clear
  29.     if exists("syntax_on")
  30.         syntax reset
  31.     endif
  32. endfunction
  33.  
  34. nnoremap <silent> <A-ScrollWheelDown> :<C-u>call CycleColorSchemes(+1)<CR>
  35. inoremap <silent> <A-ScrollWheelDown> <Esc>:<C-u>call CycleColorSchemes(+1)<CR>
  36. vnoremap <silent> <A-ScrollWheelDown> <Esc>:<C-u>call CycleColorSchemes(+1)<CR>
  37. cnoremap <silent> <A-ScrollWheelDown> <Esc>:<C-u>call CycleColorSchemes(+1)<CR>
  38. onoremap <silent> <A-ScrollWheelDown> <Esc>:<C-u>call CycleColorSchemes(+1)<CR>
  39.  
  40. nnoremap <silent> <A-ScrollWheelUp> :<C-u>call CycleColorSchemes(-1)<CR>
  41. inoremap <silent> <A-ScrollWheelUp> <Esc>:<C-u>call CycleColorSchemes(-1)<CR>
  42. vnoremap <silent> <A-ScrollWheelUp> <Esc>:<C-u>call CycleColorSchemes(-1)<CR>
  43. cnoremap <silent> <A-ScrollWheelUp> <Esc>:<C-u>call CycleColorSchemes(-1)<CR>
  44. onoremap <silent> <A-ScrollWheelUp> <Esc>:<C-u>call CycleColorSchemes(-1)<CR>
  45.  
  46. " }}} Bind Alt + MouseWheel to cycle color schemes
  47.  
  48. " Over 300 colorschemes so you have a few to scroll through:
  49.  
  50. " SOURCE: https://github.com/rafi/awesome-vim-colorschemes
  51. Plug 'rafi/awesome-vim-colorschemes'
  52.  
  53. " SOURCE: https://github.com/mcchrish/vim-no-color-collections
  54. Plug 'andreasvc/vim-256noir'
  55. Plug 'Alligator/accent.vim'
  56. Plug 'plan9-for-vimspace/acme-colors'
  57. Plug 'huyvohcmc/atlas.vim'
  58. Plug 'LuRsT/austere.vim'
  59. Plug 'chriskempson/base16-vim'
  60. Plug 't184256/vim-boring'
  61. Plug '~romainl/vim-bruin'
  62. Plug 'aditya-azad/candle-grey'
  63. Plug 'ntk148v/komau.vim'
  64. Plug 'davidosomething/vim-colors-meh'
  65. Plug 'pbrisbin/vim-colors-off'
  66. Plug 'andreypopp/vim-colors-plain'
  67. Plug 'owickstrom/vim-colors-paramount'
  68. Plug 'reedes/vim-colors-pencil'
  69. Plug 'Jorengarenar/vim-darkness'
  70. Plug 'KKPMW/distilled-vim'
  71. Plug 'jaredgorski/fogbell.vim'
  72. Plug 'zekzekus/menguless'
  73. Plug 'jaredgorski/Mies.vim'
  74. Plug 'fxn/vim-monochrome'
  75. Plug 'koron/vim-monochromenote'
  76. Plug 'Lokaltog/vim-monotone'
  77. " TODO: This repo isn't set up as a vim plugin.
  78. " Plug 'bdd/noclown.vim'
  79. Plug 'robertmeta/nofrils'
  80. Plug 'n1ghtmare/noirblaze-vim'
  81. Plug 'YorickPeterse/vim-paper'
  82. Plug 'ajgrf/parchment'
  83. Plug 'widatama/vim-phoenix'
  84. Plug 'axvr/photon.vim'
  85. Plug 'ewilazarus/preto'
  86. Plug 'stefanvanburen/rams.vim'
  87. Plug 'kadekillary/skull-vim'
  88. Plug 'nikolvs/vim-sunbather'
  89. Plug 'ryanpcmcquen/true-monochrome_vim'
  90. Plug 'hardselius/warlock'
  91. Plug 'pgdouyon/vim-yin-yang'
  92. Plug 'danishprakash/vim-yami'
  93. Plug 'cideM/yui'
  94. Plug 'zaki/zazen'
  95. Plug 'mcchrish/zenbones.nvim'
  96. Plug 'vim-scripts/zenesque.vim'
  97. " NOTE: Needs lua to work.
  98. " Plug 'kvrohit/rasmus.nvim'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement