As has been stated, your list of exceptions is by no means comprehensive and you will probably find that this often creates more problems than it solves.
However, it's still doable and it was kind of fun to write out the code to do so, so here goes:
"When hitting Enter, if the line doesn't start with a /*, insert a semicolon
:inoremap <CR> <C-R>=match(getline('.'), '\s*/\*')==-1?';':''<CR><CR>
Feel free to expand this regex to capture your conditions above. I didn't want to write all of that out as I feel like it would obfuscate what I was writing and would still not be a complete solution for what your intent is.
You would probably want to only do this for certain filetypes, in which case you'd want to add the <buffer> argument to this command and do it inside an autocmd Filetype block.
To disable the mapping, you would say :iunmap <CR>
;, for example when breaking a function call with many arguments over 2 or more lines... Scripting all of these cases is difficult... You will quickly get used to adding the semicolons, so just hang in there for a little while :-) – Martin Tournoij Mar 03 '15 at 18:13etc.in my exceptions. This is also why I want to toggle it on and off. – iProgram Mar 03 '15 at 18:18;insertion could even be dangerous if it is not perfect (and no code is perfect). Imagine the following confusing set of lines:if (this > isfollowed by&& a + /* check */followed bythat * is_very(important |followed bysecurity | wise))followed bydo_something();. If your automatic;insertion makes a mistake and puts a;at the end of theif, then you immediately get a hard-to-detect security bug. – Shahbaz Mar 06 '15 at 13:23#define UNTIL(x) while (!(x)). Then when you writeUNTIL(out_of_bounds), it's impossible to know if that's a function call and therefore needs a terminating;or a macro that expands towhileand therefore doesn't need a terminating;. If you do insert the;, you are in trouble. – Shahbaz Mar 06 '15 at 13:29;, they wouldn't have added;to the language now, would they? ;) Since that's not possible, you can't have a program that correctly inserts it for you either. – Shahbaz Mar 06 '15 at 13:31;to the end of the line, but I often press the wrong one and then delete and retype it. I would rather;be added automatically every time and then I delete as I need to. – Kargath Aug 18 '23 at 08:39Jump to end of line, type ;to perform this action. Oh, maybe that's not necessary, justEnd+;. – Kargath Aug 18 '23 at 08:43