Correct setting: add |redraw
at the end
augroup CmdLineStatus_to_Title
autocmd!
autocmd CmdlineEnter * set titlestring=CommandlineMode|redraw
autocmd CmdlineEnter * set titlestring=%F\ %{v:servername}\ %{mode()}
augroup END
Original Post
I tried the following auto-command, and fail to achieve what I wanted. Ideally,
I would like to append to the end of the titlestring
an identifier when I move
the cursor to the command line (by pressing :
key).
" Global setting
setglobal titlestring=%F\ %{v:servername}\ %{mode()}
" The Auto command group
augroup CmdLineStatus_to_Title
autocmd!
autocmd CmdlineEnter * let &l:titlestring="CommandlineMode"
" autocmd CmdlineLeave * let &l:titlestring=%F\ %{v:servername}\ %{mode()}
augroup END
There are multiple problems:
- The
titlestring
, and/or the title of the Gvim window does not update when I ENTER the command line. It refreshes when I LEAVE the command line mode.- Also, the
&l:
flag did not restrict the setting native to the buffer: I get the constant title string as "CommandlineMode" for new files opened in new buffer/tabs. (One particular file is opened through annoremap <> <Plug>VimwikiMakeDiaryNote
mapping, with no command line operation involved.)
- Also, the
- Also, I cannot simply "append" a customized string towards the end of the
titlestring
. This should be a syntax problem- Also related: the line in
augroup
that has been commented out shall bring about the following error when I actually LEAVE the command line. Please also advise how to restore thetitlestring
settings when I leave the command line.
- Also related: the line in
Inspiration and credits:
- Naumann in this post, I can already tell the
titlestring
the current mode of Vim.
Machine specification: the reported trouble occurred on Gvim running through
X11 on a WSL-Linux-shell on a Windows 10 machine. The %{mode()}
"variable"
does update when I switch back and forth between the Normal mode and the Insert
mode. Chances are this could be a Xming problem? Will test by updating
the Gvim.exe that is installed natively to the Windows 10 machine.