Keil C51 插件 快速复制一行

此插件解决的问题

目前 Keil 软件 只可以 先选中一行,再Ctrl C + Ctrl V , 太麻烦了

Keil 插件 -- Python 代码

python 复制代码
import sys


# 插入当前行内容
def insert_line(current_file_path, line_number):
    line_to_insert = ''

    # 读取文件内容
    with open(current_file_path, 'r', encoding='gb2312') as file:
        content = file.read()

    # 分割内容为行
    lines = content.splitlines()

    # 获取当前行 内容
    if line_number <= len(lines):
        line_to_insert = lines[line_number - 1]
    else:
        raise IndexError("Line number exceeds the total number of lines in the file.")

    # 插入新行
    lines.insert(line_number - 1, line_to_insert)

    # 将修改后的内容写回文件
    with open(current_file_path, 'w', encoding='gb2312') as file:
        file.write('\n'.join(lines) + '\n')


if __name__ == "__main__":
    try:
        filename = sys.argv[1:]

        file_path = ' '.join(filename[:-2]) + filename[-2].split('\\')[-1]

        row_num = int(filename[-1]) + 1

        insert_line(file_path, row_num)

        print('复制当前一行')

    except Exception as e:
        print(str(e))

需要修改的地方

上面代码,所需要的包,自行导入

Python 生成 exe

pip install pyinstaller -- 自行安装包

python 复制代码
pyinstaller -Fw .\Select_All_if.py 

Keil C51 插件安装

参数 自行复制

复制代码
$E !E ~E

效果

快捷键添加

不会改的,自行留言

相关推荐
xiaoh_722 分钟前
解决视频处理中的 HEVC 解码错误:Could not find ref with POC xxx【已解决】
python·ffmpeg·音视频
明月与玄武1 小时前
Python编程的真谛:超越语法,理解编程本质
python·编程语言
CodeCraft Studio1 小时前
Excel处理控件Aspose.Cells教程:使用 Python 在 Excel 中进行数据验
开发语言·python·excel
子非衣1 小时前
Windows云主机远程连接提示“出现了内部错误”
服务器·windows
国科安芯1 小时前
面向高性能运动控制的MCU:架构创新、算法优化与应用分析
单片机·嵌入式硬件·安全·架构·机器人·汽车·risc-v
阿让啊1 小时前
C语言中操作字节的某一位
c语言·开发语言·数据结构·单片机·算法
拾忆-eleven1 小时前
C语言实战:用Pygame打造高难度水果消消乐游戏
c语言·python·pygame
旦莫2 小时前
Python 教程:我们可以给 Python 文件起中文名吗?
开发语言·python
豌豆花下猫2 小时前
Python 潮流周刊#99:如何在生产环境中运行 Python?(摘要)
后端·python·ai
小杨4042 小时前
python入门系列二十(peewee)
人工智能·python·pycharm