in Education by
I'd like to create a keyboard shortcut (such as CTRL+T) that automatically moves the cursor to the line after the occurence of a fixed text, such as &todo. Example: foo bar &todo fix bug #783 blah blah2 Pressing CTRL+T would automatically move the cursor to the line beginning with fix .... Currently I'm doing it like this: CTRL F enter &todo, ENTER ESCAPE (closes the Search bottom panel) HOME DOWN ARROW (moves to next line) but this requires too many actions. How to do that in a single key shortcut? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
The best solution is it use a plugin to do that. The plugin below does what you require. It will find the next occurrence of pattern (i.e. the &todo marker) below the current cursor position, move the cursor to the line below it, and centre that position in the window. If the pattern is not found below the current cursor position it will search again from the top of the buffer providing a wrap around feature. Copy and paste the following Python code into a buffer and save it in your Sublime Text config User folder as GoToPattern.py. import sublime import sublime_plugin class GotoPatternCommand(sublime_plugin.TextCommand): def run(self, edit, pattern): sels = self.view.sel() # Optional flags; see API. flags = sublime.LITERAL | sublime.IGNORECASE start_pos = sels[0].end() if len(sels) > 0 else 0 find_pos = self.view.find(pattern, start_pos, flags) if not find_pos and start_pos > 0: # Begin search again at the top of the buffer; wrap around # feature, i.e. do not stop the search at the buffer's end. find_pos = self.view.find(pattern, 0, flags) if not find_pos: sublime.status_message("'{}' not found".format(pattern)) return sels.clear() sels.add(find_pos.begin()) self.view.show_at_center(find_pos.begin()) row, col = self.view.rowcol(find_pos.begin()) self.view.run_command("goto_line", {"line": row + 2}) # Uncomment for: cursor to the end of the line. # self.view.run_command("move_to", {"to": "eol"}) Add key bindings: // The pattern arg, i.e. "&todo", can be changed to anything you want // and other key bindings can also be added to use different patterns. {"keys": ["???"], "command": "goto_pattern", "args": {"pattern": "&todo"}} Add a Command Palette entry to Default.sublime-commands if you want: {"caption": "GoToPattern: &todo", "command": "goto_pattern", "args": {"pattern": "&todo"}}, These links may be useful to you ST v. 2 API and ST v. 3 API. P.S. Did you know that Sublime Text has bookmarks? [Just in case you didn't.]

Related questions

0 votes
    When we realize a specific implementation of a pancake algorithm, every move when we find the greatest of the ... b) Exponential functions c) Logarithmic functions d) Permutations...
asked Dec 29, 2022 in Technology by JackTerrance
0 votes
    What is the command to pick a commit from a specific branch and move it to another branch? A. Git move commit B. Git cherry-pick C. Git move branch D. None of the options...
asked Dec 24, 2022 in Technology by JackTerrance
0 votes
    I'm trying to make the text move continuously by pressing a button but right now it only moves an ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 1, 2022 in Education by JackTerrance
0 votes
    I made some input boxes with 0 20px padding placeholders. However the text I type inside ignores padding ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    Write the short cut keys to move text in word document. 1. ctrl+A 2.Alt+m 3.ctrl+x ctrl+v 4. Ctrl+p ctrl+Q Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    The Text and Comment is part of __________ (a) CharacterData (b) Document (c) Attr (d) Element I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    I am using a third party application and would like to change one of its files. The file is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I am using a third party application and would like to change one of its files. The file is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I am using a third party application and would like to change one of its files. The file is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I am using a third party application and would like to change one of its files. The file is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 10, 2022 in Education by JackTerrance
0 votes
    I have millions of file in a Folder its difficult to read with script so i need to store file in ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    I looked into the Python os interface, but was unable to locate a method to move a file. How ... mv source_files destination_folder Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    Which built-in function can be used to move the file pointer internally?...
asked Jan 18, 2021 in Technology by JackTerrance
+1 vote
    Which built-in function can be used to move the file pointer internally in C Programming?...
asked Nov 9, 2020 in Technology by JackTerrance
0 votes
    Point out the correct statement. (a) shiny project is a directory containing at least three parts (b) shiny project ... directory containing only one part (d) none of the mentioned...
asked Oct 9, 2021 in Technology by JackTerrance
...