2

I recently switched to using neovim + deoplete + neosnippets and I'm trying to get a snippet to do a thing that I'm pretty sure that I've been able to do in UltiSnips. In a template I'd like to be able to enter a value for ${0:THING} and have it be reused throughout the snippet output without retyping it. I'm not sure if there's a point in providing the snippet because it doesn't do what I want, but just in case my description isn't clear enough, this:

snippet thing
abbr    thing
    #ifndef THING_${0:TYPE}_H
    #define THING_${0}_H

    #include <something.h>

    BEGIN_DECLS

    // ...

    END_DECLS

    #endif /* THING_${0}_H */

would produce:

#ifndef THING_TEST_H
#define THING_TEST_H

#include <something.h>

BEGIN_DECLS

// ...

END_DECLS

#endif /* THING_TEST_H */

if I hit <C-k> and enter 'TEST' when prompted.

1 Answer 1

2

The answer is synchronized placeholders; I just couldn't find anything online/in the manual because I didn't know the terminology. The correct snippet would be:

snippet thing
abbr    thing
    #ifndef THING_${1:something}_H
    #define THING_$1_H

    #include <something.h>

    BEGIN_DECLS

    // ...

    END_DECLS

    #endif /* THING_$1_H */

For some reason, starting from 0 creates an error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.