我正在从Notepad ++切换到VIM作为主文本编辑器.
通过按住ctrl并单击文本中的任意位置,Notepad ++可以有多个游标,因此如果键入,文本将显示在多个位置.
在vim中有可能吗?在可视模式下选择多行之后插入的东西,但可以在文本中的任何位置使用游标.
这是我很少使用的功能,也很容易避免,我只是很好奇,因为它是唯一一个我无法在vim中找到它的替代品.
我正在编写一个Chrome扩展程序供我自己使用.我正在从注入的脚本中查询当前选项卡的索引,如下所示:
[注入脚本]
chrome.runtime.sendMessage({whatIsMyIndex:1}, function(response){
var myIndex = response.index;
});
Run Code Online (Sandbox Code Playgroud)
[后台脚本]
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.whatIsMyIndex){
sendResponse({index: sender.tab.index});
}
}
);
Run Code Online (Sandbox Code Playgroud)
现在这一切都很好,但是我还需要返回第一个标签的url:
[注入脚本2]
chrome.runtime.sendMessage({whatIsMyIndex:1}, function(response){
var myIndex = response.index;
var url = response.url;
});
Run Code Online (Sandbox Code Playgroud)
[后台脚本2]
var url;
//this uses sendResponse when the requested values arrive
function respond(sendResponse, index){
if(typeof(url)!="undefined"){
sendResponse({index:index, url:url});
} else {
setTimeout(respond, 15, sendResponse, index);
}
}
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.whatIsMyIndex){
chrome.tabs.query({index:0, currentWindow:true}, function(tabs){
url=tabs[0].url;
}
setTimeout(respond, 15, sendResponse, sender.tab.index);
return true; //so …Run Code Online (Sandbox Code Playgroud)