0

I do not know if this has already been adressed or if it just me, but I find the insertion of code into a post in a proper manner using the current method to be quite convoluted.

Honestly, I believe it is a malformed feature and could be made and implemented so much easier.

I dread every time I need to post code here - It seems like a hassle and half of the time it never works for me correctly.

Maybe someone can comment on this and point out the best way to go about it - At this point it seems to be a two-step process. That should not be.

Just my opinion.

Thank you,
Matthew

4
Contributors
3
Replies
47
Views
2 Years
Discussion Span
Last Post by Reverend Jim
0

To paste code I usually place the cursor in a new line and then I press TAB once, for example:

/**
 * Sign Out
 * @return void
 */
public function getOut()
{
    Auth::logout();
    return Redirect::route('sign_in');
}

Usually, it does not require any other adjustment because, in my editor, I always indent the code. Otherwise you have to select the pasted code and press TAB. By pressing Shift Tab, instead, you remove one tab space. So you can adjust the code block as you like. Hope it helps, bye!

0

Let's try cereal's technique

def paire(x):
    return sqrt(-x**2+3*x+4), abs(x-2)

for x in (-0.5, 1, 3.7):
    print x, paire(x)

In kubuntu, I selected code in an editor with ^c, then pasted it in daniweb's editor with ^v, then selected it with a mouse and pressed TAB. It works, but I'd like a way to select several lines without the mouse. For example in the Kate editor, SHIFT+DOWN ARROW selects groups of lines.

Edited by Gribouillis

0

There are three easy ways.

  1. Click the Code tool. This will open a window where you can paste your code. When you click Insert code snippet or press ALT-I, the code will be inserted into your post.

  2. Paste the code directly into your post. If you do it this way remember to leave one blank line above and below the code. You can select one or more lines and press Tab or Shift-Tab to indent or undent the selected block. Note that you don't have to select an entire line to do this. For single lines you can place the text cursor anywhere in the line and indent/undent the same way.

  3. For inline code mixed with non-code you can just select the code and click Inline Code. This will cause the selected text to be rendered in a different font and colour to distinguish it from the non-code.

This is an example x = y * 15 of inline code.

Edited by Reverend Jim

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.