خالی جگہ صاف کرنے والا

استعمال کا طریقہ 3 مراحل
  1. اپنا عبارت چسپاں کریں۔
  2. مطلوبہ صفائیوں پر نشان لگائیں: لائنیں تراشنا، خالی جگہ سمیٹنا، خالی لائنیں ہٹانا، ٹیب بدلنا۔
  3. صاف کریں دبائیں، پھر کاپی کریں۔
صاف شدہ عبارت

نان بریکنگ اسپیس، زیرو وڈتھ جوائنر اور بائٹ آرڈر مارک عام طور پر اُس عبارت کی وجہ ہوتے ہیں جو دیکھنے میں ٹھیک لگتی ہے مگر CSV درآمد یا URL سلگ خراب کر دیتی ہے۔ یہ بتاتا ہے کہ کتنے ملے۔

یہ ٹول کیسے کام کرتا ہے

ویب صفحے، ورڈ پروسیسر یا PDF سے نقل کی گئی عبارت اکثر ایسے حروف ساتھ لے آتی ہے جو خالی جگہ لگتے ہیں مگر ہیں نہیں: نہ ٹوٹنے والی خالی جگہیں، CJK کمپوزنگ میں استعمال ہونے والی چوڑی خالی جگہ، صفر چوڑائی والی خالی جگہیں اور جوڑنے والے نشان، اور وہ بائٹ آرڈر نشان جو بہت سی برآمد شدہ فائلوں کے شروع میں ہوتا ہے۔ یہ تلاش، موازنے اور کوڈ کو خراب کرتے ہیں، اور جب آپ انہیں ڈھونڈ رہے ہوں تو نظر ہی نہیں آتے۔ ہر ملنے والے کو یا تو عام خالی جگہ میں بدل دیا جاتا ہے یا، جہاں اس کی کوئی چوڑائی ہی نہ ہو، سرے سے ہٹا دیا جاتا ہے، اور کتنے ملے یہ بتا دیا جاتا ہے۔

باقی عمل ایک مقررہ ترتیب سے چلتے ہیں: پہلے نظر نہ آنے والے حروف، پھر ٹیب کو ایک سے آٹھ کے درمیان چنی ہوئی خالی جگہوں میں پھیلانا، پھر خالی جگہوں اور ٹیبوں کے سلسلوں کو ایک خالی جگہ میں سمیٹنا، پھر ہر سطر کے آگے پیچھے کی خالی جگہ کترنا، پھر خالی سطریں ہٹانا۔ سمیٹنا اور کترنا سطری ٹوٹوں کو کبھی نہیں چھیڑتے، اس لیے دستاویز کی شکل صرف آخری اختیار سے بدلتی ہے۔

چلانے سے پہلے جاننے کے قابل نکات

  • بتایا گیا عدد خالص فرق ہے: ٹیب پھیلانے سے حروف بڑھتے ہیں، اس لیے ٹیبوں سے بھری دستاویز شروع سے لمبی ختم ہو سکتی ہے اور عدد اسی کو ظاہر کرے گا، اس پر پردہ نہیں ڈالے گا۔
  • صفر چوڑائی والے حروف ہٹا دیے جاتے ہیں، بدلے نہیں جاتے: ان کی کوئی چوڑائی تھی ہی نہیں۔ نہ ٹوٹنے والی اور دوسری غیر معمولی خالی جگہیں عام خالی جگہ بن جاتی ہیں، کیونکہ وہاں کچھ ہونا مقصود تھا۔
  • کوڈ میں احتیاط چاہیے: سلسلے سمیٹنا اور سطریں کترنا وقفہ بندی چپٹی کر دے گا۔ سورس فائلوں کے لیے ٹیب پھیلائیں اور نظر نہ آنے والے حروف صاف کریں، باقی دو کو چھوڑ دیں۔
  • آخری اختیار کے سوا سطری ٹوٹیں ہر چیز سے بچ جاتی ہیں: صرف خالی سطریں ہٹانا یہ بدلتا ہے کہ آخر میں آپ کے پاس کتنی سطریں ہوں گی۔ باقی سب کچھ انہی سطروں کے اندر کام کرتا ہے جو پہلے سے موجود ہیں۔

The character count can go up

That surprises people, and it is correct.

Expanding a tab into four spaces adds three characters. If your text has more tabs than it has runs of redundant spaces, cleaning it makes it longer. The tool reports the net difference honestly rather than assuming the number must fall.

