I use tabs in C/C++ but want to convert those tabs to spaces when copying code that I'm going to paste into an external program. However, I want the original code to retain tabs. Additionally (if possible), I'd like to keep the tabs when copying/pasting within Emacs.
I sort of adapted the code at this link and tried:
(advice-add 'kill-ring-save :before 'untabify)
(advice-add 'kill-ring-save :after 'tabify)
but it doesn't copy all the text and converts away from tabs when copying and pasting within Emacs.
For instance, if I use the above setup on
int main()
{
int i = 5;
}
it only copies
int main()
{
int i
I'm not a Lisp programmer and am relatively new to Emacs, so forgive me if I'm missing something obvious here.