News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

[PLUGIN WANTED] Automatic white space adder

Started by Mad Scientist, March 01, 2007, 12:05:49 AM

Previous topic - Next topic

Mad Scientist

I have been just learning python and when finding i need to add an if statement to a long list thought it would be nice if there was a macro/plugin that could be used to add whitespace. For test commands in the file I was thinking something like://Some code
...
...
code
...
...
//Add the text commands to the file
...
>> SPACE 2
...
code
...
>> SPACE END
...
//Indented code
...
  ...
  code
  ...
...

Or a simpile right click/menu option would be nice to.

Some options for it that would be nice are add/remove('>>' or '<<'), space or tab('SPACE' or 'TAB') and how many.

Thanks in advance for any time used to do this. :D

byo

Maybe you mean that:

Select source you want to indent and then TAB - adds one tab in front of each selected line, alt+Tab removes one tab for each line if there's any

Mad Scientist

Ya thanks thats what I was looking for. If only it worked for spaces and Alt Tab wasnt already taken by windows :x Well then i am looking for someone to add spaces and a differnet key combo then alt - tab for windows.

stahta01

Quote from: Mad Scientist on March 01, 2007, 02:03:36 AM
Ya thanks thats what I was looking for. If only it worked for spaces and Alt Tab wasnt already taken by windows :x Well then i am looking for someone to add spaces and a differnet key combo then alt - tab for windows.

Verify your settings, it should work for spaces.

"settings" -> "editor"
"General Settings" verify "Use TAB Character" is unchecked.

Tim S
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

Mad Scientist

O thanks for showing me the options but I was looking more for adding one space at a time not a tab indent with spaces. I like to indent with 2 spaces and have tab be 8 spaces long to keep the files looking right with other programs and with code blocks.  :(

Pecan

#5
Quote from: Mad Scientist on March 01, 2007, 06:55:13 AM
O thanks for showing me the options but I was looking more for adding one space at a time not a tab indent with spaces. I like to indent with 2 spaces and have tab be 8 spaces long to keep the files looking right with other programs and with code blocks.  :(

KeyMacs is a plugin that allows the user to define a hotkey as a sequence of keystrokes. You could define (say) alt-shift-2 as two spaces, or alt-shft-4 as four spaces etc.

If you're using SVN source, try compiling KeyMacs.
If your using the Nightly, and you think that KeyMacs will help,
tell me which Nightly you're using and I'll make a binary for  you.

Help entry (Wiki):
http://wiki.codeblocks.org/index.php?title=KeyMacs_plugin
Forum:
http://forums.next.codeblocks.org/index.php?topic=4681.0

kkez

Quote from: byo on March 01, 2007, 12:36:49 AM
Maybe you mean that:

Select source you want to indent and then TAB - adds one tab in front of each selected line, alt+Tab removes one tab for each line if there's any

On my os it's Shift+Tab, not Alt+Tab ...

Mad Scientist

Pecan: Ya, thanks that would be great just compile it for the latest nightly that is availible and ill upgrade when its compiled.

kkez: Yup Shift-Tab works could of sworn I tried that along with all the other modifier keys.

Thanks to everyone for all the help   :D

Pecan

Quote from: Mad Scientist on March 01, 2007, 09:46:51 PM
Pecan: Ya, thanks that would be great just compile it for the latest nightly that is availible and ill upgrade when its compiled.

kkez: Yup Shift-Tab works could of sworn I tried that along with all the other modifier keys.

Thanks to everyone for all the help   :D

Please see: http://forums.next.codeblocks.org/index.php/topic,5308.new.html#new

Mad Scientist

#9
Ok I have KeyMac setup just wondering if i could have it add a space to the first line of the selected block of text every time i press space and remove a space from the first line with Shift-Space in a similer way that it is done with Tab and Shift - Tab?

Pecan

#10
Quote from: Mad Scientist on March 03, 2007, 07:05:53 AM
Ok I have KeyMac setup just wondering if i could have it add a space to the first line of the selected block of text every time i press space and remove a space from the first line with Shift-Space in a similer way that it is done with Tab and Shift - Tab?

I cannot think of a combination of keys that would do that directly, but KeyMacs can make it easier to prefix a space to a line with
a keymac of {space}{down}{home} associated with a hot key of say Ctri-Shift-I.

Each time you hit Ctrl-Shift-I, a space will be added to the beginning of the line and the cursor will advance to the beginning of the next line.

If you had 10 lines, just hold now Ctrl-Shift and hit "I" ten times.

You could also temporarily define the Tab key as a 1 space tab, then use mark/tab mark/shift-tab as usual.

To redefine TAB, MainMenu=>Setting=>Editor=>"TAB size in spaces: 1"

A workaround that allows both a 4space tab and a 1space tab is:
1)set Tab to a 1space tab(as above).
2) with KeyMacs define (say)Alt-Ctrl-T as {TAB 4} to simulate the old tab.

You cannot use a single character (like space) as a hotkey for either KeyMacs or a menu item, else you wouldn't be able to use it as a regular text key. However, you can use any combination of a text key with Ctrl,Shift, or Alt.

Alt/Ctrl Tab cannot be used as a hotkey because it's overridden by MicroSoft.