[Share My Idea] Plugin to insert leading number Alt+C

Post Reply
hycmos
Posts: 86
Joined: 06.11.2019 02:17

[Share My Idea] Plugin to insert leading number Alt+C

Post by hycmos »

function: column mode to insert increasing leading number at everyline (Same as Notepad++)

1) you can find menu Plugins--> Make Plugin
2) Click it
3 )Plugname=MyaltC,module name=MyaltC,items=MyaltC>run
4) OK
5) At line 27, find "def run(self)"
6) replace all of def run(self) with:

Code: Select all

    def run(self):
        cnt = ed.get_carets()
        altCnum=dlg_input_ex(4, 'Number be inserted',
              'start'   , text1="0", label2="Step by", text2="1",
              label3="Leading Char", text3="",label4="Following Char", text4="")
        if altCnum==None:return()
        i=0
        for a_cnt in cnt:
            altCtxt=int(altCnum[0])+i*int(altCnum[1])
            altCtxt=altCnum[2]+str(altCtxt)+altCnum[3]
            a_caret=a_cnt[0]
            if a_cnt[0]>a_cnt[2]:
                a_caret=a_cnt[2]
            ed.insert(a_caret, a_cnt[1], altCtxt)
            i=i+1
7) Now restart CudaText. you can find new menu in "Plugins-->MyaltC", even you can assign a hotkey 'alt+C' to this.
8) get the Alt-C function same as many editor :D :D
Thank too the Cudatext's power python API,
this function is more powerfull than NP++'s Alt+C. This can add following char.
miro.matas
Posts: 67
Joined: 26.08.2013 06:16

Post by miro.matas »

sorry… not tested your code
but, there is plugin Insert Numbers
not the same?
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

Plugin InsertNumbers has good quality, but the snippet above a) don't check if selection made, b) works bad if n carets on the same line (you must iterate carets from last to first). But i like the approach!
hycmos
Posts: 86
Joined: 06.11.2019 02:17

Post by hycmos »

sorry, I did not know the plugin "insert number" before. Can not find it in sf.net nor totalcmd.net.
Could you show me the link to this plugin?

In my code, I try to implement the same column selection function as Notepad++.
1) alt+(left mouse) to select multiline texts;
2) keyboard (alt+C) to show a dialog to set "start number/step"(for example,start number=0/step=1);
3) then at every first column of the selected box, 0/1/2/3...will be inserted to every line.
BTW, I added the leading char and the following char to this inserted number, which is not implemented in NP++(this shows the Cuda's powerful potential.)

this plugin is special for this same function as NP++'s.
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

Plugin was medged into plugin "Number Utils" long ago.
You can make patches-
https://github.com/cudatext-addons/cuda_number_utils
hycmos
Posts: 86
Joined: 06.11.2019 02:17

Post by hycmos »

I tested the plugin "Number Utils" .
It is very good.
I would not write this post if I find this plugin. :D
I use it Now.

Thanks!
Post Reply