Welcome, guest | Sign In | My Account | Store | Cart

A Komodo Python macro that can be used to select the current word under the cursor position.

JavaScript version here: Recipe 577007.

Python, 7 lines
1
2
3
4
5
6
7
import komodo

scimoz = komodo.editor
word_start = scimoz.wordStartPosition(scimoz.currentPos, True)
word_end = scimoz.wordEndPosition(scimoz.currentPos, True)
scimoz.anchor = word_start
scimoz.currentPos = word_end

2 comments

Shaun 14 years, 2 months ago  # | flag

This works as well

import komodo word = komodo.getWordUnderCursor()

Im having a more difficult time finding how to get the selected text...

Use "scimoz.selText" to get the selected text. More scimoz functions can be found at: http://docs.activestate.com/komodo/5.2/macroapi.html#macroapi_scimoz

Created by Todd Whiteman on Thu, 14 Jan 2010 (MIT)
Python recipes (4591)
Todd Whiteman's recipes (13)

Required Modules

Other Information and Tasks