jrowny / brackets-snippets

A brackets snippets extension
http://www.github.com/adobe/brackets
Other
129 stars 42 forks source link

Feature request : expand with "tab" #24

Open raphaelgoetter opened 11 years ago

raphaelgoetter commented 11 years ago

Hello,

"Ctrl-Alt-V" to insert the snippet is a bit painful and long. Would it be possible to expand trigger with tab key, as Emmet does for example ?

ghost commented 10 years ago

(I see it's an old post, but I wanted to reply so everybody who read this'll know)

You can change that keybind to whatever you want in "jrowny.brackets.snippets/main.js"

//add the keybinding KeyBindingManager.addBinding(SNIPPET_EXECUTE, "Ctrl-Alt-V");

But I agree with you that it should be good if it could work as Emmet, because now if you change keybind "Ctrl-Alt-V" to "Tab" with this extension and then you want to use regular space with "Tab" it deletes everything on that line. Issue here: https://github.com/jrowny/brackets-snippets/issues/30

zaggino commented 10 years ago

This is now solved and you can set your own key in settings dialog - https://github.com/jrowny/brackets-snippets/pull/34 Error with deleting everything on the line is solved in https://github.com/jrowny/brackets-snippets/pull/35

raphaelgoetter commented 10 years ago

Hello,

I changed my settings to "Tab" key, but doesn't work if Emmet extension is installed :/

zaggino commented 10 years ago

emmet uses tab for something else ... you can't have multiple bindings on one key currently https://github.com/emmetio/brackets-emmet/blob/master/keymap.json

raphaelgoetter commented 10 years ago

Yep, that's the problem.

I'd love to expand my snippets as I use Emmet, with Tab key :/

zaggino commented 10 years ago

What exactly does the emmet extension do on tab key?

raphaelgoetter commented 10 years ago

It expands abbreviations, it's his main function.

Ex. div>p + tab -->

<div>
    <p></p>
</div>
zaggino commented 10 years ago

Well one expands abbreviations, one snippets - it'd be quite hard to execute both at the same time, wasn't it?

raphaelgoetter commented 10 years ago

We do not execute both at the same time.

Emmet is made to extend the most common abbreviations: HTML elements, CSS properties, vendor prefixes, or many shortcuts such as w20width: 20px; etc..

On the other hand, snippets of code does not seem at all incompatible.

For example, one of my snippets is navi

<nav role="navigation" id="navigation"> 
     <ul> 
        <li> <a href="#"> </ a> </ li> 
        <li> <a href="#"> </ a> </ li> 
        <li> <a href="#"> </ a> </ li> 
        <li> <a href="#"> </ a> </ li> 
        <li> <a href="#"> </ a> </ li> 
    </ ul> 
</ nav> 

Why would it be uncompatible?

zaggino commented 10 years ago

@raphaelgoetter I'll try to open an issue with main Brackets core when I'll have time. Currently implementing this feature you want is not possible.

alexvf commented 10 years ago

Hi raphaelgoetter, You asked:

Why would it be uncompatible?

It would be incompatible because Emmet creates "code" with all strings. Even the ones it does not know. If you type "navi" and hit the tab key, you will get: <navi></navi>

How would brackets know what was really the plugin you were expecting to execute the command (Emmet or Snippets)?

I don't think it is possible to use both with the same key combination.