Am I the only one who has trouble with formatting code?
Is it just me or does everyone have trouble with formatting code within code tags?
I generally don't paste the code in, highlight it and press the 'Code' button because it removes the color coding.
I usually paste it in and then manually add the code tags.
I generally remove any tabs and perform indenting with spaces, but...
Most times after submitting the post, my text gets reformatted which causes me to have to edit the post.
What is the secret here? Can the text included within the code tags just be left alone and displayed as typed?
Is there a way to do this, so the code gets formatted properly (without me having to reedit the post)?
[721 byte] By [
Arjay] at [2007-11-20 10:57:41]

# 1 Re: Am I the only one who has trouble with formatting code?
I haven't noticed anything.
[code] tags just make it as a <pre> tag in HTML. That means that all white-space is preserved. However it appears in notepad, is how HTML should see it.
# 2 Re: Am I the only one who has trouble with formatting code?
How do you post your code? Do you use tabs in the code or white space?
Do you paste the code, highlight it and press the 'Code' button. Or do you add the tags manually?
Arjay at 2007-11-10 3:36:40 >

# 3 Re: Am I the only one who has trouble with formatting code?
I type the code tags first with no spacing. Then just paste the code right in and let it go.
EDIT: If I do highlighting, I do that in my text editor outside of the browser.
# 4 Re: Am I the only one who has trouble with formatting code?
Highlight code, click the code button, and then add editing.
Quoting someone, I bolded something and then highlighted and clicked code.
I was surprised that I didn't lose the bold highlight.
# 5 Re: Am I the only one who has trouble with formatting code?
I type the code tags first with no spacing. Then just paste the code right in and let it go.
EDIT: If I do highlighting, I do that in my text editor outside of the browser.I wasn't clear in the highlighting. What I meant was I select the text and then press the code button.
Is there a way to simply paste text in and not lose the formatting.
If I press the 'CODE' button and pasted perfectly formatted code from Visual Studio, here's what happens.
//+----------------
// Resets the start, pause, resume button state (to start)
//+----------------
void CStartStopDlg::ResetSPRState( )
{
m_ThreadState = TS_STOPPED;
m_btnStartPauseResume.SetWindowText( _T("Start") );
m_ctrlProgress.SetPos( 0 );
m_ctrlList.DeleteAllItems( );
}
To get it to look good, I have to manually indent it with spaces
//+----------------
// Resets the start, pause, resume button state (to start)
//+----------------
void CStartStopDlg::ResetSPRState( )
{
m_ThreadState = TS_STOPPED;
m_btnStartPauseResume.SetWindowText( _T("Start") );
m_ctrlProgress.SetPos( 0 );
m_ctrlList.DeleteAllItems( );
}
Arjay at 2007-11-10 3:39:40 >

# 6 Re: Am I the only one who has trouble with formatting code?
VB.6 (Firefox)
Option Explicit
Private Sub Form_Load()
SetParent Me.hWnd, Form2.hWnd
Me.Move 0, 0, Form2.Width / 2, Form2.Height / 2
End Sub
as I described before... no manual editing.
# 7 Re: Am I the only one who has trouble with formatting code?
VB.6 (Firefox)
Option Explicit
Private Sub Form_Load()
SetParent Me.hWnd, Form2.hWnd
Me.Move 0, 0, Form2.Width / 2, Form2.Height / 2
End Sub
as I described before... no manual editing.What does VB.6 (Firefox) mean? I'm pasting code from Visual studio.
Arjay at 2007-11-10 3:41:49 >

# 8 Re: Am I the only one who has trouble with formatting code?
I'm using Firefox with Visual Studio 6 (vb6)
It works fine for me. What formatting do you have set as your editor?
# 9 Re: Am I the only one who has trouble with formatting code?
Arjay, this might be a problem directly affecting you. Notice that when you quote dglienna...it takes out the indenting. What browser are you using and what's the latest patching on it? Do you have any toolbars?
EDIT:
I use CG's simple editor. Which do you use?
# 10 Re: Am I the only one who has trouble with formatting code?
I'm using IE 7 (7.0.5730.11) on Win2003 Server. I believe it's the advanced CG editor with the toolbar (how do I check for sure)?
Arjay at 2007-11-10 3:44:45 >

# 11 Re: Am I the only one who has trouble with formatting code?
The enhanced editor has known problems. I would suggest just using the basic. You can change this setting in the CP, under Edit Options. Try that and see what happens.
# 12 Re: Am I the only one who has trouble with formatting code?
Ah, it is a bug then? Okay.
I switched to standard mode and it works (unfortunately I lose color coding, but that better than losing the formatting).
//+----------------
// Resets the start, pause, resume button state (to start)
//+----------------
void CStartStopDlg::ResetSPRState( )
{
m_ThreadState = TS_STOPPED;
m_btnStartPauseResume.SetWindowText( _T("Start") );
m_ctrlProgress.SetPos( 0 );
m_ctrlList.DeleteAllItems( );
}
Arjay at 2007-11-10 3:46:52 >

# 13 Re: Am I the only one who has trouble with formatting code?
Looks like that worked. Did you format that?
# 14 Re: Am I the only one who has trouble with formatting code?
No, that was just pasting. Thanks for your help.
You've just saved me an hour a day. :)
Arjay at 2007-11-10 3:48:56 >

# 15 Re: Am I the only one who has trouble with formatting code?
Glad I could help. I prefer the simplicity of just a textbox.
# 16 Re: Am I the only one who has trouble with formatting code?
Believe me, the irony of a bug in the editor on a site full of programmers isn't lost. :D
Arjay at 2007-11-10 3:50:50 >

# 17 Re: Am I the only one who has trouble with formatting code?
I've been out of the office a couple days (I'm at Jupitermedia's corporate headquarters for about another hour). I believe that on VBForums, some of the guys are re-writing the Highlight add-in to fix some of its issues. If they get if fixed, then we will eventually be able to add it here (once this forum is fully upgraded). That feature/code will allow you to post code and have it highlighted (automatically) based on its specific language.
I don't know when the upgrade is happening, but when it does, that will be available.
Brad!
# 18 Re: Am I the only one who has trouble with formatting code?
Thanks Brad.
Arjay at 2007-11-10 3:53:00 >
