How do I use abbreviations?

The manual at http://docs.activestate.com/komodo/11/manual/abbreviations.html says “The Abbreviations function lets you quickly insert code snippets by entering their name in the editor buffer followed by Ctrl+T.”

Ctrl+T opens a new tab in the Vi keybindings that I’m using, and when I looked for Ctrl+T in Default.kkf to see what Ctrl+T was bound to by default… it’s cmd_newTab there as well. I don’t see anything with an obvious name like ‘expand’ or ‘abbrev’, or ‘snippet’.

@jfondren you’re searching for the “Insert Abbreviation Snippet by name” key binding.
You can set this in you’re preferences (preferences > key bindings > Insert Abbreviation Snippet by name).

OK. I set that to Ctrl-\ , saving it in a new key binding scheme.

I then opened a new file and typed ‘main’ (sans quotes) and hit that key, and got the error “No ‘main’ abbreviation was found.” I see a ‘main’ under Abbreviations/General.

I then set the file language to Perl and typed ‘hash’ and then hit Ctrl-, and got the error “No ‘hash’ abbreviation was found.”

Are those not abbreviations? Or are those not their real names?

The Abbreviations should work as you described.
If I create a new Perl file or create a new file (php) and set the language to perl:

If I than type hash and hit my Ctrl + \ shortcut, the hash abbreviation is inserted:

The only criteria you have to meet, is that the a abbreviation language should match the sub language of the file you’re in ( for example a php file can contain html, php, or javascript ).
To test in witch sub language you are, you can run the following snippet in you’re console.

ko.views.manager.currentView.koDoc.subLanguage

1 Like

It should, but it doesn’t. I am always told that the abbreviation I want to use doesn’t exist, by name. Some random preference I’ve changed may have broken it, because other than changing some global preferences and creating a few projects I haven’t done much with this 5-day installation. I was using VI keybindings, but it fails as well when I add the key to Default.

So this is a bug rather than my doing things wrong. Is there a way I can package up what’s distinct about by installation, to include it in a bug report?

Hi, you can try restarting in Safe Mode (Help > Troubleshooting > Restart in Safe Mode) in order to determine whether or not you altered “some random preference” that affects abbreviation insertion.

@jfrondren could you also share your “main” abbreviation, so we can see if it works on our installs?

Thanks

There is no main Abbreviation in the default install so unless you added it and enabled Auto-Abbreviation option in it then it won’t work.

The hash abbreviation in the toolbox folder Abbreviations > Perl has the Auto-Abbreviation turned off, as do most if not all of the abbreviations that come with Komodo. We ended up doing this as many people complain about Komodo injecting random code into their files constantly which is a reasonable complaint. Long story short, you won’t be able to trigger that abbreviation unless you right click it > Properties: Enable Auto-Abbrivation.

Apologize for the outdated docs. That’s frustrating for you. I thought I had fixed that ages ago. I’ll make sure that gets up dated. Also note that you can trigger Auto-Abbreviation using Tab or any other key you specify under Edit menu > Preferences > Editor > Smart Editing: Auto-Abbreviations.

  • Carey

I also have a main abbreviation in my default Abbreviations folder:

Tried to trigger it using the “Insert Abbreviation Snippet by name” but I’m unable to.
It also has no language defined:

The code:

// komodo tool: main
// =================
// auto_abbreviation: false
// indent_relative: false
// set_selection: false
// treat_as_ejs: false
// type: snippet
// version: 1.1.5
// =================
#!/bin/env [[%tabstop:bash]]
# [[%tabstop:scriptname]]!@#_currentPos!@#_anchor

@careyh he doesn’t want auto-abbreviation, he wants “Ctrl+” to insert the abbreviation.

To add more information about the main snippet.
I think I might have imported it somehow, did a global search in my profile folder for the main.ktf snippet and found these results:

Noticed there are some pointing to a custom folder of mine ‘php-everywhere’ and the ‘php_new_tags/php-everywhere’.
These are still a left over from a older folder structure I imported, I copied over the old “Abbreviations” folder.
And customized it to my own needs.

But noticed the “General” folder is still inside them, with the same main.ktf snippet.
How the “General” folder ended up in my main “Abbreviations” folder I don’t know.

The General folder is a subfolder of Abbreviations. I’m not sure I understand your confusion.

I thought it should not be there.

Here: http://manda.host/kabbrev.webm

It’s a three-minute video that’s 3MB in size, showing:

  1. my installing Komodo IDE onto Linux from the tarball
  2. Komodo starting up without finding any existing settings
  3. A demonstration that the General/main and Perl/hash abbreviations both work when you click on them, and that these abbreviations are supplied with Komodo IDE itself.
  4. A demonstration that neither can be invoked via the Insert Abbreviation Snippet by Name hotkey that is defined, which claims that ‘main’ and ‘hash’ do not exist, the latter not even after the file type is switched to Perl.

@jfondren you hit yourself a bug.
Got it reproduced using the latest Edit:

What happened here, is that it only had Edit 8.5 installed.
It copied over the Samples 8.5 folder from my previous install:

If I know try to insert a snippet by name, it fails.
If I look at the snippet, the language is not set correctly:

This is causing the “Insert Abbreviation Snippet by name” command to fail.
As a work around you will have to set the language manually.
Then the “Insert Abbreviation Snippet by name” will work correctly.

@careyh I was testing out the following work around I think should work, but it doesn’t.

Download the latest Komodo Edit Source from here
Download the zip and unzip it:

Remove the old samples folder.
And use the import function to import the new Abbreviations folder from you’re latest Komodo Edit download:

After the import the the structure looks good:

Only it did not set the languages correctly, causing the “Insert Abbreviation Snippet by name” to still fail.

1 Like

Nice digging @babobski! Can you file a bug for this? Thanks!

done!