notepad ++ adjust indentation
-
I usually prefer 4 spaces for tabs when working with code. I have found if I select multiple lines then press tab it will go over 4 spaces. If I select multiple lines then press the space bar it deletes the lines. Is there another way to deal with this?
-
@Bob-Smith said in notepad ++ adjust indentation:
If I select multiple lines then press the space bar it deletes the lines. Is there another way to deal with this?
Have you looked in the Preferences, under Indentation? You can either use the tab character or a space character to indent. You can also select how many positions the indent is.
Terry
PS I should qualify that. As @PeterJones said, it will either fill with a tab or a space. Of course as he says using an actual space character overwrites the selected text.
-
The two are different actions: the
TAB
key is performing the indentation action, based on your settings; hitting the space key is literally typing the space character, and as with any normal selection when you type after making a selection, the entire selection is replaced by what you type.If you want to indent code using spaces instead of tabs, use the Settings > Preferences > Indentation and set the defalt to Space Characters instead of Tab characters – then when you select multiple lines and hit the
TAB
key, it will indent using spaces. (But hitting the spacebar will still overwrite the selection with the space character.) -
@PeterJones Is there a way to select multiple lines and do an action? Is that not the case? Am I just not explaining it clearly? I have seen people do that before when sharing code in presentations. I have seen people add
//
and,
in front of various code.Where is this hiding? Not seeing it. Have the settings been moved around?
@PeterJones said in notepad ++ adjust indentation:
Settings > Preferences > Indentation
-
@Bob-Smith said in notepad ++ adjust indentation:
I usually prefer 4 spaces for tabs when working with code. I have found if I select multiple lines then press tab it will go over 4 spaces. If I select multiple lines then press the space bar it deletes the lines. Is there another way to deal with this?
What you need to do is make a “zero-width rectangular selection” at the beginning of the lines.
Click at the beginning of the first line. Alt+Shift+click at the beginning of the last line. Then type a tab character (or four spaces).
-
Where is this hiding? Not seeing it. Have the settings been moved around?
Sorry, you didn’t say which version you were on, so I assumed a recent version, like v8.7.1 (which was the most recent version to trigger auto-update) – specifically, the option was moved in v8.7 in September of this year, as mentioned in the User Manual. In your older N++ copy, it’s still in the old Settings > Preferences > Language page, instead.
Is there a way to select multiple lines and do an action?
Yes. You’ve already done it: when you select multiple lines, and typed the
TAB
key, you performed the indent action.I have seen people do that before when sharing code in presentations.
I have seen people add//
and,
in front of various code.They do it with the column-mode selection (as @Coises explained while I was typing my reply).
So you could do the column selection, then type the four spaces yourself. But since you are talking about indentation, not generic text, you just need to set indentation to use spaces, and then from then on, you can indent using the
TAB
key but it will use spaces. -
@Bob-Smith said in notepad ++ adjust indentation:
Where is this hiding? Not seeing it. Have the settings been moved around?
Which version of Notepad++ are you running. The preference option is certainly there in the recent versions. You might need to show us your debug info. From the ? menu, select debug info, copy and paste that info here.
As well as the previous post another idea is I think the “Column Editor”. If you want all the lines in your file to have the same prefix, position the cursor at the very start, use column editor and enter the text to be the prefix on EVERY line.
If you just want a group of lines to have a prefix, position the cursor on the first line of the group, use Ctrl + Alt + mouse control to move down the left margin for the group of lines. Then use the column editor to insert a prefix for that group. You could also just type the character(s).
Terry