Is there an auto-close curly brackets plugin for the Geany IDE?
Asked Answered
S

5

13

Geany is the closest thing I can find to the perfect web development IDE. However, I can't find a way to automatically close curly brackets ({).

For example, typing:

function test()
{

..and pressing RETURN should cause this to happen:

function test()
{
    // cursor ends up here (indented by 1 tab)
}

Is there anything that can make Geany do that?

Spit answered 17/10, 2012 at 0:8 Comment(0)
V
5

This is a native feature of Geany,

Go to Preferences, then Completions, down there you can choose which one you want to auto close.

Check here for screenshots

Vigesimal answered 20/10, 2012 at 0:42 Comment(4)
I was already aware of that. However, it doesn't work on the Windows platform. Believe me I've tried.Spit
Then have you submitted the bug? Submit the bug, likely if they don't offer a patch they will at least give you a workaround, sorry I didn't help.Vigesimal
This has been known and unfixed for a very long time. The only workaround is for someone to make a plugin which is the reason I made this post.Spit
This way I get {\n\t%cursor%}. I want get {\n\t%cursor%\n}, how can I do that?Circumscissile
C
1

You make something else: If you want, open https://plugins.geany.org/autoclose.html and see "autoclose" plugin. You can install with : sudo apt-get install geany-plugins-autoclose and It is all

Confidential answered 7/10, 2018 at 11:50 Comment(0)
C
0

That isn't full answer to your question, but may be helpful.

I have Geany not in english, I make translations of menu's fields on my own.

Geany has a feature: when you type special text and press Tab, the text is going to be replaced with another text.

It works by default for if, else, for, while, do, switch and try.

Configuration of this feature is in [Tools]/[Config files]/[snippets.conf].
After doing some changes, save file and click [Tools]/[Reload configuration].

I added two lines to section C++:

class=class %cursor%%block%;\n
struct=struct %cursor%%block%;\n

With block=\s{\n\t%cursor%\n}

It doesn't let you press { Enter or { Tab to get

{
    //cursor
}

because {=anything is ignored, I don't know why.

What you can do? You can have some another text, replaced using {\n\t%cursor%\n}, or define keybinding inserting it.

Circumscissile answered 31/8, 2014 at 21:33 Comment(0)
B
0

Geany can have user defined snippets. It is possible to open snippet configuration file from menu.

Tools ->
        Configuration files ->
                               snippets.conf

Go to the language block where you want to add that feature. For example:

  [C]
  if=if (%cursor%)%block_cursor%
  else=else%block_cursor%
  for=for (i = 0; i < %cursor%; i++)%block_cursor%
  while=while (%cursor%)%block_cursor%
  do=do\n{\n\t%cursor%\n} while (%cursor%)\n%cursor%
  switch=switch (%cursor%)%brace_open%case %cursor%:\n\t\t%cursor%\n\t\tbreak;\n\tdefault:\n\t\t%cursor%\n%brace_close%%cursor%

At first it can be thought that the problem can be fixed just with adding this line

 {=%\n{\n\t%cursor%\n}%

But Geany does not accept that when snippet is one non alphabetic character. It will work for any other alphabetic character like this

 b=%\n{\n\t%cursor%\n}% or  bl=%\n{\n\t%cursor%\n}%

However I dont think it is what you want. The real solution you can find from geanys menu.

 Edit
      ->Preferences
                    ->Editor
                            ->Completions 

Tick the Auto-close quotes and brackets then click on apply and saveenter image description here

Blinking answered 15/7, 2015 at 8:52 Comment(0)
C
0

The Auto-close doesn't work if we place brackets inside another pair of brackets. For example, the inner bracket doesn't auto-close.{{|}

However, we can use the following snippet to create a block.

{={\n\t%cursor%\n}

But in order to use this snippet, we first have to include '{' char in our wordchars set by changing the below line in snippets.conf file.

wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789{
Correlate answered 26/8, 2021 at 1:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.