I'm writing a report in LaTeX that I keep in a Git repository. In order to make the most out of Git, I would like to keep each sentence on its own line. I.e. for each dot, exclamation mark and question mark - while I'm in insert mode - I would like vim automatically to insert a newline.However, I only want this to happen in the body of the text and not between {}, [], (),  or '' because in LaTeX, I may want to write filenames or commands between these characters.Is there any way I can achieve this with a key mapping in insert mode, or is there another preferred way of doing this?
Insert a newline after punctuations
key bindings;filetype tex
Here is a solution which seems to be working (note the word seems I didn't test it extensively so it might not work in some cases) :function! InsertDot(char)     Save the cursor position    let save_pos=getpos('.')     Try to yank inner braces    call setreg('z', )    normal zyi(    normal zyi[    normal zyi    normal zyi'    if ( getreg('z') ==  )     If nothing was yanked insert the character and a new line        execute normal! i . a:char . ^M        execute startinsert    else     If something was yanked insert the dot     (messy workaround to get back to the correct position)        call setpos('.', save_pos)        execute normal! i . a:char        execute startinsert        let save_pos[2] = save_pos[2]+1        call setpos('.', save_pos)    endifendfunctioninoremap . <c-o>:call InsertDot('.')<CR>inoremap ! <c-o>:call InsertDot('!')<CR>The characters must be mapped in insert mode to call the function. The function will try to determine if the cursor is between braces and add the character and a new line or only the character accordingly.Note that the function uses a crappy workaround to preserve the cursor position. I'm pretty sure it can be improved.Otherwise to follow your comment you can use this:inoremap . .^Minoremap \. .To make . insert a dot and a new line and \ . insert only a dot.Important noteAll the occurences of ^M in the code must be added with CTRL+vEnter