CMD不需要的行间距

时间:2013-09-08 08:57:13

标签: batch-file cmd line

我正在写一个小程序。当我想要做更多用户友好的界面时,我最终得到了 不需要的行距。我怎么能摆脱它?

这是这种不需要的行间距的图片。

capture http://shrani.si/f/2B/NA/1z2UfrDu/capture.png

这是我的代码:

http://pastebin.com/raw.php?i=42z68tXk

@echo off
echo    --------------------------------------------------------------------------
echo                           WHAT DO YOU WANT TO DO
echo    --------------------------------------------------------------------------
echo    #                                                                        #
echo    #  1 - Random stuff                                                      #
echo    #                                                                        #
echo    #  2 - ghkfhhglk                                                         #    
echo    #                                                                        #
echo    #  3 - jgfjhdchgggggggggggh                                              #          
echo    #                                                                        #
echo    #  4 - hggggggggggggggggggggggdd                                         #         
echo    #                                                                        #
echo    #  5 - gdhhfgdfdfsdfg                                                    #              
echo    #                                                                        #
echo    #  6 - Bfgsgfsfgsfgsg                                                    #     
echo    #                                                                        #
echo    #  7 - hdfhsgsfgsgfsgsfgsfg                                              #          
echo    #                                                                        #
echo    #  8 - ssfgfsgfsgfsfgs                                                   #        
echo    #                                                                        #              
echo    #  9 - shfjhfjfghjkhjjjjjjjjj                                            #      
echo    #                                                                        #       
echo    #                                                                        #
echo    #  00 - fgsgfsfgsgsgf                                                    #          
echo    #  X - sgfsgfsgfsgfsfgs                                                  # 
echo    #                                                                        # 
echo    --------------------------------------------------------------------------
pause >nul

3 个答案:

答案 0 :(得分:4)

为了更好地控制不需要的尾随空格/制表符,只需将其写在括号中:

@echo off
(echo    --------------------------------------------------------------------------)
(echo                           WHAT DO YOU WANT TO DO)
(echo    --------------------------------------------------------------------------)

答案 1 :(得分:3)

您的批处理文件在某些​​行中的最后一个有意义的字符后面有很多不可见的空格。只需清理它们,你的问题就会消失。

有些编辑能够显示不可见的空格或标签,请使用它!

答案 2 :(得分:0)

这是因为空间。 试试这个代码。希望您可以在两个代码部分中可视化滚动条的长度。

@echo off
echo    #                                                                        #
echo    #  1 - Random stuff                                                      #
echo    #                                                                        #
echo    #  2 - ghkfhhglk                                                         #
echo    #                                                                        #
echo    #  3 - jgfjhdchgggggggggggh                                              #
echo    #                                                                        #
echo    #  4 - hggggggggggggggggggggggdd                                         #
echo    #                                                                        #
echo    #  5 - gdhhfgdfdfsdfg                                                    #
echo    #                                                                        #
echo    #  6 - Bfgsgfsfgsfgsg                                                    #
echo    #                                                                        #
echo    #  7 - hdfhsgsfgsgfsgsfgsfg                                              #
echo    #                                                                        #
echo    #  8 - ssfgfsgfsgfsfgs                                                   #
echo    #                                                                        #
echo    #  9 - shfjhfjfghjkhjjjjjjjjj                                            #
echo    #                                                                        #
echo    #                                                                        #
echo    #  00 - fgsgfsfgsgsgf                                                    #
echo    #  X - sgfsgfsgfsgfsfgs                                                  #
echo    #                                                                        #
pause >nul