l mode + submodes (n, niI, niR, niV; plus operator pendings no, nov, noV, no^V)
    endif
    if exists("*VMInfos") && !empty(VMInfos())
      " Vim plugin Multiple Cursors https://github.com/mg979/vim-visual-multi
      let m = 'multi'
    endif
    " Adjust to handle additional modes, which don't display correctly otherwise
    if index(['niI', 'niR', 'niV', 'ic', 'ix', 'Rc', 'Rv', 'Rx', 'multi'], m) == -1
      let m = m[0]
    endif
    let w:airline_current_mode = get(g:airline_mode_map, m, m)
  else
    let mode = ['inactive']
    let w:airline_current_mode = get(g:airline_mode_map, '__')
  endif

  if g:airline_detect_modified && &modified
    call add(mode, 'modified')
  endif

  if g:airline_detect_paste && &paste
    call add(mode, 'paste')
  endif

  if g:airline_detect_crypt && exists("+key") && !empty(&key)
    call add(mode, 'crypt')
  endif

  if g:airline_detect_spell && &spell
    call add(mode, 'spell')
  endif

  if &readonly || ! &modifiable
    call add(mode, 'readonly')
  endif

  let mode_string = join(mode)
  if get(w:, 'airline_lastmode', '') != mode_string
    call airline#highlighter#highlight_modified_inactive(context.bufnr)
    call airline#highlighter#highlight(mode, string(context.bufnr))
    call airline#util#doautocmd('AirlineModeChanged')
    let w:airline_lastmode = mode_string
  endif

  return ''
endfunction

function! airline#update_tabline()
  if get(g:, 'airline_statusline_ontop', 0)
    call airline#extensions#tabline#redraw()
  endif
endfunction

function! airline#mode_changed()
  " airline#visual_active
  " Boolean: for when to get visual wordcount
  " needed for the wordcount extension
  let g:airline#visual_active = (mode() =~? '[