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

效果

快捷键添加

不会改的,自行留言

相关推荐
----云烟----13 分钟前
STM32的Systick定时器的作用
stm32·单片机·嵌入式硬件
Vodka~23 分钟前
HAL库常用函数
stm32·单片机·嵌入式硬件
m0_7482522331 分钟前
Python 入门教程(2)搭建环境 2.4、VSCode配置Node.js运行环境
vscode·python·node.js
梓羽玩Python1 小时前
太牛了!OWL:Manus 最强开源复现,开源框架GAIA基准测试中排第一!
人工智能·python
不不不丶1 小时前
STM32 ——系统架构
stm32·单片机·嵌入式硬件
2301_764441331 小时前
python实现的生态模拟系统
开发语言·python·pygame
m0_748241701 小时前
Python毕业设计选题:基于django+vue的智能租房系统的设计与实现
python·django·课程设计
m0_748244961 小时前
Python毕业设计选题:基于Python的社区爱心养老管理系统设计与实现_django
python·django·课程设计
莓事哒1 小时前
静态网页的爬虫(以电影天堂为例)
爬虫·python
HerrFu1 小时前
可狱可囚的爬虫系列课程 18:成都在售新房数据爬虫(lxml 模块)实战
爬虫·python