Questions tagged [text-formatting]
409 questions
798
votes
6 answers
How to output numbers with leading zeros in JavaScript?
Is there a way to prepend leading zeros to numbers so that it results in a string of fixed length? For example, 5 becomes "05" if I specify 2 places.

chris
- 8,219
- 4
- 18
- 14
245
votes
4 answers
How to write URLs in Latex?
How do you write a URL in Latex?
The subscripts and everything else make the font look very strange when it compiles.

danzig
- 2,467
- 2
- 15
- 3
43
votes
2 answers
Telegram markdown syntax: Bold *and* italic? (September 2018)
By looking at Telegram’s “Markdown Syntax” Wiki page, it should be relatively easy to create text that is bold and italic.
There, it says that
*this is in italic* and _so is this_
**this is in bold** and __so is this__
***this is bold and…

Nemgathos
- 605
- 1
- 5
- 13
41
votes
5 answers
Use a custom thousand separator in C#
I'm trying not to use the ',' char as a thousand separator when displaying a string, but to use a space instead. I guess I need to define a custom culture, but I don't seem to get it right. Any pointers?
eg: display 1000000 as 1 000 000 instead of…

Luk
- 5,371
- 4
- 40
- 55
39
votes
8 answers
Printing with "\t" (tabs) does not result in aligned columns
I have a very weird problem. After writing this:
for (File f : currentFile.listFiles()) {
if (f.isDirectory()){
System.out.println(f.getName()+"\t"+"Dir\t"+Command.getpremission(f)+"\t"+f.getTotalSpace());
}
else{
…

Unknown user
- 44,551
- 16
- 38
- 42
37
votes
5 answers
Why does Vim add spaces when joining lines?
I want to unwrap text in Vim. When I join lines I get an additional space between sentences.
Why is that?

binOr
- 2,551
- 1
- 22
- 18
31
votes
5 answers
What is the WPF XAML Data Binding equivalent of String.Format?
Or, to be more clear, how can I format a block of text (in my case, to be included within a tooltip) such that some portions of the text come from bound values.
In plain C# I would use:
_toolTip.Text = string.Format("{1:#0}% up, {2:#0}% down",
…

Drew Noakes
- 300,895
- 165
- 679
- 742
26
votes
3 answers
how to use "tab space" while writing in text file
SimpleDateFormat formatter = new SimpleDateFormat("ddMMyyyy_HHmmSS");
String strCurrDate = formatter.format(new java.util.Date());
String strfileNm = "Cust_Advice_" + strCurrDate + ".txt";
String strFileGenLoc = strFileLocation + "/" +…

Manu
- 3,179
- 23
- 57
- 69
24
votes
5 answers
How to know the preferred display width (in columns) of Unicode characters?
In different encodings of Unicode, for example UTF-16le or UTF-8, a character may occupy 2 or 3 bytes. Many Unicode applications doesn't take care of display width of Unicode chars just like they are all Latin letters. For example, in 80-column…

Lenik
- 13,946
- 17
- 75
- 103
21
votes
10 answers
Truncate part of text in UILabel
My requirement is that I need to display text in label in such a way that if the length of text is too big to accommodate in one line, i need to truncate it at the end in such a way that only the last few characters(usually a number b/w 1-1000 so…

user2990765
- 387
- 2
- 3
- 16
21
votes
2 answers
Add rich text format functionality to django TextField
I have a django model which contains a description field:
class Product(models.Model):
name = models.CharField(max_length="125")
description = models.TextField()
class ProductForm(ModelForm):
class Meta:
model = Product
def…

Shiva Krishna Bavandla
- 25,548
- 75
- 193
- 313
19
votes
4 answers
Apply multiple font colors to the text in a single Google Sheets cell
I am trying to format a cell to have multiple font colors using a function in Google Apps Script. I am unable to find any documentation on it. Also, using getFontColor() doesn't return anything useful.
Is there any way to programmatically reproduce…

MGomeyy
- 215
- 1
- 2
- 8
19
votes
3 answers
How do I get HTML Tidy to not put newline before closing tags?
HTML Tidy has this infuriating habit of putting a newline before the closing tag. For example:
Some text
becomesSome text
How do I tell Tidy to keep the closing tag on the same line as the end of the content? Btw, I am running Tidy…
markvgti
- 4,321
- 7
- 40
- 62
16
votes
5 answers
Nice bit of code to format an xml string
Anyone got a ready made function that will take an XML string and return a correctly indented string?
eg
A
and will return nicely formatted String in return after inserting linebreaks and tabs or…

Toby Allen
- 10,997
- 11
- 73
- 124
15
votes
5 answers
Set color of text in a Textbox/Label to Red and make it bold
I want a text color to be red in color on certain condition.
Here is how i want to get it done.
string minusvalue = TextBox1.Text.ToString();
if (Convert.ToDouble(minusvalue) < 0)
{
// set color of text in TextBox1 to red color and bold.
}
Is…

Ishan
- 4,008
- 32
- 90
- 153