2016-09-23 14 views
2

メモ帳では、編集 - >列エディタを使用してテキストファイルの各行に数値を入力しています。メモ帳++列エディタ

開いているすべてのドキュメントでこれを行う方法はありますか?テキストファイルごとにこれを保存する方法はありますか?

+0

最も簡単な方法は、お好みのスクリプト言語でスクリプトを記述することである使用。 – Toto

答えて

1

はい、これを行うためのPythonスクリプトを書くことができます。これらの工程(N/A場合は省略)実行します。 - >のPythonスクリプト -

  • プラグインPythonScript
  • Go]をインストール>新しいスクリプト
  • を新しいAddLineIdsAllTabs.pyスクリプト
  • を作成します。次のコンテンツを追加してください:

offset = 1 # Define the offset (step) value 
fileNames = notepad.getFiles()    # get all open files 
for x in fileNames[1:]:      # iterate thru all tabs (first is doubled, thus skipping) 
    filename, bufferID, index, view = x  # get the details 
    notepad.activateIndex(view, index)  # activate the tab 
    line_number = editor.getLineCount()  # get line count 
    for id in range(line_number):   # iterate thru all lines 
     editor.gotoLine(id)     # go to line with a given ID 
     editor.home()      # place cursor at the line start 
     editor.addText("{0}. ".format(str(id+offset))) # Add text 

プラグインからスクリプトを実行します - >のPythonスクリプト - >スクリプト - >AddLineIdsAllTabs

代替スクリプト

notepad.activateIndex(view, index)行の後、

editor.selectAll() 
notepad.runMenuCommand('TextFX Tools', 'Insert Line Numbers')