howl-editor / howl

The Howl Editor
http://howl.io
Other
712 stars 68 forks source link

code snippets/abbreviations #500

Open dzklaim opened 5 years ago

dzklaim commented 5 years ago

According to the documentation: "Code blocks are code snippets that are automatically inserted as you type."

It seems that we should be able to use this feature to create abbreviations/snippets like in emacs/vim. How to do that?

Thank you for all in the work in Howl :)

shalabhc commented 5 years ago

Currently code blocks are specified by the mode. E.g. see https://github.com/howl-editor/howl/blob/master/bundles/lua/lua_mode.moon#L42

It's not very advanced at the moment, e.g. there are no placeholders. This would be nice to have though. What features specifically are you looking for?

dzklaim commented 5 years ago

I have been writing latex lately. I would like to write something like "bgit" and the editor would expand it to

\begin{itemize}
\item [cursor]
\end{itemize}

and other simpler stuff like entering "hw" and howl should expand it to "Hello World!"

nilnor commented 5 years ago

As @shalabhc said the code blocks are rather simple and tied to modes. I'd like to see snippets functionality as well, but I think that needs to be something new, more advanced. For instance, things such as the [cursor] macro you give as an example should work (and other placeholders as well). I've been thinking that expansion could both be available as a specific command, but also tied into completions. For instance with autocompletion enabled for the example above you'd get something like bgit [macro] as a completion option and pressing enter then would expand it.

dzklaim commented 5 years ago

sounds great, thanks :)

refi64 commented 5 years ago

expansion could both be available as a specific command, but also tied into completions.

Worth noting that GNOME Builder does this. Snippets appear in the autocomplete drop-down, and when you select it, it inserts the text with the cursor automatically jumping to the first placeholder within, then to the next when you Tab and so forth until all are filled.