[{"data":1,"prerenderedAt":328},["ShallowReactive",2],{"lesson-2026-03-25":3},{"id":4,"title":5,"body":6,"date":312,"description":313,"difficulty":314,"extension":315,"format":316,"meta":317,"navigation":263,"path":318,"progression":122,"seo":319,"stem":320,"subtopic":321,"tags":322,"tldr":325,"topic":108,"triggered":326,"__hash__":327},"lessons\u002Flessons\u002F2026-03-25.md","Registers: Vim's Hidden Clipboard System",{"type":7,"value":8,"toc":305},"minimark",[9,21,26,29,88,92,103,132,135,173,177,183,194,198,205,214,232,236,239,298,301],[10,11,12,13,17,18,20],"p",{},"Most Vim users know ",[14,15,16],"code",{},"y"," and ",[14,19,10],{},". Fewer know that every yank and delete operation writes to a register — and that you can control exactly which one.",[22,23,25],"h2",{"id":24},"the-register-landscape","The Register Landscape",[10,27,28],{},"Vim maintains several categories of registers:",[30,31,32,43,49,58,64,70,76,82],"ul",{},[33,34,35,38,39,42],"li",{},[14,36,37],{},"\"a"," through ",[14,40,41],{},"\"z"," — 26 named registers you control explicitly",[33,44,45,48],{},[14,46,47],{},"\"0"," — the yank register (last yanked text, untouched by deletes)",[33,50,51,38,54,57],{},[14,52,53],{},"\"1",[14,55,56],{},"\"9"," — the delete history (a stack of your last 9 deletes)",[33,59,60,63],{},[14,61,62],{},"\"+"," — the system clipboard",[33,65,66,69],{},[14,67,68],{},"\"_"," — the black hole register (deletes without saving)",[33,71,72,75],{},[14,73,74],{},"\"."," — the last inserted text",[33,77,78,81],{},[14,79,80],{},"\"%"," — the current filename",[33,83,84,87],{},[14,85,86],{},"\":"," — the last ex command",[22,89,91],{"id":90},"using-named-registers","Using Named Registers",[10,93,94,95,98,99,102],{},"Prefix any yank or delete with ",[14,96,97],{},"\"x"," where ",[14,100,101],{},"x"," is the register letter:",[104,105,110],"pre",{"className":106,"code":107,"language":108,"meta":109,"style":109},"language-vim shiki shiki-themes github-light","\"ayy    \" yank current line into register a\n\"Ayy    \" append current line to register a (uppercase = append)\n\"ap     \" paste from register a\n","vim","",[14,111,112,120,126],{"__ignoreMap":109},[113,114,117],"span",{"class":115,"line":116},"line",1,[113,118,119],{},"\"ayy    \" yank current line into register a\n",[113,121,123],{"class":115,"line":122},2,[113,124,125],{},"\"Ayy    \" append current line to register a (uppercase = append)\n",[113,127,129],{"class":115,"line":128},3,[113,130,131],{},"\"ap     \" paste from register a\n",[10,133,134],{},"The uppercase trick is particularly powerful. Build up a collection of lines from different parts of a file by appending to the same register:",[104,136,138],{"className":106,"code":137,"language":108,"meta":109,"style":109},"\"ayy    \" first line into register a\njj\n\"Ayy    \" another line appended to a\n5G\n\"Ayy    \" yet another line appended\n\"ap     \" paste all three lines together\n",[14,139,140,145,150,155,161,167],{"__ignoreMap":109},[113,141,142],{"class":115,"line":116},[113,143,144],{},"\"ayy    \" first line into register a\n",[113,146,147],{"class":115,"line":122},[113,148,149],{},"jj\n",[113,151,152],{"class":115,"line":128},[113,153,154],{},"\"Ayy    \" another line appended to a\n",[113,156,158],{"class":115,"line":157},4,[113,159,160],{},"5G\n",[113,162,164],{"class":115,"line":163},5,[113,165,166],{},"\"Ayy    \" yet another line appended\n",[113,168,170],{"class":115,"line":169},6,[113,171,172],{},"\"ap     \" paste all three lines together\n",[22,174,176],{"id":175},"the-yank-register-trick","The Yank Register Trick",[10,178,179,180,182],{},"Here's the scenario: you yank a line, then delete something to make room, then try to paste — but ",[14,181,10],{}," pastes the deleted text, not the yanked line.",[10,184,185,186,189,190,193],{},"The fix: ",[14,187,188],{},"\"0p",". Register ",[14,191,192],{},"0"," always holds your last yank, unaffected by delete operations.",[22,195,197],{"id":196},"pro-tip","Pro Tip",[10,199,200,201,204],{},"Use ",[14,202,203],{},":reg"," to see the contents of all registers at any time. Better yet, map it:",[104,206,208],{"className":106,"code":207,"language":108,"meta":109,"style":109},"nnoremap \u003Cleader>r :registers\u003CCR>\n",[14,209,210],{"__ignoreMap":109},[113,211,212],{"class":115,"line":116},[113,213,207],{},[10,215,216,217,219,220,223,224,227,228,231],{},"When you're refactoring, use named registers as staging areas. Yank the replacement text into ",[14,218,37],{},", then navigate and use ",[14,221,222],{},"ciw"," followed by ",[14,225,226],{},"Ctrl-R a"," in insert mode to paste from register ",[14,229,230],{},"a"," without leaving insert mode.",[22,233,235],{"id":234},"example","Example",[10,237,238],{},"A real workflow for renaming a variable across a function:",[104,240,242],{"className":106,"code":241,"language":108,"meta":109,"style":109},"\" Yank the new name into register n\n\u002FnewVariableName\n\"nyiw\n\n\" Now find each old name and replace\n\u002FoldVariableName\nciw\u003CC-r>n\u003CEsc>\n\n\" Repeat with n (find next) and . (repeat change)\nn.n.n.\n",[14,243,244,249,254,259,265,270,275,281,286,292],{"__ignoreMap":109},[113,245,246],{"class":115,"line":116},[113,247,248],{},"\" Yank the new name into register n\n",[113,250,251],{"class":115,"line":122},[113,252,253],{},"\u002FnewVariableName\n",[113,255,256],{"class":115,"line":128},[113,257,258],{},"\"nyiw\n",[113,260,261],{"class":115,"line":157},[113,262,264],{"emptyLinePlaceholder":263},true,"\n",[113,266,267],{"class":115,"line":163},[113,268,269],{},"\" Now find each old name and replace\n",[113,271,272],{"class":115,"line":169},[113,273,274],{},"\u002FoldVariableName\n",[113,276,278],{"class":115,"line":277},7,[113,279,280],{},"ciw\u003CC-r>n\u003CEsc>\n",[113,282,284],{"class":115,"line":283},8,[113,285,264],{"emptyLinePlaceholder":263},[113,287,289],{"class":115,"line":288},9,[113,290,291],{},"\" Repeat with n (find next) and . (repeat change)\n",[113,293,295],{"class":115,"line":294},10,[113,296,297],{},"n.n.n.\n",[10,299,300],{},"This is faster than a substitution command when you want to review each replacement individually.",[302,303,304],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":109,"searchDepth":122,"depth":122,"links":306},[307,308,309,310,311],{"id":24,"depth":122,"text":25},{"id":90,"depth":122,"text":91},{"id":175,"depth":122,"text":176},{"id":196,"depth":122,"text":197},{"id":234,"depth":122,"text":235},"2026-03-25","Most Vim users know y and p. Fewer know that every yank and delete operation writes to a register — and that you can control exactly which one.","intermediate","md","deep-dive",{},"\u002Flessons\u002F2026-03-25",{"title":5,"description":313},"lessons\u002F2026-03-25","registers",[108,321,323,324],"clipboard","productivity","Vim has 26+ named registers that act like individual clipboards. Master them and you'll never lose a yanked line again.",false,"pIwKA40SKrLQKN-fA1DJzRM99p9S4wlurRjOfnHBUZY",1775249074072]