{"id":133,"date":"2026-11-21T09:20:00","date_gmt":"2026-11-21T09:20:00","guid":{"rendered":"https:\/\/www.masters-tool.com\/blog\/?p=133"},"modified":"2026-11-11T03:39:07","modified_gmt":"2026-11-11T03:39:07","slug":"tab-to-spaces-before-pasting-into-strict-linters","status":"publish","type":"post","link":"https:\/\/www.masters-tool.com\/blog\/tab-to-spaces-before-pasting-into-strict-linters\/","title":{"rendered":"Convert Tabs to Spaces Before Pasting Into Strict Linters"},"content":{"rendered":"<p><strong>TL;DR \/ Summary:<\/strong> Tabs copied from one editor can fail CI the moment a repo enforces spaces-only indentation. Convert tabs to the project\u2019s space width before you paste into a review comment, a web IDE, or a ticket snippet\u2014then lint sees what you intended, not a mix of invisible characters.<\/p>\n<h2>Why a \u201cclean\u201d paste still fails lint<\/h2>\n<p>Your local editor may render a tab as four columns while the remote linter expands tabs as eight, or rejects tabs entirely. The visual alignment you trusted in the browser preview collapses when ESLint, RuboCop, or gofmt runs on a spaces-only tree. Reviewers then argue about style instead of the logic you meant to share.<\/p>\n<p>Mixed indentation is worse: a file that already uses spaces gains a pasted block with tabs. Many formatters treat that as an error, not a soft warning, and the build goes red on a one-line hotfix.<\/p>\n<h2>Detect tabs before you blame the rule<\/h2>\n<p>Turn on visible whitespace in your editor, or pipe the clipboard through a check that flags U+0009. If you only look at the rendered gutter, tabs and spaces look identical. A quick convert-and-diff cycle on a throwaway buffer shows whether the problem is width or character identity.<\/p>\n<p>Online text utilities that expand tabs to a chosen width help when you are mid-ticket and cannot open the full IDE. Paste, set width to match <code>.editorconfig<\/code> or the repo\u2019s documented indent, copy the spaced result back. Tools on <a href=\"https:\/\/www.masters-tool.com\/\">Masters Tool<\/a> fit that clipboard-first workflow when you are away from your usual setup.<\/p>\n<h2>Match width to the project, not to muscle memory<\/h2>\n<p>Python projects often want four spaces; Go wants tabs that <code>gofmt<\/code> owns; many JavaScript trees want two spaces. Expanding every tab to four spaces into a two-space repo still fails prettier. Read the nearest config file before converting. Wrong width is still wrong even when every tab is gone.<\/p>\n<p>Makefiles are the classic exception: recipe lines must start with a real tab. Converting those to spaces breaks Make itself. Scope your conversion to source and config languages that document spaces, and leave Makefile recipes alone.<\/p>\n<h3>Snippet comments in GitHub and Jira<\/h3>\n<p>Fenced code blocks in tickets often preserve tabs until someone copies them into a patch. If your team pastes \u201csuggested fix\u201d blocks into PRs, convert first so the suggestion applies cleanly with \u201cCommit suggestion.\u201d Otherwise the author spends a commit fighting whitespace noise.<\/p>\n<h2>EditorConfig and CI should agree<\/h2>\n<p>When <code>indent_style = space<\/code> lives in EditorConfig but the CI formatter still accepts tabs, onboarding becomes tribal knowledge. Align both sides. Developers who convert tabs before paste are compensating for that gap; fixing the gap removes the ritual for everyone.<\/p>\n<p>If you maintain a monorepo with mixed languages, document per-package indent rules in the contributing guide with one concrete example each. Ambiguous \u201cuse project defaults\u201d language is how tabs sneak into the wrong package.<\/p>\n<h2>A safe convert workflow for hotfixes<\/h2>\n<p>Copy the suspect block into a scratch buffer. Expand tabs to the repo width. Run the same formatter the CI uses on that buffer if available. Paste into the PR or patch. Avoid converting an entire legacy file in the same commit as a behavioral fix\u2014reviewers cannot see the real change under a thousand indent flips.<\/p>\n<p>For emergency patches on a phone browser, do the expand step in a text tool first, then paste into the web editor. Mobile keyboards rarely expose a clear tab-versus-space signal.<\/p>\n<h2>When soft tabs hide the problem<\/h2>\n<p>Some editors insert spaces when you press Tab (\u201csoft tabs\u201d) but still leave literal tabs in older files. You can believe you \u201calways use spaces\u201d while the file on disk disagrees. A project-wide search for the tab character before a release branch cut catches surprises that soft-tab muscle memory misses.<\/p>\n<p>Binary or generated files should stay out of that search. Limit scans to source globs your formatter already owns.<\/p>\n<h2>Teaching the habit without shaming<\/h2>\n<p>New contributors often paste from tutorials that used tabs for brevity. Link the indent rule and a one-click convert path in the first review comment instead of only citing the failed job URL. The goal is a green build and a clearer diff, not a purity contest.<\/p>\n<p>Keep a short internal note: language, required style, convert tip, formatter command. That note saves more time than another debate in Slack about whether tabs are morally superior.<\/p>\n<h2>Clipboard hygiene for multi-file pastes<\/h2>\n<p>When you assemble a reproduction from three files, convert each block separately at its own width. A YAML sidecar that wants two spaces next to a Python module that wants four will break if you run one global expand. Label each paste with the path so reviewers know which rule applied.<\/p>\n<p>If you regularly move snippets between stacks, a dedicated convert pass on <a href=\"https:\/\/www.masters-tool.com\/\">Masters Tool<\/a> before the ticket update is faster than re-indenting by hand in the browser.<\/p>\n<h2>PR bots that rewrite only half the file<\/h2>\n<p>Some repositories run a formatter on changed lines only. A pasted tab inside a spaces file can survive if the bot formats solely the hunk boundaries and leaves the middle untouched. Full-file format jobs catch the mix; partial jobs do not. When you know CI uses a sparse formatter, convert before paste rather than hoping the bot will finish the job.<\/p>\n<p>Pre-commit hooks on your laptop that expand tabs locally prevent the round trip entirely. Install the same hook the repo documents so your clipboard habit and the hook agree on width. If the hook and EditorConfig disagree, fix that conflict once instead of teaching every contributor a private convert ritual.<\/p>\n<p>Patch files downloaded from review tools sometimes reintroduce tabs when the web UI normalizes whitespace for display. Re-open the downloaded patch in a hex-aware or visible-whitespace view before applying it with <code>git apply<\/code>.<\/p>\n<h2>Indent that survives the pipeline<\/h2>\n<p>Tabs are not evil; mismatched indentation is. Convert to the width and style your linter already enforces before the paste lands in a PR, a gist, or a support ticket. The characters you cannot see are the ones that burn the most CI minutes\u2014fix them on purpose, once, before the bot does it the hard way.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>TL;DR \/ Summary: Tabs copied from one editor can fail CI the moment a repo enforces spaces-only indentation. Convert tabs to the project\u2019s space width before you paste into a review comment, a web IDE, or a ticket snippet\u2014then lint sees what you intended, not a mix of invisible characters. Why a \u201cclean\u201d paste still [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":40,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-133","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-everyday-workflows","entry","has-media"],"_links":{"self":[{"href":"https:\/\/www.masters-tool.com\/blog\/wp-json\/wp\/v2\/posts\/133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.masters-tool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.masters-tool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.masters-tool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.masters-tool.com\/blog\/wp-json\/wp\/v2\/comments?post=133"}],"version-history":[{"count":1,"href":"https:\/\/www.masters-tool.com\/blog\/wp-json\/wp\/v2\/posts\/133\/revisions"}],"predecessor-version":[{"id":134,"href":"https:\/\/www.masters-tool.com\/blog\/wp-json\/wp\/v2\/posts\/133\/revisions\/134"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.masters-tool.com\/blog\/wp-json\/wp\/v2\/media\/40"}],"wp:attachment":[{"href":"https:\/\/www.masters-tool.com\/blog\/wp-json\/wp\/v2\/media?parent=133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.masters-tool.com\/blog\/wp-json\/wp\/v2\/categories?post=133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.masters-tool.com\/blog\/wp-json\/wp\/v2\/tags?post=133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}