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.
Related
Apparently <c-space> doing something by default in vim but I can't figure out a way to check what it's doing.
:imap <c-space>
> No mapping found
:h <c-space>
> Sorry, no help for <c-space>
It's a little hard to give a fully generic answer here and sometimes your specific platform or terminal emulator might have an effect on how specific keys are seen by Vim.
One way to try to figure out which key code is seen by Vim is to go into Insert mode and then press Ctrl+V followed by your specific key. (See :help i_CTRL-V, which will tell you Vim will insert the next symbol literally.)
In my case, typing Ctrl+V followed by Ctrl+Space in Insert mode shows me ^#, which symbolizes the Ctrl+# sequence, which shows me that's how Vim is seeing this key sequence.
(I believe this is mostly universal, and Ctrl+Space will always generate Ctrl+# everywhere, but as I mentioned there are platform differences, so I can't guarantee it works that way everywhere, but you should be able to use the same Ctrl+V trick to find out if it's the same or not in your case.)
Following that finding, you can then look at :help i_CTRL-# to see that the Ctrl+# sequence (which should be equivalent to Ctrl+Space) will "insert previously inserted text and stop insert."
I am using GVim 7.4 and I would like to do some really simple mapping to use CtrlP fuzzy matching of tags when a key combination is used.
I tried 2 approaches and they all seem to fail when vim calls Control + [x] combination. While I do understand that there are restrictions when it comes to mapping Ctrl+[x] codes, I haven't found any information on why ctrl mapping wouldn't work.
noremap \t :CtrlPTag<CR><C-\>w
This one enters CtrlP tag mode but then it doesn't enter word from under the cursor.
noremap \t <C-p><C-\>w
Here we don't even get to CtrlP window (I even omit going into tag mode here for simplicity).
As far as I understand (I'm no CtrlP user), the plugin is triggered via some command / key combination, and then presents interactive selection and filtering. It even has different "source" modes.
Now, this is a pretty heavy integration into Vim, probably using scratch buffers and its own input loop. That's why you cannot simply append keys to the mapping and get them interpreted by the plugin "as typed".
Typically, these plugins offer mode selection and so on via (optional) command arguments. Check the plugin's help, and if you cannot get the plugin into the state you need, best contact the plugin's author and ask for such enhancement.
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.. :)
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.
I'm trying to achieve something simple, usually called "function hints". For example, scintilla-based editors have it:
You type a name, and just get the prototype. There are a few problems with that in vim:
You have to rebuild the ctags to keep it up to date
You can't type C-X C-O after the (, you'll just get "Pattern not found"
You can't type C-X C-O in normal mode, the cursor will just jump around
You get the annoying preview window at the top
I've tried a few plugins; most of them mess things up even more [^1].Can anyone recommend a simple way to get just that ? A simple rectangle containing the function prototype and nothing more.
[^1] It's really mind-numbing how idiotic some of these plugins are. One plugin (I won't mention it) actually contained in the .vim file a list of functions from libc.
ctags for autocompletion is a mess. I suggest you try a compiler based plugin such as clang-complete or gcc-sense (haven't tried this one). Advantages are:
more accuracy as what they do is pretty much compiling
compile errors are marked on the fly over the source code
You have to rebuild the ctags to keep it up to date
you don't need to deal with ctags (they are still useful to jump around though)
You can't type C-X C-O after the (, you'll just get "Pattern not found"
what would you expect?
You can't type C-X C-O in normal mode, the cursor will just jump around
you can always remap that sequence if you think it's a frequent mistake (something like nnoremap <C-x><C-o> a<C-x><C-o>)
You get the annoying preview window at the top
You can disable this by removing preview fromcompleteopt option. see :help completeopt
I'm using the following setup:
clang-complete for completion
supertab to complete with tab key
ultisnips for function signature placeholders. (also works with snipmate)
and some vimrc settings:
set pumheight=10 " so the complete menu doesn't get too big
set completeopt=menu,longest " menu, menuone, longest and preview
let g:SuperTabDefaultCompletionType='context'
let g:clang_complete_auto=0 " I can start the autocompletion myself, thanks..
let g:clang_snippets=1 " use a snippet engine for placeholders
let g:clang_snippets_engine='ultisnips'
let g:clang_auto_select=2 " automatically select and insert the first match
Enjoy!
Try to use eclim (plugin for integration with Eclipse).
This solution is overheaded a lot but it works in all cases.