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

效果

快捷键添加

不会改的,自行留言

相关推荐
码界索隆12 小时前
Python转Java系列:前言
java·开发语言·python
金銀銅鐵12 小时前
用 Tkinter 实现一个罗马数字转整数的简单工具
后端·python
天涯铭12 小时前
深入浅出:单片机I/O口串联电阻选型
单片机·嵌入式硬件·io口串联电阻
国科安芯13 小时前
ASP7A84AS——航天级低噪声高PSRR线性稳压器
网络·单片机·嵌入式硬件·架构·安全性测试
MC皮蛋侠客13 小时前
Ruff 完全指南:下一代 Python Linter 与 Formatter
python
普中科技14 小时前
【普中STM32F1xx开发攻略--标准库版】-- 第 42 章 STM32 内部 FLASH 实验
stm32·单片机·嵌入式硬件·开发板·普中科技·内部flash
happylifetree14 小时前
Python014-第二章13.数据容器-tuple案例
python
ID_1800790547314 小时前
小红书笔记评论 API 接口深度解析(带全套 JSON 示例・技术实战版)
java·开发语言·windows
茉莉玫瑰花茶14 小时前
LangGraph 其他核心能力 [ 3 ]
python·ai
AI玫瑰助手14 小时前
Python函数:递归函数的定义与阶乘案例实现
开发语言·python·信息可视化