`
kanpiaoxue
  • 浏览: 1789739 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

notepad++自定义功能

 
阅读更多

notepad++ 提供了丰富的自扩展功能,这里只介绍一下Python的plugin的扩展。

如何开发属于自己的扩展功能呢?请参考附件中的PythonScript.chm官方文档。

功能1:notepad++如何插入时间 地址:http://kanpiaoxue.iteye.com/admin/blogs/2340937

功能2:去掉右侧空格:

#rstrip the contents
def testContents(contents, lineNumber, totalLines):                
	newContents = contents.rstrip()
	editor.replaceLine(lineNumber, newContents)

editor.forEachLine(testContents)

 

【 notepad++的Python自身对象和用法需要参考它自带的文档】

需要先安装插件 python script。

插件的官方说明如下:

================== start

Scripting plugin for Notepad++, documentation included

As easy as:

 notepad.open('filename.txt')

 editor.appendText("Hello World")

Full programmatic access to Notepad++ features and menus

Full programmatic access to all of Scintilla features

Call other plugin menu items

Assign menu items, shortcuts and toolbar icons to scripts

Process Notepad++ and Scintilla events, direct from a Python script

Python console built-in

Full regular expression support for search and replace - script Python regular expression replaces

Start external programs and pipe the output direct to a Notepad++ document, or filter it, or simply to the console window

Full documentation for all the objects and methods

Author: Dave Brotherstone + Jocelyn Legault

Source: http://github.com/davegb3/PythonScript

Homepage: http://npppythonscript.sourceforge.net

Latest update: Important bug fix for editor.pymlreplace()

Added editor.getCharacterPointer() that returns a string

Added notepad.getPluginVersion() to get version of Python Script

================== end

它文档的位置在: npp.7.2.1.bin\plugins\doc\PythonScript\PythonScript.chm

在这个文档里面可以查找到各种notepad++的自身对象和调用的方法。

自定义Python脚本的目录: npp.7.2.1.bin\plugins\Config\PythonScript\scripts

 

功能

快捷键

对于脚本

插入日期

Alt + Shift + d

ActionInsertDate.py

插入日期和时间

Alt + Shift + f

ActionInsertDateTime.py

插入时间戳

Alt + Shift + t

ActionInsertTimestamp.py

插入分割线

Alt + Shift + =

ActionInsertSplitLine.py

去掉右侧空格

Alt + Shift + r

ActionRstripLine.py

格式化Windows样式的路径为Unix样式

Alt + Shift + l

ActionForReplaceLinuxPathSplit.py

为列模式计算求和与平均值

ActionCalculateNumberSumForColumnModel.py

 

 

脚本名称

脚本内容

ActionInsertDate.py

import datetime

now = datetime.datetime.now()

editor.addText(now.strftime('%Y/%m/%d'))


 

ActionInsertDateTime.py

import datetime

now = datetime.datetime.now()

editor.addText(now.strftime('%Y/%m/%d %H:%M'))

 

ActionInsertTimestamp.py

import datetime

now = datetime.datetime.now()

editor.addText(now.strftime('%Y%m%d%H%M%S'))

ActionInsertSplitLine.py

import datetime

now = datetime.datetime.now()

nowString = now.strftime('%Y%m%d%H%M%S')

formatString = '[%s %s]'.center(100,'=')

result_start = formatString % ('start', nowString)

result_end = formatString % ('  end', nowString)

editor.addText(result_start)

editor.addText('\n')

 

editor.addText(result_end)

ActionRstripLine.py

#rstrip the contents

def testContents(contents, lineNumber, totalLines):               

newContents = contents.rstrip()

editor.replaceLine(lineNumber, newContents)

 

editor.forEachLine(testContents)

 

ActionForReplaceLinuxPathSplit.py

import re

 

def replaceAction(strObject):

return strObject.replace('\\','/')

 

def replaceFunc(m):

if m :

if m.group(1):

return '/' + m.group(1) + replaceAction(m.group(2))

else:

return replaceAction(m.group(0))

return None

 

def doAction():

#wPath = r'd:\baidu\workspaces\workspace_java\dmap-console'

wPath = editor.getSelText()

if '' != wPath.strip():

distPatten = r'^(?:(\w):)?(.*)$'

rs = re.sub(distPatten,replaceFunc, wPath)

if rs:

console.write(rs + '\n')

else:

console.write('can not find right path of windows style\n')

else:

console.write('select any nothing!\n')

 

 

#==============================================[start 2017/01/05 21:11:09]===============================================

doAction()

console.show()

editor.setFocus(True) 

#==============================================[ end  2017/01/05 21:11:09]===============================================

 

ActionCalculateNumberSumForColumnModel.py

def calculateNumberSumForColumnModel():

wPath = editor.getSelText()

if '' != wPath.strip():

lst = wPath.split('\n')

 

numSum = 0

numCount = 0

for numStr in lst:

if '' == numStr.strip():

continue

else:

numSum = numSum + float(numStr)

numCount = numCount + 1

averageNumString = 'denominator is 0'

if 0 != numCount:

averageNumString = str(numSum / numCount)

result = 'sum:%s, average:%s\n' % (str(numSum), averageNumString)

console.write(result)

else:

console.write('select any nothing!\n')

 

#==============================================[start 2017/01/11 14:36:12]===============================================

console.show()

calculateNumberSumForColumnModel()

editor.setFocus(True)

 

#==============================================[ end  2017/01/11 14:36:12]===============================================

 

分享到:
评论

相关推荐

    notepad++各种自定义主题

    总的来说,Notepad++的自定义主题功能是其的一大亮点,让每个人都能根据自己的需求和喜好定制独一无二的工作环境,提高编程效率和舒适度。"notepad++各种自定义主题"这个资源集合正是这种个性化表达的体现,提供了...

    notepad++ 插件开发模板

    6. `PluginInterface.h`:Notepad++插件接口的定义,包括各种函数指针类型,这些指针指向插件实现的函数,使得Notepad++能够调用插件的功能。 7. `NppPluginTemplate.vcproj`:Visual Studio的项目文件,用于构建和...

    notepad++ 智能提示插件

    智能提示插件是Notepad++的一种扩展功能,能够为用户在编写代码时提供自动补全、语法高亮、代码折叠等实用功能,极大地提高了开发效率。这些插件通常位于Notepad++的“plugins”目录下,可以通过安装和配置来启用。 ...

    NotePad++ 编辑NCL 代码,实现自动补全和高亮颜色2

    NotePad++作为一款开源、免费且功能强大的文本编辑器,因其对多种编程语言的支持及自定义特性而深受喜爱。在处理NCL(NCAR Command Language)这种科学数据处理语言时,通过适当地配置NotePad++,我们可以实现NCL...

    Notepad++Mac版怎么安装?.docx

    Notepad++ 作为一个功能强大且广泛应用的文本编辑器,在 Windows 平台上拥有极高的用户基础。然而,对于 Mac 用户来说,官方并未提供 Notepad++ 的 Mac 版本,引发了广泛的讨论和需求。幸运的是,有些大神利用 ...

    Notepad++ release 8.6.4 x64

    作为一款强大的代码编辑工具,Notepad++不仅支持多种编程语言,还具备丰富的自定义功能,使得其在开发者社区中备受推崇。本文将深入探讨Notepad++ 8.6.4 x64版本中的关键特性、优势以及如何下载和安装。 首先,...

    Notepad++ JSToolNPP 32位版本

    Notepad++是一款非常受欢迎的免费源代码编辑器,尤其在编程和文本处理领域,它以其轻量级、可自定义及支持多种编程语言的特点而受到程序员的青睐。JSToolNPP是Notepad++的一个插件,专为JavaScript开发者设计,提供...

    Notepad++插件包

    标题提到的"Notepad++插件包"是专门为Notepad++设计的一系列增强功能的工具集合,这些插件可以极大地提升编辑器的性能和用户体验。 Notepad++插件包通常包含多个不同的插件,每个都有其特定的用途。以下是一些常见...

    Notepad++ 解压即用

    Notepad++的特点和功能包括: 1. **多语言支持**:Notepad++内置了对多种编程语言的支持,如C++, Java, Python, PHP, HTML, CSS等,可以自动识别并进行语法高亮,提高代码可读性。 2. **插件系统**:Notepad++拥有...

    notepad++安装包及插件.zip

    它支持多种编程语言的高亮显示,并且具有丰富的自定义功能,可以极大地提高程序员的编码效率。下面,我们将深入探讨Notepad++的安装、功能以及与之相关的插件。 首先,我们看到"Win8.1_Net3.5_Offline.exe",这是一...

    Notepad++7.9安装包

    它基于Windows操作系统,支持多种编程语言,并且具有丰富的自定义功能。Notepad++ 7.9版本是该软件的一个更新迭代,带来了许多改进和新特性。 首先,Notepad++的核心优势在于它的轻量级特性。相比其他重量级的IDE...

    notepad++插件plugins,仅供32位notepad++使用

    它支持多种编程语言,并且具有丰富的自定义功能,包括安装各种插件以增强其功能。标题提到的"notepad++插件plugins,仅供32位notepad++使用"表明这是一个针对32位系统的Notepad++插件包。 插件是Notepad++扩展功能...

    Notepad++.zip解压即用版

    它基于Windows操作系统,支持多种编程语言,并且具有丰富的自定义功能。这个“Notepad++.zip解压即用版”提供了方便快捷的安装方式,用户无需进行复杂的安装过程,只需将压缩包解压到任意位置即可立即开始使用。 ...

    notepad++安装文件

    "用来看代码有颜色区分,层次分明",这是指Notepad++的一项核心功能——语法高亮。它能够根据不同的编程语言,用不同的颜色来标识关键字、变量、字符串等,帮助程序员快速识别代码结构,提高阅读效率。 Notepad++...

    Notepad++.zip

    Notepad++的特色功能包括: 1. **语法高亮**:Notepad++能够自动识别多种编程语言,如C++, Java, Python, HTML, CSS等,并对不同类型的代码元素进行颜色标记,使代码更易于阅读和理解。 2. **多文档界面(MDI)**...

    Notepad++免安装版

    作为一个强大的文本编辑工具,Notepad++拥有许多高级特性,如自动完成、代码折叠、查找和替换(支持正则表达式)、宏录制与回放、多视图编辑以及自定义插件等。这些功能使得Notepad++超越了基础文本编辑,成为开发...

    notepad++7.7便携版下载

    它基于强大的Scintilla编辑组件,支持多种编程语言,并提供了丰富的自定义功能,使得程序员和文本处理者都能享受到高效的工作环境。此版本7.7包括了多个插件,进一步增强了其功能,如XMLTools、PythonScript、...

    notepad++编辑nginx配置文件支持高亮

    为了改善这一情况,我们可以利用Notepad++的自定义语言功能来创建或导入Nginx的语法高亮定义文件。 描述中提到的方法就是通过导入一个名为"userDefineLang_nginx.xml"的文件,这个文件包含了Nginx配置文件的语法...

Global site tag (gtag.js) - Google Analytics