Search This - get current line text and search

Gif Demo

Description

A simple plugin which gets current line and do global search. No need for copy/paste.

Install

Put snippet below in your console (Ctrl+Shift+I)

!function() {
	function searchThis() {
			const search = query => app.globalSearch.openGlobalSearch(query)
			const doc = app.workspace.activeLeaf.view.sourceMode.cmEditor.doc
			const curLineNum = doc.getCursor().line

			const searchQuery = doc.getLine(curLineNum).trim()

			search(searchQuery)
	}

	app.commands.addCommand({
	    id: 'app:search-this',
	    name: 'Search This',
	    callback: searchThis,
	    hotkeys: []
	})
}()

5 Likes