Adobe brackets: write spaces instead of tabs - indentation

I am using brackets with coffeescript, but when I hit Tab, it insert a tabulation whereas i only need 2 spaces. Also, when I create a line break, the indent is tabs, and not spaces. Can I change these 2 setting ?

In the lower-right of the status bar you should see an indicator saying "Tab Size." Click the label to toggle to spaces. To change the amount of indent, click the number next to it and type a new value.
Note: if the indicator already says "Spaces" then Brackets should be using spaces instead of tab characters already. But it might not feel that way because when you move the cursor or press Backspace, there's a "soft tabs" behavior: the cursor will smartly skips over contiguous spaces to line up evenly with the next tab stop. If that bothers you, there will be a preference in the next release of Brackets (Sprint 38) to disable that behavior, making the cursor never move more than one space at a time.

For language specific control, Brackets allows you to provide different tab and space indentation values in the brackets.json file. For example:
"language": {
"html": {
"spaceUnits": 4
},
"javascript": {
"tabSize": 2
}
}

For changing tab spacing you can edit your brackets.json file. you can find it on Debug->Open Preferences File and simple add "spaceUnits": 2 at the end of the file for 2 space. Remember to add a comma on previous line. You can edit that file for customizing your bracket.
Or you can change it more easily at the right-bottom of your bracket interface you saw a option Space: 4 click on the number and change it as your wish...

Related

Moving over tab spaces in ncurses

I am creating a basic text editor using ncurses. It can display text fine, but navigating with arrow keys causes a problem when tabs are encountered. Calling move(y, x) will freely move the cursor onto a tab space, where most text editors will jump to the next character. Is there functionality within ncurses to jump over tab spaces or do I need to find a way to do it myself?
You have to do it yourself: wmove moves to the given coordinates, ignoring the way characters are displayed on the screen.
If a destructive (filling with spaces) tab works for your application, then you could use waddch:
If ch is a tab, newline, carriage return or backspace, the
cursor is moved appropriately within the window:
Tabs are considered to be at every eighth column. The
tab interval may be altered by setting the TABSIZE
variable.
For an editor, you probably do not want that behavior (though it probably would be helpful to use the TABSIZE feature when displaying text).

Proper code indentation for tabs in LibreOffice/OpenOffice and Ms Word

I have some text documents (.doc and .odf) with portions of colored code appearing inside.
This code was copied as RTF from Notepad++, that's how it got colored.
However, in Notepad++ (and in many IDEs as well), the line wrap function works makes the indented code look better when in does not fit and goes to the next line.
In LibreOffice/OpenOffice and Ms Word it's possible to achieve a similar line wrap with the "increase indent" button.
So, what I'd like to do, is to automatically replace the tabs (or 4 spaces, if you like) with proper indents. Or make the tabs behave like I expect them to. Is it possible? Thanks.
Here's a visualization of the problem
I achieved what I want through some (not that many) manual steps.
find out what is the maximum number of tabs (or sets of 4 spaces), say it's 3
open the search and replace window, input 3 tabs (or 12 spaces), and click "Find All"
now all groups of 3 tabs are selected, and you are working on all the lines with maximum indentation
park or close the search and replace window, click 3 times on the "Increase indent" button (or set the left indentation in the paragraph style menu)
delete the selected groups of 3 tabs
open the search and replace window, input 2 tabs (or 8 spaces), and click "Find All"
park or close the search and replace window, click 2 times on the "Increase indent" button
delete the selected groups of 2 tabs
open the search and replace window, input 1 tabs (or 4 spaces), and click "Find All"
park or close the search and replace window, click 1 time on the "Increase indent" button
delete the selected single tabs
Now you have a nice code indentation.
If you are using Microsoft Word, then there's no "find all", but there is a way to apply paragraph styles directly from the search and replace menu. But the steps are a little different.
First decide how wide a single indentation should be (e.g. 0.5 cm)
open the find and replace window, input 3 tabs (or 12 spaces) in the Find bar
leave the Replace bar empty, but click on it
if you don't see the Search options group, click More
click on Format
click on Paragraph
set a left indentation of 3 * the indentation width you want (e.g. 1.5 cm)
click Replace All, the paragraph style will be applied but the tabs/spaces will NOT be removed
click on the empty Replace bar (again)
click No Formatting
click on Replace All (again)
now the tabs/spaces will be deleted
Rinse and repeat until you get a nice indentation.
If you are using Python (or if you want to keep your white spaces) then instead of deleting the tabs (or spaces), you can replace them with a placeholder character you don't use in the rest of the code, say £ and replace them back in one pass when you are done. However, you'll get a skewed indentation.
I guess there's a way to do this with macros, but this was good enough for me.

How to Move selected text Left or Right

I can't believe I can't find a way in Webstorm that when you highlight code, then move it right or left as a group (tab left or right, moving it over left or right).
Is there a way to do this? I can't find one. I need to shift several lines of code in JSON to tab and make it read better from withing Webstorm as just one example. Most editors have this capability! unless I'm just missing it, this is a huge hole in Webstorm that is fundamental that is simply not there!
On top of this I've also noticed that if you put your cursor at the beginning of a line of code and then do Shift + Home to highlight the empty space before it, typically in most editors you can hit tab and start moving it back from the farthest point left back to right. In webstorm, when you highlight the empty space to the left of a starting line and hit tab, it starts tabbing from the the start of the line, not from the first empty space. I find this bizarre and very frustrating.
select a code region and hit Tab (Edit | Indent Selection) or Shift+Tab (unindent)

