A dynamically generated small grammar is used for text editing using voice commands in a hand-held electronic device where memory requirements do not allow a large grammar to be used. However, the text is dictated using a large grammar, which can reside in the electronic device or in a remote site. When an editing session begins, words in the dictated text are added to the small grammar. As such, words to be deleted or replaced can be located, for example. When a voice command calls for a text-modifying word, the text-modifying word is obtained from the small grammar if possible. Otherwise it is obtained from the large grammar. During the editing session, as more text-modifying words are used to modify the text, these words are also added to the small grammar. At the end of the editing session, the dynamically generated part of the small grammar is removed.