Increase/decrease tab indent in Discourse text editor?


(Walter Stabosz) #1

Is there a way to increase/decrease the tab indent in the Discourse text editor? The normal keyboard shortcuts (tab/shift+tab) are already used by the web browser.

I often copy code from an IDE into the text editor, which results in code blocks that require fix-up like the examples below. The only work-around I know of is to paste the code into Notepad++, and fix the indents there. Fixing the indents in the IDE doesn’t always work because sometimes the code is read only (i.e. Visual Studio when debugger is active, and I don’t want to stop the debugger)

##Examples

							// this is how far the code was indented in the IDE
							for (var i=0;i<100000;i++) {
								console.log(i);
							}

or this

// opps, I didn't start my select block at character zero, 
			//now the first line of my code is indented differently
			for (var i=0;i<100000;i++) {
				console.log(i);
			}

(Sam Saffron) #2

I have seen this quite a lot when I was using Stack Overflow. For code heavy forums that often involve pasting snippets from IDEs this would be handy.


(Manthan Mallikarjun) #3

Is there a way to get Discourse to autoindent?


(Sam Saffron) #4

You don’t need to indent anything you use ``` guards for code. The issue is un-indenting


(Manthan Mallikarjun) #5

Sorry, I meant “Is there a way to get Discourse to auto un-indent?”

It would be great if Discourse had the ability to parse and prettify the code.


(Sam Saffron) #6

I think you could enable conditional SHIFT TAB and TAB support.

You would only use the magical behavior is text is selected in the editor, it would work fine.