I'm currently working on an application in Eclipse where I'm running a really huge SQL statement that spans about 20 lines when splitting it in notepad to fit on the screen. Thus I want the string for the query also to be formatted somewhat more readable than a single line. All the time autoformatting normally worked when I used Eclipse but somehow now neither Ctrl + Alt + F nor rightclicking and selecting the "Format" option from the menu doesn't work to get a line break after a certain amount of characters.
I already checked the preferences where I already tried running my own profile with 120 and 100 characters line width but that didn't fix anything so far. I really don't know why Eclipse won't let me format this anymore. Normally Eclipse would be splitting the string into several lines in this case but I don't really know why this doesn't work anymore.
However other formatting is being fixed when executing autoformatting (e.g. if(xyz){ still becomes if (xyz) {.
Thank you for your help in advance.
As far as I can tell, autoformat as you described was never supported (at least as far back as 2008). And I have been using Eclipse much longer than that
You can do one of several things.
Simply insert the cursor in the string and hit a return.
Toggle word wrap Alt-Shift-Y
Try writing a regex to do what you want(not certain if this will work).
Related
Hy all,
In IntelliJ I have set the "Hard wrap at" limit to 100 lines and want all lines that are longer then that to be wrapped by IntelliJ (including Indentation of course) when I reformat the file.
This works for everything except long method names in one of my interfaces (Note: Purple underline is checkstyle which also says its too long):
This alone would not be a huge issue, I can just make a line break myself.
The main issue is, that a manual line break puts the method name on the same indentation level as the method description (which again checkstyle correctly does not like) and when I indent it manually, a reformat of the file moves the line back to this level. So IntelliJs reformat file moves it to the wrong location.
Does somebody have any idea, which setting this is and what I have to change to at least have the correct indentation and at best also the corret wrapping?
Greets
Chris
I need to insert Java/Android code into Latex/Lyx, and I would like to highlight Java comments with a certain colour. I have done it earlier in the document, but now when I try the same code, it is not working for some reason. One difference between the codes are, that the one I'm now trying to insert is Android Java-code, and the former was pure Java, could that have an affect? The settings I'm using in the both cases are these:
\def\listingsfont{\ttfamily}
\lstset{language=Java}
\lstset{basicstyle=\ttfamily\scriptsize}
\lstset{keywordstyle=\color{blue}\ttfamily}
\lstset{stringstyle=\color{red}\ttfamily}
\lstset{commentstyle=\color{green}\ttfamily}
\lstset{breaklines=true}
\lstset{tabsize=2}
\begin{lstlisting}[frame=single] % Start your code-block
So first time working, second time not any more. What happens is, that all comment marks (//) appear as blue, but only the marks, not the whole comments with them. Strings are highlighted correctly.
EDIT: I have gained some new information what is happening. After the first time, when this code was working, I have a latex code where language is set as R. If I insert this code before the code that is written in R, all is working as it should. But if I insert the code after the code that is written in R, then it is no longer working. So something weird happens there.
EDIT2: For testing purposes, I changed the settings for the R-code as (language=Java). What happened was, that after that, all the Java code in the latex appeared correctly. So apparently, setting language as R breaks Lyx/Latex somehow to not being able to highlight other languages.
If you use \lstset, this is the default for the whole document. Try setting the language of each listing in LyX separate instead (through the settings you reach in the context menu of the program listing)
in our company we recently changed the used line width from like 80 to 150.
Now it is quite annoying that all code is - of course - wrapped after 100 characters, as this was the previous setting.
We use save actions to run the format settings and it all works wonderful in the one direction: wrap too large lines.
But what I need now: UNWRAP me all lines as I now got enough space available, USE it. Is there a possibility to do that in form of a format setting? I couldn't find any
I now got this line (extremly) wrapped as there were not enough space:
final List<SomeSuperDuperType>
mySuperDuperListOfSuperDuperTypes =
CrazyUtils.gimmeSomeCrazyStuffAsList(
parameter1, parameter2);
Now, with more space available, this code is still correctly formatted as it doesn't exceed the limit. Though I want to actually USE that extra space and make the line now like this (length=133):
final List<SomeSuperDuperType> mySuperDuperListOfSuperDuperTypes = CrazyUtils.gimmeSomeCrazyStuffAsList(parameter1, parameter2);
On Eclipse, go to Window>Preferences>Java>Code Style>Formatter, edit the active profile, and you'll find what you're looking for under the tab Line Wrapping.
Then, select all your code (CTRL+A) and use CTRL+Shift+F to format the text using these new setttings.
Im new to Docx4j and my task is to replace some Text of a docx Template.
I read the getting Started Guide of docx4j but I don't think I fully understood the whole concept.
Well Anyway... I already tried [the unmashalling Template of Docx4j][1],
which worked fine with the given docx, but then I got the same Problem when I tried it on my own template
The Exceptions say, that the HashMap doesnt contain valid keys or values, and therefore it doesnt replace the placeholders.
I replaced the
<w:proofErr w:type="spellEnd"/>
by disabling the spellchecking, but it still didn't work... And it also takes quite some time to run the app.
In didn't understand the databound example in the Getting_Started.pdf, so I'm running out of options...
How can I simply replace some String-Texts from a docx?
EDIT:
I found out that if I add some Text to the unmarshallFromTemplate.docx and save it, that it wont replace the new lines of text.
the - Tags are somehow splitted into multiple Tags:
<w:p w:rsidR="002512F8" w:rsidRDefault="002512F8" w:rsidP="002512F8"><w:r><w:t>My</w:t></w:r><w:r w:rsidR="001A5174"><w:t xml:space="preserve"> favourite ice cream is ${DEGREE</w:t></w:r><w:r><w:t>}.</w:t></w:r><w:bookmarkStart w:id="0" w:name="_GoBack"/><w:bookmarkEnd w:id="0"/></w:p>
editing the Text in the document.xml, and adding the missing Information didnt help much.
well anyway here is the document.xml of the Template.docx that im using:
http://uploaded.net/file/vz4qr23o
EDIT 2:
Well guys. I found a quite suitable workaround for myself and dont know why it took so long to figure it out.
As I was saying: The runs where splited up, and the reason for this was the ${} in my opinion. Therefore I simply used a # before my Placeholders and rewrote every placeholder, so that it would all be in one run.
Had to switch couple of times to the document.xml and rewrite the passages but then it worked. Then I simply used a replace(placeholder, xml) and replaced the text of the marshalled document.xml, then I unmarshalled it again.
Worked. End of Story, fuck the nightly build or the mappings. THX
docx4j source code has been on GitHub for a while now; that svn repository is obsolete.
The equivalent sample is now called VariableReplace. That code is a bit more efficient, but you need to build it yourself, or use a current nightly build.
You'll probably find running VariablePrepare addresses your issue.
The placeholder search and replace code built in to docx4j works just fine, but if you're having issues with placeholders getting broken up by rsid entities, you need to ensure that you have grammar and spell-checking disabled when saving your "template" (i.e. source) document. This will help prevent your text runs becoming fragmented (note that you might want to disable proof-reading too, as that inserts bookmark tags here there and everywhere).
Once you've done the search and replace and have a new / updated document, you can re-enable spell-checking easily enough. This thread has more on RSIDs: turnoff rsid's spell check & grammar check in generated xml
I know there are hundreds of questions asking how to update already written text on console and I know I can do it printing the \r character.
My issue comes when I use Console.readPassword or Console.readLine which creates a new line and later I can't overwrite it.
I think that my issue isn't related to something special about the Console.read* methods but to new lines. \r goes to the start of the current line, I need to be able to go to the start of the previous N line and start overwriting from there. Or just clear the entire screen.
Any ideas how can I do this?
Thanks.
In principle, this is terminal dependent, and with simple Java means there is no way to do this for all consoles.
Many terminals (at least in unixoid systems) support ANSI-escape sequences, so you can there write something like "\u001B[1;5H" to move the cursor to line 1, columnn 5.