Let\'s say I have a batch file that has \"padding\" in it, and I want to indent the beginning of the prompt string for the user to type in. If I use spaces, it will not show up
Highly inspired by in dbenham's answer, I propose a similar but simpler variation based in the fact that the backspace character can be inserted in its raw form (only in batch files, attempting this in the console directly won't work as expected):
set /p var=.'BS' Leading spaces will now show properly.
The 'BS' character can be inserted by typing Alt + Numpad 008 (8 is backspace's ASCII code, won't work using the alphanumeric keys typically found above the letters), using a good text editor (such as Notepad++, Windows Notepad simply performs the backspace action).
If unable to insert the character, Notepad++ has a useful feature for this: in TextFX menu, choose TextFX Tools followed by Insert Ascii Chart or Character:
The desired character is the BS
(white letters on black background on the screenshot) found in line 9 (ASCII character 8
- as stated above - as it's a zero-indexed table).
If still the result is not the one described, try changing the file encoding to ASCII. Using Notepad++:
Tested with Windows 7 Professional SP1.
Credits also go to: