I would like to bind CTRL-N in nvim's terminal mode to autocomplete, just like CTRL-N in insert mode. I don't know command what CTRL-N is bound to in insert mode, so I am not sure how to bind it to the same key in another mode. I am new to Vim and might be confused by emacs concepts here.
The vim completion only works in insertmode, its not possible to open the completion menu in other modes.
the terminal mode however does allow you to remap keys so to make <C-n> activate the shells completion system one would add to init.vim
tnoremap <C-n> <Tab>
this might however not be what you asked for.
your asumption is right your in terminal mode. The autocompletion feature of vim doesnt work in the terminal as its a special kind of buffer that can not be edited. There are plugins though that create a pseudo terminal where the completion menu can be used see
https://github.com/Shougo/vimshell.vim
Related
I used the :term command in Vim.
but i can't escape from that.
While you are typing in the terminal, you are in the "terminal" mode. You can press <C-\><C-N> (Ctrl+\, and then Ctrl+N) to enter the "normal" mode. After that you will be able to switch the windows, with e.g., <C-W> j.
You can read :help terminal-input about this. In particular, it explains how to use Esc (instead of <C-\><C-N>) to escape the terminal mode if you want.
I'm using gvim 7.4 on Windows, and I use CTRL+O from insert mode quite often (execute one command from normal mode, then come back to insert mode). Something has remapped it (or not) to where it goes home or something from insert mode.
:imap, :nmap, and :vmap don't show any remapping for CTRL-O, and I've disabled the call to mswin.vim and behave mswin from _vimrc, but it's still happening.
Has anybody seen this or know how to correct it? Is there some other way to see what mapped it and/or override the mapping?
Not really satisfied with this solution, but Ctrl-Shift-O behaves in insert mode the way I expect Ctrl-O to behave.
If :verbose imap <C-o> doesn't show anything, it could also be caused by event handlers triggered by InsertLeave (or InsertEnter). You can quickly check via :set eventignore=all; if that fixes the problem, you need to go to all handlers listed by :autocmd InsertLeave to find the culprit.
I am currently trying out Clion from intellij but I am not a big fan of keybindings but it offers vim support. For example Clion has a keybinding ctrl+shift+n to open a fuzzy search.
Is it possible to bind a keybinding to a custom command in vim?
Something like
command :fuzzy <C-N>
IdeaVim is not Vim. There is no reason whatsoever to expect anything to work in IdeaVim like in Vim or vice-versa so… do you want that mapping to work in Vim or in IdeaVim? If your question is about Vim, your CLion explanation and tags are totally irrelevant.
In Vim, you would put this line in ~/.vimrc:
nnoremap <key> :Command<CR>
See :help key-notation for <key> and note that Vim doesn't make a difference between <C-N> and <C-n>.
Now, Vim has no "fuzzy" capability on its own, so you will need a third party plugin for that.
I don't see how you'll enjoy Vim without a preference for (fast and efficient) keybindings, but this is certainly possible, if somewhat odd. Usually, one defines keybindings for custom commands (so the other way around), in order to speed up frequently used commands.
To do the opposite, you have to consider the modes: (Custom) commands take Ex commands, whereas keybindings usually are in normal mode. Fortunately, there's the built-in :normal command to bridge between the two of them. And to use the special keycodes (like <C-N>), you need :execute:
:command FuzzySearch execute "normal \<C-N>"
Note that this probably only works in Vim itself, not in emulations (like in Eclipse or IntelliJ IDEA), as those typically only offer a subset of the full Vim functionality.
Is there a default key for scrolling in insert mode? I know that I could just
:imap <F5> <ESC><C-e>a
:imap <F6> <ESC><C-y>a
but I'm wondering if there's any key binding there by default.
For completeness, there are two dedicated commands for scrolling in insert mode, CTRLXCTRLE and CTRLXCTRLY. They are probably the proper ones to map.
See the documentation here: :h i_CTRL-X_CTRL-E.
In normal mode CTRLE and CTRLY do the same thing, I use them quite often.
In insert mode, type Ctrl-o, then type zz.
It'll set current line in the middle of the screen.
Actually, you can type any command.
when I use Ctrl-W (or Ctrl-H) in insert mode it does nothing. In gvim with the same vimrc works. I'm using Ubuntu 10.4 with gnome, what may be wrong?
Try adding to your .vimrc: set backspace=indent,eol,start
Type this from normal mode:
:verbose mapC-vC-wEnter
This will tell you two things:
you will see what your terminal emits for C-w (it is shown on the vim command line before you press Enter)
it will tell you whether C-w has any mappings in any mode
it will tell you where the mapping comes from
Subsequently look at
:verbose iabbrev
to see whether abbreviations are in the way
just try type "i" or "a"
maybe you terminal has reserved these key binds?