Using tkdiff on unix platform, I've tried modifying whitespace option in the preferences window to be -w or -b, neither of which seem to ignore carriage return differences (unix/pc.)
-w works with diff from the command line.
Any thoughts would be greatly appreciated.
Had the same problem, google search landed me here, and answer didn't help me. tkdiff uses diff internally for diffing, so spent few minutes trying all options including --strip-trailing-cr which doesn't help.
Here is options that works -
use -B along with -w to make tkdiff ignore all white spaces including blank lines.
tkdiff -w -B
If you have GNU diff, you can use the --strip-trailing-cr option. I don't know how to tell tkdiff to use that option.
Related
I am having an issue with using Ag (The Silver Searcher)...
In the docs it says to use -Q for exact match, but I don't understand why it does not work for my purposes. If I type something like ag -Q actions or ag -Q 'actions' into my terminal, it returns all instances of actions, including things like transactions and any other strings that actions is part of.
I have tried a couple other combinations of flags from the docs, including -s and -S, among others, but still I cannot get strictly strings matching just actions to return for me.
I can't get this to work with grep either. Does anyone know how I can get what I need with ag? (or even with grep)...?
Thank you in advance!
Because ag (and grep), find files that contain something. ag -Q means to interpret the search as an exact literal string, not a fuzzy string or a regex. Okay. But a file that has the word "transactions" in it contains exactly, literally the character sequence actions. Sure, it contains more than that too, but that's not surprising.
Probably you're looking for a word-boundary search, grep '\bactions\b' or ag -w -Q actions (maybe ag -w -Q -s actions). But that is not at all the same thing as "just actions", it's a specific requirement on the things surrounding "actions" (namely that they be the beginning or end of a line, or non-letter characters). You have to tell the computer what you actually mean.
I am using a single unified LaTeX doc to create problem sets and solutions:
\item What is one plus one?
\begin{soln}
The answer is "two".
\end{soln}
In LaTeX, I define this environment with (simplified):
\NewEnviron{soln}
{
\ifsolutions\expandafter
\BODY
\fi
}
That is, if \solutionsfalse has been defined in LaTeX, it prints:
1. What is one plus one?
and if \solutionstrue has been defined, it prints:
1. What is one plus one?
** The answer is two **
I'm trying to replicate this in pandoc to generate HTML or MD files from the latex input, but I've run against the wall. Pandoc doesn't honor any kind of /if /else /fi statement in LaTeX, I think. Pandoc doesn't honor the comment environment, which would also work with \excludecomment{soln}. So, I can't come up with a shim.tex file that would replicate the 'ignore stuff in the soln environment'.
The next way to go would, I guess, be to do something in luatex that pandoc can talk to, or to define the custom environment to pandoc with a filter? But the documentation for those systems is extremely heavyweight - there's no easy way in.
Can anyone suggest a solution to this?
Ideally, I want to run two different shell commands. Command A should omit all content in the soln environment. Command B, ideally, should turn all regular text blue, and show all content in the soln environment in black color.
(P.S. The xcolor package also seems unsupported in native pandoc, although there is a filter that doesn't work for me.)
Edit
Following comments by #tarleb and #mb21, I guess I have to try to work out how filters work. Again, the documentation here is terrible - it wants you to know everything before you can do anything.
I tried this:
return {
{
RawBlock = function(elem)
print(elem.text)
if starts_with('\\begin{soln}', elem.text) then
return pandoc.RawBlock(elem.format,"SOLN")
else
return elem
end
end,
}
}
and ran it with
pandoc --lua-filter ifdef.lua --mathjax -s hw01.tex -s -o hw01.html
But there is nothing on stdout from the print statement, and my document is unchanged, so the RawBlocks are apparently not processed by the lua filter unless the -f latex+raw_tex flag is passed. But passing those flags means that pandoc doesn't actually process the \include commands in the latex, so my filter wont' see the subdocuments.
Apparently, the answer is "No, pandoc cannot support new latex environment", because it would require modifying the parser. Although the -f latex+raw_tex can disable big parts of the parser, that just means the document is largely unparsed, which isn't what I want.
Please tell me if I'm wrong.
Amazing people!!
I have a project which needs a TechDebt to be executed where, all the existing code files having 2 space indentation. Now I want to convert all the 2 space indentation to 4 space indentation, is there any way I can automate this process rather going with Manual approach.
Potentially with any sort of Shel scripting in XCode editor configuration settings where I can inject that script and get things done.
Help would be highly appreciated.
Thanks a ton in advance guys.
I think you should be able to do what you're after using Regex in Xcode Find and Replace. Using ⌥⇧⌘F to bring up the Find Navigator, checking Replace is shown. Switch from Text to Regular Expression if not already shown and ensure In Workspace is selected (or change to required scope)
Use ^\s\s for Find and ^\s\s\s\s for Replace. This will replace all 2 space indentation from the start of each line to 4 space indentation.
Leon's answer is close... but that will also change existing 4-leading-spaces to 6, 3-leading to 5, 6-leading to 8, etc...
Try search pattern:
^ [\S]
hard to tell here, but that is ^ followed by two spaces followed by [\S] (beginning of line + two spaces followed by non-whitespace),
replace pattern:
$0
hard to tell here, but that is two spaces + $0 (the matched string)
Hey Guys #DonMag and #Leon Storey
I did a bit research and I found a significant solution which is below :
Install SwiftLint brew install swiftlint
Go to your project in terminal
Execute below command
swiftlint autocorrect --format
There you are!
This will edit all your files automatically and convert them into 4 spacing and also it will fix other formatting errors inside your project if any. For me it was 790 files which got executed just in seconds.
Thanks for the answers guys.
In bash, php/{composer,sismo} expands to php/composer php/sismo. Is there any way to do this with /bin/sh (which I believe is dash), the system shell ? I'm writing git hooks and would like to stay away from bash as long as I can.
You can use printf.
% printf 'str1%s\t' 'str2' 'str3' 'str4'
str1str2 str1str3 str1str4
There doesn't seem to be a way. You will have to use loops to generate these names, perhaps in a function. Or use variables to substitute common parts, maybe with "set -u" to prevent typos.
I see that you prefer dash for performance reasons, however you don't seem to provide any numbers to substantiate your decision. I'd suggest you measure actual performance difference and reevaluate. You might be falling for premature optimization, as well. Consider how much implementation and debugging time you'll save by using Bash vs. possible performance drop.
I really like the printf solution provided by #mikeserv, but I thought I'd provide an example using a loop.
The below would probably be most useful if you wish to execute one command for each expanded string, rather than provide both strings as args to the same command.
for X in composer sismo; do
echo "php/$X" # replace 'echo' with your command
done
You could, however, rewrite it as
ARGS="$(for X in composer sismo; do echo "php/$X"; done)"
echo $ARGS # replace 'echo' with your command
Note that $ARGS is unquoted in the above command, and be aware that this means that its content is wordsplitted (i.e. if any your original strings contain spaces, it will break).
Even though there are lots of grep questions and answers, these don't answer and I need help in this. I need to make
Title-BEX-override-8>"
expressions to become
Title-BEX>"
Any letters or words among Title-BEX and >" should be terminated. I need an exact grep expression for this.
And some optional answers can be about this: I want to do is thin multiple files. And prefer doing this in Mac.
grep cannot do text replacement.
try sed
sed 's/Title-BEX-override-8/Title-BEX/g' file
-i option can let you do it "in place". but I don't know the corresponding option is for your sed on mac.. :(