2 Created the functions after testing it out.
source | link

First off, that's a shitty style enforcement and you have my sympathies. Instead of hiding how about creating a mapping or functions (like shown below) for deleting the unnecessary lines before editing and adding them when you're done ? something along the lines (untested):

function! Clean()
    %s/{\n^$/{/g
    %s/^$\n^$\n\(\s*}\)/}\1/g
endfunction

function! Pollute()
    %s/{$/{^M\r/g
    %s/\(\s*}$\)/^M}\r\1/g
endfunction

...or some such.

The basic idea begin, delete the empty lines at read and replace them at write (didn't, didn't try it but I feel like this can be doneadded as an autocmd). like so:

Note the ^M above is got by typing Ctrl-v followed by an Enter.

au BufReadPost *.cpp call Clean()
au BufWritePost *.cpp call Pollute()

First off, that's a shitty style enforcement and you have my sympathies. Instead of hiding how about creating a mapping for deleting the unnecessary lines before editing and adding them when you're done ? something along the lines (untested):

%s/{\n^$/{/g
%s/^$\n}/}/g

%s/{$/{^M/g
%s/}$/^M}/g

...or some such.

The basic idea begin, delete the empty lines at read and replace them at write (didn't try it but I feel like this can be done as an autocmd).

Note the ^M above is got by typing Ctrl-v followed by an Enter.

First off, that's a shitty style enforcement and you have my sympathies. Instead of hiding how about creating a mapping or functions (like shown below) for deleting the unnecessary lines before editing and adding them when you're done ? something along the lines:

function! Clean()
    %s/{\n^$/{/
    %s/^$\n\(\s*}\)/\1/
endfunction

function! Pollute()
    %s/{$/{\r/
    %s/\(\s*}\)/\r\1/
endfunction

The basic idea begin, delete the empty lines at read and replace them at write, didn't try it but I feel like this can be added as an autocmd like so:

au BufReadPost *.cpp call Clean()
au BufWritePost *.cpp call Pollute()
1
source | link

First off, that's a shitty style enforcement and you have my sympathies. Instead of hiding how about creating a mapping for deleting the unnecessary lines before editing and adding them when you're done ? something along the lines (untested):

%s/{\n^$/{/g
%s/^$\n}/}/g

%s/{$/{^M/g
%s/}$/^M}/g

...or some such.

The basic idea begin, delete the empty lines at read and replace them at write (didn't try it but I feel like this can be done as an autocmd).

Note the ^M above is got by typing Ctrl-v followed by an Enter.