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?

xLite
  • 1,441
  • 3
  • 15
  • 28

5 Answers5

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

Valor
  • 1,305
  • 8
  • 13
  • I was already aware of that. However, it doesn't work on the Windows platform. Believe me I've tried. – xLite Oct 20 '12 at 03:18
  • 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. – Valor Oct 20 '12 at 04:10
  • 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. – xLite Oct 20 '12 at 18:24
  • This way I get `{\n\t%cursor%}`. I want get `{\n\t%cursor%\n}`, how can I do that? – GingerPlusPlus Aug 31 '14 at 14:26
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

Ivan DImitrov
  • 19
  • 1
  • 3
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.

GingerPlusPlus
  • 5,336
  • 1
  • 29
  • 52
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

MIRMIX
  • 1,052
  • 2
  • 14
  • 40
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{