Skip to main content
2 of 7
added 232 characters in body
user202729
  • 339
  • 1
  • 10

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

table[row][col] = std::max(sf, other_table[row+1][col+1])

The sf typed will expand to table[row][col] in this case.

user202729
  • 339
  • 1
  • 10