Add trailing zeroes to line in notepad++

I have a file containing (hundreds) of blocks of numbers like below;
This one is fine (16x20, correct number of rows and columns)
11111111111111111110
16666616666666661110
16111616111111162610
16111646111663132610
16162616261623132610
16162313261623132610
16162313261623132610
16162313261623132610
16162313261623132610
16162313261623132610
16162313261623132610
16162313261626132610
16166313661116632610
16111111111116132610
16666666666666136610
11111111111111111110
This one needs to be padded with trailing zeroes so it is (16x20)
111111111111111111
166616666666663661
166611111111111661
166666366663661661
113161111111161611
1316166666616161
1616162262616161
11616166112616161
16616166116616161
16616162262616161
16616166266616161
16616111161116161
1661666666666616111
1661666166163366661
1641666166166613661
1111111111111111111
I would like to pad them with zeroes so they are all like the first example. I'm aware of the regular expressions feature in notepad++ but am struggling to get it to work. I appreciate any help given.
You could do it via a macro.
First append a large number of zeroes to the end of each line using a macro.
Caret on the first entry
click record macro
press end
type out 20 zeroes
press down arrow
click stop recording
play the macro until all lines look like this
11111111111111111100000000000000000000000000000000000000000000
16661666666666366100000000000000000000000000000000000000000000
16661111111111166100000000000000000000000000000000000000000000
16666636666366166100000000000000000000000000000000000000000000
11316111111116161100000000000000000000000000000000000000000000
131616666661616100000000000000000000000000000000000000000000
161616226261616100000000000000000000000000000000000000000000
1161616611261616100000000000000000000000000000000000000000000
1661616611661616100000000000000000000000000000000000000000000
1661616226261616100000000000000000000000000000000000000000000
1661616626661616100000000000000000000000000000000000000000000
1661611116111616100000000000000000000000000000000000000000000
166166666666661611100000000000000000000000000000000000000000000
166166616616336666100000000000000000000000000000000000000000000
164166616616661366100000000000000000000000000000000000000000000
111111111111111111100000000000000000000000000000000000000000000
Then...
Caret on first line
click record
press home key
press the right arrow key 20 times
hold shift and press end key
press delete key
press down arrow
click stop recording
play the macro until all lines are processed
You could save the entire process as a single macro so its just a single click in the future.
I can give you a macro solution
go to the beginning of your text
select Macro/Start Recording
press end, press 0 16 times then press Home and down arrow key
select Macro/End Recording
You now have a macro to add sixteen zeros to the end of all lines.
Playback this macro on all lines.
You now have appended zeroes to all lines.
Pressing Alt key and using mouse select the required block(columns) of text you want and paste it into another empty notepad tab
help on column mode editing is there inside notepad ? / help contents menu
Good luck
You can use the plugin ConyEdit to do this.
With ConyEdit running in the background, follow these steps:
use the command line cc.aal 00000000000000000000 to append after lines with twenty zero character.
use the command line cc.gc 1/\d{20}/ to get the first column of regex match.
Looking to do this manualy and not progomaticly ?
Open Findreplace
Copy from the last to rhe first WITHOUT NUMBERS on a line so...
in this example
111111111111111111 <---from here
to here ---> 166616666666663661
166611111111111661
paste that into the fine ( yes your effecticly copying the return wich some applications allow you to manualy input others wont )
then in the replace box, type '0' then your return
Hit that magic replace all :D
This will then add a 0 every time it hits a new line, then add a new... new line....
edit : quickly reviewing another method a second to recover for alternate options :P give me 10
edit 2:
Ah ok somthing like this will work :P just tested it.
use [0-9] in the find replace. so if im looking for 123123123123 ( wich is 12 long ) and i need to buff i up to 20,
Your FIND must be in ()
so..
the find would be
([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] )
and the replace is referd to as \1 no the regex, this was my mistake
\100000000
tested and confirmed !dont forget YOU NEED MATCH ALL on, WRAP off!
And so on for your other numbers, Not sure if you can loop this with macros nd stuff :P but hope it helps more than you have now
two good resources.
http://blog.creativeitp.com/posts-and-articles/editors/understanding-regex-with-notepad/comment-page-1/
http://regexpal.com/
base on OP's comment: you could try an editor called vim/gvim
open your file in vim, then type:
:%s/.*/\=printf("%-20s",getline("."))/|%s/ *$/\=substitute(submatch(0)," ","0","g")/
don't forget pressing <Enter> after the above typing.
then you will see the text has been changed into what you want.
of course vim macro can work as well, however, I feel command better... :)

How do tabs work for text boxes?

I'm making a game gui api and I'm wondering how to implement tabs. I'm using freetype for text. When I try to render '\t' It looks like a square. I'm wondering how tabs are implemented because they are not a fixed width.
Thanks
For a fixed-width font you could compute how many spaces to the next tab stop, but the general solution is to stop rendering when you hit a tab, move to the next tabstop, and then render the text that comes after the tab character starting from there. Where the tabstops are is up to you, but a good default is probably something like every 8 ems.
The simplest strategy is to swap a tab out for a some number of spaces. I.e. when the user pushes tab, pretend they pushed tab four times instead. (Or just print out four spaces, whatever works for you)