Display current cursor position from top of file

Is there a way to display the current cursor position in Komodo Edit? I frequently work with binary files and need to update pointers after edits. It would be great to have this displayed with the line and column info or assign a macro to a hot key to display this elsewhere. Any ideas? I am new to Komodo and love it.

The current line and cursor position (as well as the current selection) are displayed at the bottom right of Komodo, in the status bar.

Thanks for the reply.

For clarification - I need the position from the top of the file not just the current line and column. My editor is only displaying line and column values and I would like to get it to display the absolute position from the top of the file. If I select everything from the top of the file to the position I would like to know, the editor will display the number of selected characters “ch”. This method works for very small files but when the file is a few thousand lines it is a real pain in the …

I was able to get something close as a Macro assigned to a key.

var out = "echo " + komodo.editor.currentPos;
if (komodo.view && komodo.view.scintilla) {
  ko.run.runEncodedCommand(window, out);

However, the files I am working with contain some 2-byte characters and the function returns the number of bytes not the number of characters. I need the number of characters.

Any other Ideas???

Hmm, from a bit of googling the following 2 topics seem relevant:

Based on that I’m guessing it is not possible, at least not without getting creative with the scintilla API.

I think the simplest solution will involve use of a Komodo macro:

var sm = ko.views.manager.currentView.scimoz;
// Get character length:
var msg = "Length: " + sm.getTextRange(0, sm.currentPos).length;
// Get byte length:
//var msg = "Length: " + sm.currentPos;

// Use statusbar to show where you are:
ko.statusBar.AddMessage(msg, "find", 5000, true);
1 Like

Thanks toddw, that worked perfectly.

I combined your code with my previous so the “Length” displays in the Command Output window. I wanted to keep it displayed as I need to be able to move around within the file and reference the value several times.

Thanks again for everyone’s help!

var sm = ko.views.manager.currentView.scimoz
var msg = "Echo Position: " + sm.getTextRange(0,sm.currentPos).length;
if (komodo.view && komodo.view.scintilla) {
  ko.run.runEncodedCommand(window, msg);
1 Like

Hey JustMe,

I wrote up a macro that will update your statusbar Ln:Col: section with either the current byte position or character position of your cursor in the doc. I’ve blogged about it here: Add byte or char pos to statusbar. The installation instructions are at the bottom of the blog.

I hope that’s useful to you.

  • Carey