Skip to main content
l:part is referenced only one
Source Link
Martin Tournoij
  • 63.3k
  • 26
  • 199
  • 274

The following works and is faster thatthan the matchstr() solution:

fun! Getchar()
  let part =return strcharpart(strpart(getline('.'), col('.') - 1)
  return strcharpart(part, 0, 1)
endfun
nnoremap GG :echo Getchar()<CR>

See my question Reliably get the character at a byte index in a string.

The following works and is faster that the matchstr() solution:

fun! Getchar()
  let part = strpart(getline('.'), col('.')-1)
  return strcharpart(part, 0, 1)
endfun
nnoremap GG :echo Getchar()<CR>

See my question Reliably get the character at a byte index in a string.

The following works and is faster than the matchstr() solution:

fun! Getchar()
  return strcharpart(strpart(getline('.'), col('.') - 1), 0, 1)
endfun
nnoremap GG :echo Getchar()<CR>

See my question Reliably get the character at a byte index in a string.

Source Link
Ralf
  • 9.4k
  • 1
  • 13
  • 32

The following works and is faster that the matchstr() solution:

fun! Getchar()
  let part = strpart(getline('.'), col('.')-1)
  return strcharpart(part, 0, 1)
endfun
nnoremap GG :echo Getchar()<CR>

See my question Reliably get the character at a byte index in a string.