Calling omnicompletion for every keypress in vim

后端 未结 3 436
庸人自扰
庸人自扰 2021-01-14 17:24

I have a vim script that uses a one line window to get a filename pattern from the user. This pattern can be completed to a full filename from a database if you press CTRL-X

相关标签:
3条回答
  • 2021-01-14 17:27

    Try - and modify if necessary - this plugin: http://www.vim.org/scripts/script.php?script_id=1879

    I'm a happy user.

    0 讨论(0)
  • 2021-01-14 17:39

    You should look at :h autocmd. I believe the InsertChange event could be used to do what you want.

    0 讨论(0)
  • 2021-01-14 17:42

    Austin is on the right track, but just with the wrong event. Take a look at the CursorMovedI event of autocmd. Basically, it'll fire any time the keyboard cursor moves while in Insert mode. Type a character? Cursor moves, and the event is fired.

    Keep in mind this is a bit heavy-handed for your use, because the cursor can move due to other things than typing or deleting characters. The user could use the arrow keys to move back where they want to edit. You'd be popping up the completion with every move.

    I can't find anything in the help about window-local autocommands, but buffer-local exists, so that might be close enough.

    0 讨论(0)
提交回复
热议问题