The [msm_tool slug="whitespace-cleaner"] does several distinct jobs, and it is worth knowing which you actually want.

The operations, and when each matters

  • Trailing whitespace — spaces at the end of a line. Invisible in almost every editor, and the single most common cause of a diff showing changes you cannot see. Removing it is nearly always safe and nearly always worth doing.
  • Leading whitespace — indentation. Safe in prose. Destructive in Python, YAML and Markdown code blocks, where indentation is syntax.
  • Multiple spaces to one — tidies the double space after a full stop and the accidental triple space mid-sentence.
  • Blank lines — collapsing runs of empty lines to one. Useful on text pasted out of a PDF; destructive on Markdown, where a blank line separates paragraphs.
  • Tabs to spaces — or the reverse. A preference in code, and it should match whatever the project already does.

Where whitespace is meaningful

Run the wrong operation on the wrong content and the result is broken rather than tidy:

  1. Python. Indentation defines block structure. Stripping it destroys the program.
  2. YAML. Same — nesting is expressed entirely through indentation, and a valid file with the wrong indentation means something different.
  3. Markdown. Four leading spaces marks a code block; two trailing spaces force a line break; a blank line separates paragraphs. All three are whitespace that carries meaning.
  4. Fixed-width data. Column-aligned text where position is the delimiter.
  5. Poetry and formatted quotations, where the line shape is the point.

Invisible characters that are not spaces

The awkward ones. Text copied from a website or a word processor frequently carries characters that look like spaces and are not:

  • Non-breaking spaces — common in text pasted from HTML or Word. They look identical to a normal space and behave differently, and they break string comparisons and searches.
  • Zero-width characters — invisible entirely, and a known source of mystery bugs in identifiers, passwords and API keys.
  • Other Unicode spaces — en space, em space, thin space, all of which display as a gap and are not the space character.

If two strings look identical and refuse to match, one of these is usually why.

The usual reasons to clean

  • Text pasted from a PDF, which arrives with line breaks at every visual line and inconsistent spacing throughout.
  • Content moving between a word processor and a CMS, which carries non-breaking spaces and stray formatting.
  • Preparing text for comparison, where invisible differences would otherwise dominate the result.
  • Tidying a code file before committing, where trailing whitespace produces noise in every future diff.

Work on a copy

Cleaning is not reversible, and the operations that are destructive are destructive in ways that are not obvious until later — a YAML file that still parses but nests differently, a Markdown document whose code blocks became paragraphs. Keep the original until you have checked the result.

اکثر پوچھے گئے سوالات

خاص طور پر خالی جگہ صاف کرنے والا کے بارے میں۔ اس زمرے سے متعلق عمومی سوالات کے جواب زمرے کے صفحے پر موجود ہیں۔

ٹیب کا پھیلاؤ۔ ایک ٹیب کئی خالی جگہیں بن جاتا ہے، اور اگر دستاویز میں بہت سے ٹیب تھے تو یہ ہر ہٹائی گئی چیز پر بھاری پڑ جاتا ہے۔ عدد خالص تبدیلی ہے۔
ایک نظر نہ آنے والا حرف جو سطر توڑنے کے اشارے اور عبارت کی ساخت کے لیے استعمال ہوتا ہے۔ یہ ویب صفحات، ورڈ پروسیسر اور برآمد شدہ PDF فائلوں سے نقل کرنے کے ساتھ آ جاتا ہے۔
سلسلے سمیٹنا اور سطریں کترنا کر دیں گے۔ ٹیب پھیلانا اور نظر نہ آنے والے حروف صاف کرنا محفوظ ہیں؛ سورس فائلوں کے لیے باقی دو اختیارات بند رکھیں۔
نہیں۔ یہ اپنا الگ اختیار ہے، اور یہی واحد اختیار ہے جو واپس ملنے والی سطروں کی تعداد بدلتا ہے۔
تقریباً ہمیشہ وہاں نہ ٹوٹنے والی خالی جگہ ہوتی ہے جہاں عام خالی جگہ متوقع ہو۔ دونوں ایک جیسی دکھتی ہیں اور مختلف حروف کے طور پر موازنہ ہوتا ہے۔

نئے ٹولز، خصوصیات اور کارکردگی بڑھانے کے مشوروں کی اطلاع پانے کے لیے سبسکرائب کریں۔