Wikia

Vim Tips Wiki

Script:1457

1,623pages on
this wiki
Talk0

Use this page to discuss script 1457 CycleColor: cycle through available colorschemes

  • Add constructive comments, bug reports, or discuss improvements (see the guideline).
  • Do not document the script here (the author should do that on vim.org).
  • This page may be out of date: check the script's vim.org page above, and its release notes.

Fix for WindowsEdit

The CycleColor.vim script didn't work for me on Windows until I made the following change to escape those pesky backslashes before using the name in the regex:

--- a/plugin/cyclecolor.vim
+++ b/plugin/cyclecolor.vim
@@ -74,17 +74,18 @@ function! s:CycleColor(direction)
                endif
        endif

+       let escaped = substitute(s:currentfile, '\\', '\\\\', 'g')
        if a:direction >= 0
                " Find the current file name, and select the next one.
                " No substitution will take place if the current file is not
                "   found or is the last in the list.
-               let nextfile = substitute(s:schemes, '.*\n'.s:currentfile.'\n\([^\x0A]\+\)\n.*', '\1', '')
+               let nextfile = substitute(s:schemes, '.*\n'.escaped.'\n\([^\x0A]\+\)\n.*', '\1', '')
                " If the above worked, there will be no control chars in
                "   nextfile, so this will not substitute; otherwise, this will
                "   choose the first file in the list.
                let nextfile = substitute(nextfile, '\n\+\([^\x0A]\+\)\n.*', '\1', '')
        else
-               let nextfile = substitute(s:schemes, '.*\n\([^\x0A]\+\)\n'.s:currentfile.'\n.*', '\1', '')
+               let nextfile = substitute(s:schemes, '.*\n\([^\x0A]\+\)\n'.escaped.'\n.*', '\1', '')
                let nextfile = substitute(nextfile, '.*\n\([^\x0A]\+\)\n\+', '\1', '')
        endif

-- April 1, 2015

CommentsEdit

Around Wikia's network

Random Wiki