It's possible to use a mapping like this: inoremap <silent> sf <c-r><c-r>=getline('.')->strcharpart(0,getpos('.')[2]-1)->substitute('.*;','','')->substitute('=.*','','')->trim()<cr> (For older version where "method call" is not available it's possible to use inoremap <silent> sf <c-r><c-r>=trim(substitute(substitute(strcharpart(getline('.'),0,getpos('.')[2]-1),'.*;','',''),'=.*','','')) instead) So you only need to type <pre><code>table[row][col] = std::max(<b>sf</b>, other_table[row+1][col+1]) </code></pre> The `sf` typed will expand to `table[row][col]` in this case.