Replies: 6 comments 12 replies
-
I've noticed the same and it's a lot more work to make the code neat when spaces are used instead of tabs. With spaces, each time a backspace is required, there are multiple keystrokes involved, and then multiple keystrokes involved again just to get the code to line back up. @mmikeww has made it clear that spaces are not to be changed to tabs. I don't know the reason for this, as tabs are much less work and easier to manage (IMO) than multiple spaces covering the same real-estate within the document. If a vote takes place for a unified formatting, my vote will be cast for tabs4. But obviously, I will have to live with the general consensus. |
Beta Was this translation helpful? Give feedback.
-
True, but you could set up a hotkey to backspace x4. 😜 |
Beta Was this translation helpful? Give feedback.
-
spaces vs tabs debate has existed for as long as people have ever started coding i'm a spaces person, and so to keep the project consistent, thats what i originally chose but obviously as more contributors join, code can get messy and mixed. ultimately for a real solution, an editorconfig file should be used, and most programmers should be using a text editor that supports an editorconfig file, and then all of the issues are likely erased. the editor handles it on a per-project basis, depending on what the editorconfig file says so the necessary steps would be
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Thoughts? /*******************************************************************
* Replaces 3 space tabs with 4 space tabs in leading indentation. *
* Also replaces all literal tab stops with 4 space tabs. *
* Interspacing needs to be tidied up manually. *
*******************************************************************/
#Requires AutoHotkey v2.0
filename_1 := "ConvertFuncs.ahk"
filename_2 := "ConvertFuncs_2.ahk"
newContent := ""
oldTabSpaces := " "
newTabSpaces := " "
loop read filename_1
{
newLeadingTabs := ""
RegExMatch(A_LoopReadLine,"^(" oldTabSpaces ")+(?! )", &leadingWhitespace)
if leadingWhitespace
{
leadingWhitespaceLen := leadingWhitespace.Len
oldLeadingTabsCount := Round(leadingWhitespaceLen / 3)
loop oldLeadingTabsCount
newLeadingTabs .= newTabSpaces
}
newLine := RegExReplace(A_LoopReadLine, "^( )+(?! )(.*)", newLeadingTabs . "$2")
newContent .= newLine "`r`n"
}
newContent := RegExReplace(newContent,"\t", newTabSpaces)
newContent := RegExReplace(newContent,"\s*$","")
If FileExist(filename_2)
FileDelete(filename_2)
FileAppend newContent, filename_2
ExitApp |
Beta Was this translation helpful? Give feedback.
-
On a related note... I'd like to say that I would be in favor of adding comments to code that is edited giving a bit of details regarding the edit's purpose and make notes that may be helpful to others reading the code. For instance, when we add or change regex needles, it would be nice to have a brief description about what that needle is extracting/replacing. Without this, I (for one) must read the needle from left to right very slowly to see what it is doing. A note would allow the reader to see the intention and only be required to dig into the needle details if there seems to be a problem with the output. That's just one example. Comments do increase file size but also increase clarity for others who need to find a place to insert their own code. The comments I add to my code help me tremendously to remember my thought process at the time the code was written. I'm hoping it is also helpful to others who read that code. This is the type of thing I have in mind. Anyone else in favor of this idea? Not necessarily for themselves alone, but also for the "team" as a whole. |
Beta Was this translation helpful? Give feedback.
-
Can some ground rules be laid?
Literal tabs or spaces for indentation and alignment - if spaces, how many - 2/3/4, all have been used? I notice a vast mix of both used throughout the code, even mixing literal tabs and spaces in the same indentation or alignment spacing,
Other stuff that we should be reading from the same page?
Beta Was this translation helpful? Give feedback.
All reactions