Heidisql: auto-capitalizing keywords like SELECT, FROM, etc.

Created on 31 Aug 2018  路  10Comments  路  Source: HeidiSQL/HeidiSQL

Steps to reproduce this issue

  1. Step 1; I start to type "select * from my_table where id = 1;" in the query editor.

Current behavior

I can see exactly what I typed:
"select * from my_table where id = 1;"

Expected behavior

I would like to see capitalised keywords:
"SELECT * FROM my_table WHERE id = 1;"

Possible solution

Under Tools -> Preferences -> SQL, where I can set the colors and other attributes the of individual content categories, I would like to have a checkbox "[X] Capitalized". I would love to turn it on for Reserver Words.

Environment

Version 9.5.0.5277 (64 Bit)
Compiled on: 2018-04-19 05:52:03
Environment: Windows v6.1

feature

Most helpful comment

I would like to request a little bit more intelligence too

Typing

select t.name from mytable t

produces

SELECT t.NAME FROM mytable t

But I expect

SELECT t.name FROM mytable t

Essentially, coulmn names _can_ be reserved words but shouldn't be automatically capaitalized.

All 10 comments

That is what the "Auto reformat" feature is meant for.
Just click the button on the main toolbar with the white page and a paintbrush on it.

Thanks for the quick asnwer. :)

I don't think they are the same.

  1. My proposal would capitalise "select" right after pressing the last character ("t") while the toolbar button requires deliberate activity from my side

  2. The toolbar changes the indentation as well which I would hate. I know why I indented my query in the way how I did and I don't want any software to re-indent it, unless I explicitely ask for it.

Yes, I noticed your wish is different, only I don't want to implement similar things two times.

There is a second way to accomplish that: start typing "sel", press Ctrl+Space, which should offer the completion proposal with the SELECT keyword, then press Enter to overtake it.

I understand this but I still think it would be a very useful feature because Ctrl+Space is much less convenient.

For example, when I type "from" then Ctrl+Space offers three options:

  • FROM_DAYS(N)
  • FROM_UNIXTIME
  • FROM
    So, after "from", I still need 4 key presses (Ctrl+Space, Cursor Down, Cursor Down and Enter) or 3 if I am a power user (and I know Cursor Up replaces the two Cursor Downs) to capitalise it. By contrast, an auto-capitalize function would capitalise "FROM" automatically, right after I finish the word.

Unfortunately I cannot use Heidi at my workplace and I have to use SequelPro for Mac which does this autoformat thing. I don't reallt like SequelPro but this is a feature of it I really love and would love it in Heidi as well.

UPDATE: just one more tought. There are three different things but they have different purposes as well:

  • syntax highlighting/capitalizing: leaves every character at their position, just changes their appearance
  • autoformat: re-indents the code but does not change the meaning of the query
  • suggestions (Ctrl+Space): it actually changes the query, it builds it.

So, my suggestion would not implement the same functionality that we have somewhere else. It is a new feature.

Makes sense now!

I have just pushed some code extension which now by default transforms the previous reserved word, data type or function to uppercase. Users can disable this feature, in Preferences > SQL > "Auto uppercase..."

Please update and test.

Already found some bugs, which should be fixed in the upcoming Heidi build. Please retest if not done already.

Oh, great news, thank. :)

I installed Version 9.5.0.5293 (64 Bit) and works nice. Thanks. :)

However, it is not exactly what I asked for. I thought you implement it more similarly to the syntax highlighting. I expected a checkbox where the Bold and the Itcalic checkboxes are. That implementation whould make it possible for the user to capitalize/not capitalize function names, keywords, tablenames, independently from each other. I think it would be more felixible.

There is one more think. It is a bit strange that I type "select" and right after "t" the color is changing but the capitalization happens only one character later, when the space also is pressed. Is this indented? Why does it indicate to be a keyword by color change earlier than it indicates the same thing by capitalizing?

I would like to request a little bit more intelligence too

Typing

select t.name from mytable t

produces

SELECT t.NAME FROM mytable t

But I expect

SELECT t.name FROM mytable t

Essentially, coulmn names _can_ be reserved words but shouldn't be automatically capaitalized.

problem is actual
https://media.giphy.com/media/7XuzDMd2NMc2uX1cSB/giphy.gif

Version 9.5.0.5444 (64 Bit)

Was this page helpful?
0 / 5 - 0 ratings