vim

Include color string in statusline

为君一笑 提交于 2019-12-23 13:12:03
问题 I have some function defined as function! myfunc() let s = 'hello world' return s endfunction and I can include this in my status line as statusline=%{myfunc()} , which nicely prints 'hello world'. I can also color it as statusline=%#mycolor#%{myfunc()} where mycolor is a color I've defined. Now I want to color each of the words separately, so I redefine my function as function! myfunc() let s = '%#mycolor1#hello %#mycolor2#world' return s endfunction However, when I set this in the status

Call a function in Vim’s `autocmd` command

故事扮演 提交于 2019-12-23 13:08:52
问题 I want to use the expand function in an autocmd . In particular, I am adapting a tip by Paul Biggar and I wanted to use the following auto command in my .gvimrc : autocmd FileType tex set makeprg=rubber-info\ expand("%:t:r").log – Which of course doesn’t work. So what I actually want this to mean is that upon opening a tex file, the makeprg variable is set to the value of rubber-info filename.log where filename is the name of the TeX file without its file extension. How can I accomplish this?

VIM: Is it possible to view pdf file in a split window?

扶醉桌前 提交于 2019-12-23 13:03:06
问题 I would like to view a pdf file in a split window using gVim, does anyone know if this is possible? How? Some details: I just recently started using vim and use it to make notes, while reading a pdf. I write own notes, but quite often I copy text from pdf, so smooth copying would be nice. Currently I need to alt+tab for pdf viewer, go to mouse or arrow keys, select text, copy, alt+tab back to vim. Of course this is not a huge task, but using vim I feel it could be possible without mouse,

Replace end of line for lines that start with a particular pattern

懵懂的女人 提交于 2019-12-23 12:46:45
问题 I have a file in the following format --Some-XYZ-code ; --Somemore--xyz--code; COMMENT = " THIS IS A DEMO" --somemore--code; --somemore--code; I want to put an semicolon at the end of line COMMENT, keeping the rest of the line intact. 回答1: Try this: :g/^COMMENT/ normal A; For every line that matches COMMENT at the beginning enter in Insert Mode at the end of the line and append a semicolon. Explanation : :g selects every line that matches following pattern ^COMMENT and does the action after

Defining the settings for the vim help file

99封情书 提交于 2019-12-23 12:46:40
问题 With opened vim help file the command :set conceallevel=0 works fine and e.g. the "|" signs for the internal links are showed as expected, but unfortunately, it remains not permanent, i.e., jumping to another link hides the "|" signs again. As I put this setting into my .vimrc as into my .gvimrc too to make it permanent, there is no effect at all, while other settings from my config files are applied properly. So are there any local definitions for the vim help file? Perhaps I didn't look for

Different background shades in a single vim window

不问归期 提交于 2019-12-23 12:33:30
问题 In a single VIM window with 4 or 5 buffers for example, is it possible to give each buffer a different background shade? Let's assume that the color theme is darkblue, I would like to make each buffer have a slightly different background shade of the dark blue. 回答1: No, the colorscheme settings are global. 回答2: You can do: :hi ColorColumn guibg=#550000 and then color the background of selected windows with: :setlocal colorcolumn=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24

Vim plugin for adding external links

∥☆過路亽.° 提交于 2019-12-23 12:33:14
问题 Now, this may be something obvious and already solved and known to everyone, but I just thought of it, so have mercy ... Is there a Vim plugin for (when writing markdown texts) that enables you to insert links in a way that Ctrl - L in here (StackOverflow) does it. Or something similar to it. For example, I write in a link, http://www.google.com, press Ctrl - L , and it moves that link to the bottom of the page replacing it with [description][28] where 28 is the current (increase by one from

How to change iBus input method in python?

假如想象 提交于 2019-12-23 12:32:16
问题 I am writing a Vim plugin to set iBus engines and input methods. So far I can change the engines with the code below: function! im#setEngine(name) python << EOF try: import ibus,vim bus = ibus.Bus() ic = ibus.InputContext(bus, bus.current_input_contxt()) name = vim.eval("a:name") engines = bus.get_engines_by_names([name]) size = len(engines) if size <= 0: print "Could not find engine %s"%name else: engine = engines[0] ic.set_engine(engine) except Exception, e: print "Failed to connect to iBus

Toggling a match in vimrc

天大地大妈咪最大 提交于 2019-12-23 12:27:02
问题 I have the following lines in my vimrc file: hi ExtraWhitespace cterm=NONE ctermbg=green ctermfg=green guibg=green guifg=green match ExtraWhitespace /\s\+$\|\t/ These lines will highlight all lines with no characters other than spaces as well as any tab. I would like to add a function that will toggle highlighting the whitespace. map <F8> :call ToggleWhitespaceMatching()<cr> I have tried to write my own, but have not been able to get it working. Could someone please suggest a function to

vim highlighting everything in red

拟墨画扇 提交于 2019-12-23 12:24:04
问题 I added a print line to a python script while the script was executing, and now all the text is highlighted in red when I open the file. Opening and closing the file doesn't get rid of it. Opening a second python file momentarily fixed the problem, but then closing file and reopening brought the problem back. Now it wont go away at all. Any body know what could cause this? 回答1: This happens sometimes in vim when it goes to highlight syntax on multi-line comments. Occasionally everything after