3

I use Static Site Generator | Nikola. Each post has a header like as follows:

<!--
.. title: Some interesting title
.. slug: some-interesting-title
.. date: 2017-01-25 06:32:15 UTC-03:00
.. tags: tag1,tag2
.. category: Enlaces
.. link:
.. description: bla, bla, bla
.. type: text
-->

My idea is create a file with tags (tag1, tag2, ... tagn), and to use insert mode completion, whith CTRL-X and CTRL-I. But I have no idea about how to set an included file in order to vim find in it.

Edited:

I've found in the documentation:

CTRL-X CTRL-I       Search for the first keyword in the current and
            included files that starts with the same characters
            as those before the cursor.  The matched keyword is
            inserted in front of the cursor.

I haven't found how and/or where declare such a files.

I've even tried with the solution from c - vim keyword completion - Stack Overflow

I've created an empty file, and added:

set path+=/tmp/tags/**

It does not work. I use vim-enhanced-8.0.329-1.fc25.x86_64.

Any ideas?

  • I would reccomend using the 'omnifunc' with CTRL-X CTRL-O instead. "Current and included files" is talking about the file that is open and #include files (Like in C). – Tumbler41 Feb 28 '17 at 20:51
2

You could use dictionary completion to do this. Basically it completes what you type from a file (as you want). By default it is mapped to i_ctrl-x_ctrl-k and the dictionary file can be set using set dictionary=fname where fname is the name of the file containing the words (either absolute or relative to the current directory). If you really want the mapping to be i_ctrl-x_ctrl-i you could of course remap. Only problem is when you already use a dictionary (e.g. if you set spell). In that case it would probably be possible to switch dictionaries temporarily, but I'm not sure how that would work. For more information check :help ins-completion.

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.