loops - 崇高文本中的循环和测试
问题描述
我习惯于在 Ultraedit 中创建宏以将注释组织在某个列中,例如第 90 列。为此,我创建了一个宏来搜索行尾,如果存在则清除结尾空格并将空格添加到行尾直到它到达第 90 列。我找不到 Sublime 文本的任何参考:如何检查光标位置,
如何检查光标位置上的字符,如何创建循环。这个想法是创建一个宏做类似的事情
go to the end of line
while the column is not the first {
return one character
if the character under cursor is space or tab {
delete the character
}
else {
break
}
}
if column is before or on column 90 {
while the column is before 90 {
insert space
}
insert "//"
}
解决方案
这种逻辑在使用Sublime API编写的Python插件中可用。特别是,您将子类化. Package Control中有数千个包,其中许多是插件,您可以查看这些包作为示例。前面的文档链接也很有帮助。您可以在此处、Sublime Text 论坛和Discord 服务器上获得有关特定问题的帮助。Youtube 上也有很多视频 -特别是OdatNurd 的频道很棒。sublime_plugin.TextCommand
推荐阅读
- javascript - 无法读取未定义的属性 'addEventListener' --- navigator.serviceWorker.register('worker.js')
- amazon-web-services - Terraform:调用函数“元素”失败:无法从字符串中读取元素
- postgresql - 无法从另一个容器中的 Web 应用程序访问 docker 中的 postgres
- google-play - 如何使用单个 Play 商店帐户在不同的应用内帐户中购买相同的订阅?
- python - 如何从管道将参数传递给python脚本
- c++ - Qt 6.1 QSGTexture 的纹理数据可以动态更改吗?
- javascript - 计算对象数组的中位数
- visual-studio-code - 无法在编辑器中输入数字“1”
- r - 在 R 闪亮中按下浏览按钮后自动呈现“textInput”
- flutter - path_provider getExternalStorageDirectories() 只返回一个目录