c - Stable text feed for vim through vimserver -


i searching highly stable way feed text (output of program) vim through vimserver. assume have started (g)vim session gvim --servername vim myfile. file myfile contains (unique) line out: marks position text should pasted. can straight forwardly achieve commandline vim --servername vim --remote-send ':%s/out:/text\\rout:/<enter>'. can repeatedly feed more text using same command. inside c-program can execute system(). text dynamic , arbitrary (received stream in c-program) needs passed on command line , hence needs escaped. furthermore using replacement command %s vim jump position text inserted. find way paste large chunks of arbitrary text seamlessly in vim. idea have vim read posix pipe :r pipe , write the string within c-program pipe. ideally solution such can continuously edit same file manually without noting output added @ out: long location outside visible area.

the purpose of text feed create command line based front end scripting languages. blocks of input entered manually user in vim buffer , being sent interpreter through pipe using vim's :! [interpreter] command. [interpreter] can of course write output stdout (preceded original lines of input) in case input line replaced input , output (to distinguished using leading key characters instance). commands might take long time produce actual output while user might want continue editing file. therefore idea have [interpreter] return out: , append subsequent lines of output in place become available using vimserver. output must inserted in way not disturb or corrupt edits possibly made user @ same time.

edit

the proposed solutions seem work. there seem @ least 2 caveats: * if send text 2 or more times way `` part of commands not take me original cursor position (if once still markers modified may interrupt user editing file manually) * if user opens different buffer (e.g. online help) commands fail (or maybe insert text in present buffer)

any ideas?

edit: after trying, should work you:

vim --servername vim --remote-send \     ":set cpo+=c<cr>/out:<cr>:i<cr>hello<cr>world<cr>.<cr>\`\`" 

as far can see, caveats period on single line, terminate :insert instead of being inserted, , <..> sequences might interpreted keypresses. also, need replace newlines in text <cr>. however, have no worries regular expressions getting muddled, input not command line, amount of escaping necessary minimal, , jumping compensated double backticks.

check out :help 'cpoptions', :help :insert, , :help ''.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -