Monday 15 July 2013

How to send status to the VIM status line after calling custom VIM (Python) function -


I have just created my first VIM script, I wrote it in Python. This is a simple script for switching color schemes from the directory (/ vim / etc / colors). I would like to know how to send a notification after changing the color scheme to the 'Statusline' with the name of the selected color scheme.

RSN answered my question, here is an update (

Implementation of AI and Caleb's suggestions (thanks), thanks!

  " Toggle ColorSmem 0.9 (L) 200 by Jasper Popppe & lt; jpoppe@ebay.com> "F8 and Shift + F8 Churn via ColorsCams with Nnoremap; Silent> F8>: Call Toggle Class Call toggle scheme ("- 1") & lt; CR & gt; "Chalo ji" ("1") & lt; CR & gt; Nnoremap & lt; mute & gt; & lt; s-F8 & gt; Set the directory with color schemes to cycle through: T Oggle_Color_Scheme_Path = "/ etc / vim / colors" function! ToggleColorScheme (parameter) Python & lt; endpython import vim import os paramater = (vim.eval ('a: parameter')) Scheme_path = vim.eval ('g : Toggle_Color_Scheme_Path ') colourmes = [color.split ('. ') [0] os.listdir (scheme_path) for color if color.endswith (' .vim ')] colorchemes Sort () if not vars (). If_key ('Position'): start_scheme = vim.eval ('g: colors_name') + '.vim' if 'start_scheme' in colorschemes: position = colorschemes.index (start_scheme) else: position = 0 position + = int (parameter) position% = Lennon (ColorCams) vim.command ('Colormemi% s'% Coltschem [position]) vim.command (' redraw; Echo "% s" '% colorschemes [position]) vim .command (' return 1 ') Endapthon and Function  

vim.command 'Redraw | Echo "% s" '% colorschemes [position])

to Elp echo :

redraw a later The message can disappear again and since Vim prepares most of the positions again, it does not end with the sequence of commands, it happens many times before it's "echo" Before becoming the cause of a redrone (reddraces are suspended after you do not type something), repeat it again. order. Example:

: New | Redraw | The echo is "a new window"


No comments:

Post a Comment