2

I want to complete multiple lines at once.

For instance, in a buffer (may be hidden):

...
using std::cout;
using std::cin;
using std::endl;
...

In the current buffer I can complete a whole line with CTRL-X CTRL-L.

using st
        ^
   CTRL-X_CTRL-L

How can I also complete the line along with the next lines? (they don't have to share a common prefix like in the example)

In the help i_CTRL-X_CTRL-L I found:

CTRL-X CTRL-L   After expanding a line you can additionally get the
        line next to it by typing CTRL-X CTRL-L again, unless
        a double CTRL-X is used.  Only works for loaded
        buffers.

which seems to be what I want, but it doesn't work. (If I enter the selection with CTRL-Y the cursor remains on the same line and pressing CTRL-X CTRL-L again completes the same line. If I enter the selection with Enter the cursor ends on the next line and pressing CTRL-X CTRL-L again completes the same line (but on this new line))

  • 1
    it looks like it works on default settings. There is a plugin/setting of mine that breaks this. I'll edit the question / add an answer when I find out the one that breaks this. – bolov Apr 27 '15 at 11:41
1

It looks like this works if you don't press <C-Y> to choose the selection. When you've selected the one you want using <C-N> and <C-P>, just type <C-X><C-L> again.

  • it doesn't work for me. When I press C-X it exits complete mode and then when I press C-L it inserts these 2 characters: ^L – bolov Apr 27 '15 at 11:16
  • That sounds like you're hitting <C-V> instead of <C-X>. Do you have any Insert mappings that might be affecting this behaviour? – tommcdo Apr 27 '15 at 11:23
  • Actually, I just confirmed that <C-L> in Insert mode will insert ^L, so there's no <C-V> necessary as for some other chords. Still bizarre though, this works just fine for me. – tommcdo Apr 27 '15 at 11:25
  • I have the YouCompleteMe plugin. Some settings I have: :set wildmode=list:longest let g:ycm_confirm_extra_conf = 0 let g:ycm_complete_in_comments = 1 let g:ycm_autoclose_preview_window_after_insertion = 1 – bolov Apr 27 '15 at 11:28
  • I don't know anything about the plugin. Have you tested this with no plugins installed? Use vim -u NONE -N. If it works there, try a minimal setup where only that plugin is installed (nothing else in your vimrc). If that breaks it again, I'd be pretty confident that the plugin is the problem. – tommcdo Apr 27 '15 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.