3

Is there a way to expand a UltiSnips snippet while in vim command-line mode? I can only expand a snippet in insert mode.

I am using UltiSnips to help inserting unicode characters. And I need to write these characters in the command-line for searching. I do not want to insert them using <C-v>u. I also prefer not to use digraphs.

  • Digraphs are made exactly for this purpose (IMO using snippets is a bit overkill to insert a single character). Why don't you want to use them? – statox Sep 13 '15 at 16:39
1

While I didn't achieve to trigger the completion from the command-line mode you can work this like this :

Prepare your command inside insert mode (or at least the part you cannot create from command-line mode). Yank it and insert it inside your command using <C-r> and the " register like so :

Insert Mode

tec<Tab>yiw

Commande-line Mode

:/<C-r>"

In command-line mode, there are only a set of word you can expand, for example : Command names, Tags, File names, ...

See : http://vimdoc.sourceforge.net/htmldoc/cmdline.html#cmdline-completion

| improve this answer | |
  • I don't know how to use your answer, can you explain it further, please? E.g. I have a snippet ec that expands to ê and I use <Tab> key to expand snippets. In insert mode, I type tec<Tab> and get . In command-line mode to search, I type /tec<Tab> but get nothing. How do I use this :call UltiSnips#ExpandSnippetOrJump()? – Nasolo Andrianoelina Aug 14 '15 at 14:15
  • Oh ok I didn't understand your question, let me update my answer :) – nobe4 Aug 14 '15 at 14:20
0

I use noreabbrev to insert frequently used unicodes, for example:

noreabbrev vvref ※
noreabbrev vvsec §

Abbreviations are triggered automatically on non-keyword character or CTRL+]. It works both in Insert Mode and Command Mode. Or use cnoreabbrev and inoreabbrev to define Command Mode and Insert Mode only abbreviations. It also can be used to define command aliases.

More information can be found in :help abbreviations.

| improve this answer | |
  • 1
    Welcome to Vi and Vim! Your answer was flagged for review since it's too short. I do think it could be improved. Could you explain how you use noreabbrev to insert frequently used Unicode characters? Perhaps some examples of the commands you personally use? That would surely improve this answer... Thanks! – filbranden Jun 1 at 14:58

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.