Add words for autocompletion feature (for both console and editor)
Hi, very happy to know omz is come back!
I've a question related to autocompletion.
Which is the easiest way to add a list of words/commands in autocompletion database of Pythonista without writing a library and importing it?
I know that if user writes a library with some definitions and import all function, definitions, classes, etc.. Pythonista can recognize the name of the definitions and user can write the names with autocompletion support (both in console and editor). I ask if it is possible without writing a library, but by adding some words in autocompletion database, if it exists.
Example of use: I'd like to save often-used words in the database and while typing in the editor, Pythonista helps me to choose that words, that begin with the letters I have typed in the editor or console, from the database, to speed up the writing.
cvp last edited by
I know that if user writes a library with some definitions and import all function, definitions, classes, etc.. Pythonista can recognize the name of the definitions and user can write the names with autocompletion support (both in console and editor)
How do you that?
cvp last edited by
@Matteo You could use Pythonista snippets, for editor, not for console
def test(): None
and I execute once mylibs.py, I can select word 'test' for autocompletion, in editor and in console, until I reset Pythonista environment (RAM).
About snippets I don't know what it is. Can you tell me something about it?
@cvp Thank you for hint about snippet, never used it since I have Pythonista. I will try to use it for adding words.
About your last image link, how can I add words without snippet? I think it could be what I need.
Edit: sorry, I've seen now your link about Define, ok, solved. Ignore my previous question.
@Matteo That does not solve the usage in console ...
@cvp Yeah, you are right. Also in editor when I try to select an empty snipped just created, Pythonista doesn't insert the word in editor, I can see the word but it is not added in editor, tried just now (v3.1, 301016).
For usage also in console the only way is to write a py file with a list of None definitions, but I think there isna better and simpler way.
I must perform some experiments with snippets.
Again thank you for help.
I can see the word but it is not added in editor
You are right, sorry, I did not test it... 😭
Then you have to put the same word as snippet, I guess
Tested, that works but needs to type twice the word in the settings
@cvp ok, it works now.
Thank you cvp
Ps: do you know a way to change programmatically all snippets in order to add some special character to all snippets, for example?
do you know a way to change programmatically all snippets in order to add some special character to all snippets, for example?
No idea where there are stored...
@cvp ok, suppose I have a lot of snippets created by hand that start with a specific word, for example 'scipy.xxx' where 'xxx' are some words. How can I change word 'scipy' in 'basic.scipy' (for example) for all snippets of the form 'scipy.xxx'? It is just to add, modifiy, rename, change content of snippets programmatically to be faster than changing them by hand one by one.
If snippets are saved in a file , maybe it could be easier to change content of the file based on certain rules (with python regex for example).
@Matteo understood but no idea how and where are stored these snippets. And don't forget that even if you find the name of the eventual file, Pythonista files are often (always) write protected
@cvp maybe that file is writable by user, if user can add , delete, modify by hand snippets. But as you said if user can't see that file in visible directories, probably it is write protected. The best solution for me that works also for console remains the execution of a py file at Pythonista startup with a series of definition like:
def scipy.x1: None def scipy.x2: None ...
Thank you cvp for snippets solution, I've seen it is powerful with common pieces of code user uses often.