As a big TextExpander fan and new to bash/zsh, I wanted to create new snippets to speed up my workflow.

I wanted to find a way to navigate in my expanded snippet content. Let's imagine my expanded snippet content is the following:

"Lorem ipsum ($1) Lorem ipsum ($2) Lorem ipsum ($3)"

Where ($1) is where my cursor would go once the snippet is expanded.

I would fill this placeholder, then hit the tab key, then fill ($2), then hit tab, then fill ($3).

I didn't find any answer when searching "Zsh completion tab". I can do it Sublime Text and would like to do it in Zsh. If not possible in Zsh, at least in Bash.

  • Do you want to override the default meaning of Tab, which is completion? You wouldn't find it in completion settings since what you're doing has nothing to do with completion. How does this feature work, anyway? Does inserting a snippet insert markers for where you want the cursor to move next, or does it invisibly remember the positions or what? What happens if you insert a second snippet before fully filling up the first? – Gilles Dec 15 '17 at 21:17
  • Gilles, thank your for your very precise answer. No, I do not want to override Tab default meaning. You are right I used the wrong term (completion) and my question is not formulated at best... but didn't know how to say it in a different way. "Does inserting a snippet insert markers for where you want the cursor to move next"? Yes. If you have ever used Sublime Text I have found this video on Youtube that shows the creation of a snippet with the ability to choose the place of the cursor when the snippet content is expanded: youtube.com/watch?v=PyCCdxQoqII From min 3'00 to 4'30. – politicus Dec 16 '17 at 0:29
  • Here is an example with more than one "cursor placeholder". youtube.com/watch?v=zS_4yLizMBw From min 6"00 to 6"55. I am not interested in adding a default placeholder text. I just want my cursor to be in the first "placeholder cursor" when the snippet expands, write some content in this placeholder, then move to the next "placeholder cursor" by hitting on the tab key. – politicus Dec 16 '17 at 0:51
  • Looking for one too. I am using YASnippets in Emacs. They are awesome! – Daniel Hitzel Jan 27 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.