From f2d8214879b056edeedf6cce314e9903d7e704e0 Mon Sep 17 00:00:00 2001 From: "Jesper K. Pedersen" Date: Wed, 8 May 2013 10:57:36 +0200 Subject: added example comment-out-current-function.qs Change-Id: I9cfce1e924ea172cd23de2f1988e9d0690753c53 Reviewed-by: Nicolas Arnaud-Cormos --- examples/comment-out-current-function.qs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 examples/comment-out-current-function.qs diff --git a/examples/comment-out-current-function.qs b/examples/comment-out-current-function.qs new file mode 100644 index 0000000..4cb712f --- /dev/null +++ b/examples/comment-out-current-function.qs @@ -0,0 +1,17 @@ +// This simple example shows how to use mark to remember positions +// and currentFunction to retrieve information about the function. + +var editor = editors.current() +var start = editor.createMark() + +editor.gotoPosition(editor.currentFunction.start) + +editor.find("{") +var startOfFunction = editor.position() +editor.gotoBlockEnd() +editor.gotoLineStart(); +editor.insert("*/\n") +editor.gotoPosition(startOfFunction) +editor.insert("\n/*") + +editor.gotoPosition(start) -- cgit v1.2.3