Sublime text creating a new look

Just take a look at Sublime Text 2 to expand it. I pulled out the console using CTRL 'and tried to do:

>>> x = window.new_file() >>> x <sublime.View object at 0x00000000032EBA70> >>> x.insert(0,"Hello") 

A new window does open, but my insert doesn't seem to work:

 Traceback (most recent call last): File "<string>", line 1, in <module> Boost.Python.ArgumentError: Python argument types in View.insert(View, int, str) did not match C++ signature: insert(class SP<class TextBufferView>, class SP<class Edit>, __int64, class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >) 

Any idea what I'm doing wrong?

+4
source share
2 answers

Calling .new_file() returned a View object, so the .insert() method takes 3 arguments:

insert(edit, point, string)
int
Inserts the specified string into the buffer with the specified point . Returns the number of characters inserted: this can be different if tabs are converted to spaces in the current buffer.

See the sublime.View API link.

The edit parameter is for a sublime.Edit object; you need to call view.begin_edit() to create it, and then call view.end_edit(edit) to demonstrate canceled editing:

 edit = x.begin_edit() x.insert(edit, 0, 'Hello') x.end_edit(edit) 

The edit object is a marker for editing a group into something that can be undone in one step.

+6
source
 >>> x = window.new_file() >>> e = x.begin_edit() >>> x.insert(e,0,"Hello") 5 >>> x.end_edit(e) 
+1
source

All Articles