Hey guys, what is the best way to copy text within vim? I have been using `yank` . . .

SaidBen:
Hey guys, what is the best way to copy text within vim? I have been using yank but it does add tab/special characters; $ kubectl apply -f file.yaml fails in many occasions for me bc yank adds tab characters or something of that nature.

Fernando Jimenez:
Hi @SaidBen
Try to add the following line to your ~/.vimrc and see if that helps.

autocmd FileType yaml,yml setlocal ai et sw=2 sts=2 ts=2

That line will treat files ending in yaml or yml with some consideration to space and tabs.

Karim Meslem:
I usually use the vim substitute command :1,$s%\t% %g to replace all tab characters with spaces, or :1,$s%\t%%g to replace all tab characters with nothing.

SaidBen:
Thanks a lot @Fernando Jimenez @Karim Meslem, will take note of those.
I do not have this issue with I paste from k8s doc using shift+insert only when I use yank in vim

Karim Meslem:
shift insert is a cool alternative indeed. Unfortunately I couldn’t find an insert key on my macbook, looking for alternatives or shortcuts that achieve the same in macos. Any ideas anyone?

1 Like

SaidBen:
Found this online, give it a try >> The 'insert' function can be recreated on a macOS system by clicking on 'Fn' and 'Enter.'