I need to show a 'prompt' in the preview window when the user makes a selection of an item in a popup window, which is similar to the way the tern-for-vim completion plugin does in Javascript files, but I'm intending to make it work for any file.
I'd rather have the preview window opened beforehand (either by the user, or the script, currently it doesn't matter), since I find it hard to position it, when it's being opened (I prefer the topmost position full width, and it seems there is no command like e.g. <C-W>L
, which moves the window to the right, that is if one has the terminal window split vertically, the preview window will have only half of the terminal's width, like in the picture below).
So when the user selects an item in the list, the preview window is automatically filled with the prompt
Currently I find the :pedit
command the best approach to this, since it automatically selects the preview window, if one exists. But the issue with it is that it seems to accept only a filename, and I'd rather not have such a file in the user's system, because of (many writes to the file, where to place it [it shouldn't be created in any pwd] and possibly other reasons).
Another approach can be to loop through all windows, find the preview one, and edit it with some normal
commands.
How can I go about this?