Advertisement
FocusedWolf

Vim: Scrolling through colorschemes with Alt + MouseWheel

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