Vim autocomplete: Cancelling autocomplete popup - vim

If I hit ctrl+n in vim, I'll get a list of suggested autocomplete options in a popup box.
This is fine...but if I decide I don't want to autocomplete after all, I'm not quite sure what to press to revert the suggestion.
For example, suppose I type rea, hit ctrl+n, and autocomplete pops up with really_long_method_name_damn_this_is_annoying...and I don't want that. I can't quite figure out how to revert the syntax back to just rea... I have to manually delete the unwanted characters.
I'm guessing this is a pretty straightforward thing, but still - if anyone knows how, please let me know.

Ctrl+E will end the current completion and put back that originally typed text.
See
:h complete_CTRL-E
:h ins-completion

Try pressing Ctrl+P to take you back to the original (or if you are feeling ambitious, Ctrl+N until you loop back around :) ).

Type :help ins-completion-menu for a detailed description of all your options.

Press Ctrl+P followed by Esc. The former will remove the autocompleted text, and the latter will close the popup.

Related

Why is Autocomplete not working for vim-jedi

I'm relatively new to Vim so there may be something obvious I'm missing here. I'm usig Neovim and have installed the vim-jedi plugin. When I'm typing, I can see that it's offering autocomplete options:
I can scroll down to this option (using the arrow keys) and hit Enter to have it autocomplete. However, if I hit <Ctrl+Space> then it does not autocomplete. I've looked at my :map and <Ctrl+Space> doesn't seem to be mapped to anything already. Can anyone please assist?
I've never used that plugin before, but when using VIM normally I always do CTRL-p or CTRL-n to auto-complete a word that has already been typed once in my document. Then after highlighting the correct one, I hit space to confirm selection and also to continue typing the next word. Hitting CTRL-space should be unnecessary if it works in the same way as regular vim auto-complete.
You can also use CTRL-n or CTRL-p respectively to select which word is the correct one to auto-complete to.

Vim Ctrl P take out my search highlighting. How to make the highlighting stay while in Ctrl P search mode

I usually search for the route in my route file and it will be highlighted.
However, when I start searching for it in Ctrl P, the highlighted word is not highlighted anymore. It really bother me to find back where exactly that word I was searching for due to the highlighting disappear in Ctrl P search mode.
I believe there is a way to reprogram this in vimrc. I tried google, no result.
Please help.
Well, this doesn't answer your exact question ;) however, it sounds like what you're trying to do is to use the highlight to help you search. Ctrl-p has a helpful keystroke C-\ which brings up a prompt where you can tell it to use the search term as the value for ctrl-p
so.. for you.
/searchforyourterm
C-p to bring up Ctrl-p
C-\ to bring up the special prompt
s to insert the searched word.
I'm not sure how to do what you're actually asking for, but perhaps the above will be what you really need :)
link to the help doc or run :h ctrl-p and search for paste.. :)

How to i show omnicomplete's autocomplete list without autocompleting current text

I am learning vim with omnicomplete. I am wondering whether I can show the omnicomplete list without autocompleting current text. For example,
If I type "str.c" and then invoke omnicomplete, it will show a list containing possible words starting with "c", and autocomplete the current text to, say "capitalize".
If, for example, the method I am looking for is count, I have to scroll all the way down the list to find it, or delete the "apitalize" part, and then type o, etc. Is it possible to just show the list, so that if I invoke it after c, it will show the list without autocompleting to capitalize? For example to something like below, where I can still type o to quickly go to count
Thanks to #romainl comment, I looked up completeopt, and I found the answer Make Vim completion popup menu work just like in an IDE. It has a bunch of other related tips. To make the behaviour as described in the question,
:set completeopt=longest,menuone
You can also just stick with the basic vim functionality, and use C-e while in completion to have vim remove the list and go back to the point you initiated the completion.
Alternatively, you can press <C-P> right after <C-X><C-O> to go back to what you typed while keeping the completion menu open.
Check out :h ins-completion-menu for more information.
I think that the initial problem was the lack of noinsert in completeopt option.

Using makefiles and vim without prompt

I'm using vim and im doing a lot of
:make
within vim. The only thing that is really annoying is that I have to press ENTER twice to jump back to the editor. I just want to go directly back if everything worked out fine. And I want to see the error once and press a key to jump directly to the error line.
Any ideas?
This is known as the hit-enter prompt:
If you accidentally hit or and you want to see the displayed
text then use |g<|. This only works when 'more' is set.
To reduce the number of hit-enter prompts:
Set 'cmdheight' to 2 or higher.
Add flags to 'shortmess'.
Reset 'showcmd' and/or 'ruler'.
Also, I'm sure you are aware of the quickfix window (:copen) to navigate errors/messages?
This can happen when the 'cmdheight' varible is < 2.
I had the same problem. This is a simple solution that seems to work:
map <F2> :silent make^M
Now I just hit the F2 key to compile and the annoying prompt is not so annoying.
Not sure if it would help you, but if you're on Windows you could try:
:set makeprg=start\ make
I think this will break the errorfile setting though.
See:
:help make
:help !start

Is there a way to change the behavior of the vim omnicomplete menu?

Omnicompletion is working, but it automatically inserts the first result.
What I'd like to do is open the omnicomplete menu, then be able to type to narrow down the results, then hit enter or tab or space or something to insert the selected menu item.
Is this possible?
The command you are looking for is:
:set completeopt+=longest
It will insert the longest common prefix of all the suggestions, then you can type and delete to narrow down or expand results.
set wildmenu
set wildmode=list:longest,full
Found here.
There is also a great plugin for all of your completion needs called SuperTab continued.
This plugin might do what you are after: autocomplpop
Or you can try and make Vim completion popup menu work just like in an IDE.
This is the general Vim completion behaviour. For a complete overview, you can do
:he compl-current
But for your specific case (which you require the completion to be in state 2 or 3 (described in the document above). You can simply use Backspace, or Control-H to jump from state one to state two. In state 2 you can narrow the search by typing regular characters. So to complete completion with narrowing:
compl<C-X><C-P><BS>letion
It is totally backwards, I know, but that's how it works.
Edit: You can use the Down arrow key too isntead of Control-H or Backspace, and it has the benefit of not deleting a character.

Resources