What command(s) is/are best for moving the cursor to the beginning of the document? (ie 1st character of line 1). I would have thought that these two python lines would do the job:
But not, it moves the cursor to the begining of the current line. I do not see in the documentation what argument should receive doc.get_pos_at_line for the first line.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you, it works with 0. Where is this value documented? Is it the best way to do it? E.g. Ctrl-Home makes the same effect. Is there a command binding to this key combination?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What command(s) is/are best for moving the cursor to the beginning of the document? (ie 1st character of line 1). I would have thought that these two python lines would do the job:
doc_begin = doc.get_pos_at_line(1)
doc.set_cursor_pos(doc_begin)
But not, it moves the cursor to the begining of the current line. I do not see in the documentation what argument should receive doc.get_pos_at_line for the first line.
If it's python, then the first line is 0. Your code does work for me (with 0).
Thank you, it works with 0. Where is this value documented? Is it the best way to do it? E.g. Ctrl-Home makes the same effect. Is there a command binding to this key combination?
Now it's documented. It's just a common convention: first item is at the index of 0 in python.
set_cursor_pos() is the right way to do it.