It's possible to use a mapping like this: inoremap <silent> sf <c-r><c-r>=getline('.')[:col('.')-2]->substitute('.*;','','')->substitute('=.*','','')->trim()<cr> (it's necessary to have `-2` because `col()` returns the 1-indexing index of the next character on the cursor, while `[:]` takes the 0-indexing byte index of the last character to be included) This uses [function or "method" chaining](https://vimhelp.org/eval.txt.html#method), a feature [new to Vim 8.2](https://vimhelp.org/version8.txt.html#new-vimscript-8.2). For older version where such method calls are not available it's possible to instead use: inoremap <silent> sf <c-r><c-r>=trim(substitute(substitute(getline('.')[:col('.')-2],'.*;','',''),'=.*','','')) 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.