Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snippets with {VISUAL} #233

Closed
iandberg opened this issue Jun 4, 2016 · 5 comments
Closed

snippets with {VISUAL} #233

iandberg opened this issue Jun 4, 2016 · 5 comments

Comments

@iandberg
Copy link

iandberg commented Jun 4, 2016

Hi,
I'm having issues trying to get the visual mode content in the snippet. In regular visual mode, I select the text, hit trigger-name, and I get the literal snippet. The VISUAL bit isn't resolved. For example, using the supplied snippet:

snippet is "isset()"
    isset($1{VISUAL})

I highlight some text, do tab, is, tab, and I just get

isset({VISUAL})

I do have a number of other popular plugs installed, (supertab, commentary, surround, etc). I did try running a stripped down vim without the plugs but had trouble getting Snipmate to work at all.

Are there any known conflicts concerning the VISUAL placeholder? I'm running a recent MacVim and a fresh version of Snipmate. Works great otherwise and I love it.

thanks for any insight!
Ian

@ajzafar
Copy link
Collaborator

ajzafar commented Jun 4, 2016

This depends a bit on the version of the snippet parser that you're using (controlled with the g:snipMate.snippet_version option, see :h SnipMate-options). As mentioned in :h SnipMate-visual, in version 1 (the newer version of the parser), both $VISUAL and ${VISUAL} will work, with the $ being necessary. In version 0 (the legacy parser), only {VISUAL} is valid, without the $. It looks like your snippet is written for the latter, but maybe you have SnipMate configured to use the former.

Check for any version lines in your snippet file as well as the output of :echo g:snipMate.version. Other plugins shouldn't be interfering.

@iandberg
Copy link
Author

iandberg commented Jun 4, 2016

Thanks - I forgot to mention that I had tried the other 'flavors' of VISUAL as mentioned in the help: $VISUAL, ${VISUAL} - with the same results (literal output).
When I do :echo g:snipMate.version
I get:

E716: Key not present in Dictionary: version
E15: Invalid expression: g:snipMate.version

I then explicitly set the version in my vimrc

let g:snipMate = {}
let g:snipMate.snippet_version = 1

And now it works :) The visual variable gets the content now.

Though, :echo g:snipMate.version still gives me the dictionary errors, FYI

Thanks for your help!

Ian

@ajzafar
Copy link
Collaborator

ajzafar commented Jun 5, 2016

Oh shoot. I meant to say :echo g:snipMate.snippet_version. Glad it's working, but it should work even if you don't specify a parser version. I will have to investigate that. Leaving this open till I figure that out.

@iandberg
Copy link
Author

iandberg commented Jun 6, 2016

No worries. Let me know if you can't reproduce - I can try to set the conditions again. Am surprised there's not more chatter about the VISUAL feature - it's very handy.

ajzafar added a commit that referenced this issue Jun 8, 2016
The fix for #177 only handled the case where a visual placeholder was on
a line with an indent. With this commit, all cases should be handled.
Hopefully.

See #233
@ajzafar
Copy link
Collaborator

ajzafar commented Jun 8, 2016

It looks like my fix for #177 only worked for VISUAL stops on an indented line. All VISUAL stops should work now. (Both issues only affect the legacy parser). Thanks for the report!

@ajzafar ajzafar closed this as completed Jun 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants