I am new to Komodo and am just learning to use the editor. One of the most tedious activities is getting the indentation for the various commands. When I tried to utilize the Key Bindings to provide a short-cut for creating the indentation for the structure of the code, the Key Bindings section would not recognize any key combination for doing indentations. I found that many of the functions would not allow any key combinations. Is there a simple way to create indentations as the word processors have done with their outlining feature?
Hi @rich, Thanks for posting.
I’m having a little trouble following what you want from Komodo but I’m going to guess for now. If I’m wrong, I’ll need you to explain the exact use case that you expect Komodo to fulfill.
When you’re writing code in Komodo in most cases it will know when you need indenting and it will add it for you.
def myfunction(): # Komodo will add an indent when I press enter here print("I really like pizza")# Komodo magically added 4 spaces of indenting for me
The preference settings to change how Komodo adds indents can be found under Edit menu (Komodo on OSX) > Preferences > Indenting.
The indenting preference hierarchy can be a little overwhelming so i recommend you read this post to make sure you understand the various levels that you can set the preferences at: https://community.activestate.com/taxonomy/term/559
So…Did that help? There is no key binding needed unless I’m totally misunderstanding you.
Maybe he’s meaning
Python Reindent formatting feature? Like pressing
Ctrl+Shift+R to reindent the current code… I also cannot find any way to set a key binding for this thing.
UPD: in case you want to re-indent your Python3 code by shortcut you can set
Editor: Format Code or Text to
Ctrl+Shift+R, then go to
Formatters, right click on
Python reindent and choose
Edit, then change the language to
Python3 instead of
Python and click OK. After that you will able to press
Ctrl+Shift+R to re-indent your code
Thank you for your responses. I guess I was just looking for a key short cut for indenting. I will work with the software some more. In general, I wondered why under Preferences -key bindings, I could not set a key combination for most of the actions listed. I just get a message that each combination is not available.
That would be an issue then. Can you post a screenshot with this error?
Perhaps you’re using the incorrect term? Do you mean formatting your document to correct ALL of the indenting in the file?
If you’re trying to format your code then you can right click your document > Format > Choose a formatter (reindent as @defman points out). This is only in IDE.
I believe there is an Add-on or a macro out there to perform this in Edit.
Yes, Carey, I do not have IDE at this point, since I am just starting to use the Editor and learn the various programming tools. I will play with it further. I guess I was equating the Key Bindings in Preferences with the Key Stroke short-cuts in a word processor. I was trying to set key strokes in the Key Bindings section of the Preferences to do short-cuts. When I typed in a key-stroke (ie. Option-y) for a new shortcut, I get the message that the combination is not available. I try a number of other key stroke combinations, with the same message. These combinations don’t seem to be used for anything else. Perhaps the Key Bindings are not fully available for the Edit version of the software or perhaps I don’t understand how to use them. Again, I was just trying to create a key-stroke that would automatically indent my code to make it more readible without having to do each indentation with the tab key.
Auto-indent is a IDE feature, you won’t see it in Edit without an add-on or a macro. And now I understand what error you’re getting every time you want to set
Option+Y keybiding for a command. @careyh to reproduce it, try to set the
Win+Y keybinding for a command, then you’ll get
This key combination is not available.
@rich, if you’re trying to actually use key bindings you used in word processor then you’re not going to have much luck. I’m not sure why you would think that they would map over.
If you would like to know what keybindings are available look under Help > List Key Bindings.
As it sounds like you’re new to this I’d like to provide a little constructive criticism here with a couple points to follow when asking questions in forums:
- Provide specific details of your use case. For example:
There is no feature in Komodo called “short-cuts” and that’s a very generic term so please explain what you want to happen when you use the key binding.
What functionality did you expect Komodo to do? Why were you trying random key-strokes? Are they from Word Processor? Why are you expecting short cut keys from a different program to work in Komodo?
- If you’re getting error messages send them:
What message? Copy and paste the entire error message in your forum post. I think @Defman did get it but he’s still only guessing.
This is what we wanted. This is the succinct comment that explains exactly what you wanted. Looking back I now see it’s kind of in your first message but the terms you used maybe didn’t translate.
To close this thread off, as it doesn’t need more discussion, you are looking for code formatting, @rich. This feature does not exist in free Komodo Edit but is in licensed Komodo IDE. For edit there are macro’s out there to use. You can set keybindings for those in the macro Options.
That should answer your question. If you have further questions about Komodo, please don’t hesitate to ask but make sure you start a new post.
5 posts were split to a new topic: Error when setting any keybinding