Logo-small

4.2.2 Smart Characters Autocompletion

In Pharo there is a particular feature when editing code that may be irritating for newcomers since it is not widely used: the smart characters autocomepltion.

What we call smart characters? Those characters that usually are in pairs and we surround or separate code with them. Examples in Pharo are (between simple quotes) '[' and ']', '(' and ')', '{' and '}', '"', etc.

If you have already been coding in Pharo you may have notice that sometimes when you type the open character of the pair, the other one is autocompleted. But how this exactly works ?

  • When you type the LEFT (open) character of the pair, for example: '{' , '[' , '(' , '"' , etc .... it will AUTOMATICALLY open the other pair and put it next to it (on the right). This is because this is usually the case: if you type (open) the left one, you will probably need to type (close) right one.
  • When you type the RIGHT side, it only writes the right side.
  • Only and only if the immediate thing you do after opening a smart character, is to remove a character (backspace), then both of them are removed.

So a common question is, how can I type only the left character ? The easiest way to do this, is to type the smart character and immediately after, press "DEL" key. This will remove the right one and you will keep only the left one.

But why Pharo consider this a feature?

And this is because the way to code and type in Pharo is different from other IDEs. The best and expected way to type in Pharo is selecting the text first and then surround it with a pair of brackets, quotes, etc just by typing the open character of the pair.

You may feel it is annoying at the beginning, but it gets really comfortable in little time. Selecting text and "surround" it with a pair of brackets/quotes/etc. is just great. This feature that is bothering you really helps to type quicker and cleaner once you get used to it.

I promise after a couple of weeks you will be surrounding text first and then type the open character, everywhere: in your mails, in your text editor, etc.

How to disable it?

Are you really sure you want to do that? Give it a try! Ok...to disable it, in Pharo 1.0 just evaluate:

 ECPreferences smartCharacters: false

In Pharo 1.1 go disable the option from: "System -> Preference Browser -> category Browsing -> ecompletionSmartCharacters".

User Contributed Notes

dougedmunds (15 February 2011, 8:29 am)

If World Menu ->System doesn't show Preference Browser, you can open it from a workspace by typing

PreferenceBrowser open.

 

To add it to the menu, modify PreferenceBrowser>>menuCommandOn:

by adding <worldMenu> to it.

 

menuCommandOn: aBuilder

<worldMenu>

(aBuilder item: #PreferenceBrowser)

label: 'Preference browser';

action: [self open];

parent: #System;

icon: self taskbarIcon

Add a Note

Licensed under Creative Commons BY-NC-SA | Published using Pier |