随风逐叶 随风逐叶
首页
  • Quick Reference (opens new window)
  • EgretEngine开发者文档 (opens new window)
  • TinaX框架
  • SSH教程
  • VSCode插件开发
关于
  • 分类
  • 标签
  • 归档

rontian

从事游戏开发10多年的老菜鸟一枚!
首页
  • Quick Reference (opens new window)
  • EgretEngine开发者文档 (opens new window)
  • TinaX框架
  • SSH教程
  • VSCode插件开发
关于
  • 分类
  • 标签
  • 归档
  • 环境配置
  • 脚手架
  • 启动与调试插件

  • Command配置

  • 发布

  • snippets
  • 插件配置

  • 常见编辑器API

    • 常见编辑器API
    • message
    • input box
    • quick pick
    • output channel
    • file selector
    • hover
    • selection
    • FileSystemWatcher
  • 参考文章

selection

# selection

与hover类似,有时候需要处理选中的文本,获取它是通过vscode.TextEditor实例上的属性,有两个相关属性

  • selections:所有被选中的文本信息
  • selection:第一个被选中的文本信息, 等同于selections[0]

获取TextEditor的一个方法是通过注册textEditorCommand,会在回调函数里提供TextEditor实例,例如展示选中文本:

let command = vscode.commands.registerTextEditorCommand('extension.selection', function(textEditor, edit) {
  const text = textEditor.document.getText(textEditor.selection);
  console.log('选中的文本是:', text);
});

context.subscriptions.push(command);
1
2
3
4
5
6
上次更新: 2023/10/17, 16:50:29 访问次数: 0
hover
FileSystemWatcher

← hover FileSystemWatcher→

最近更新
01
一些Shell常用的功能写法整理
10-20
02
删除git仓库submodule的步骤
10-20
03
django基本命令
10-16
更多文章>
Copyright © 2017-2025 随风逐叶
沪ICP备18008791号-1 | 沪公网安备31011502401077号

网站访问总次数: 0次
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式