Menu

beginning of the document

2014-03-18
2014-03-20
  • Alejandro Jakubi

    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.

     
  • Yevgen Muntyan

    Yevgen Muntyan - 2014-03-18

    If it's python, then the first line is 0. Your code does work for me (with 0).

     
    • Alejandro Jakubi

      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?

       
  • Yevgen Muntyan

    Yevgen Muntyan - 2014-03-20

    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.

     

Log in to post a comment.

MongoDB Logo MongoDB