Once you're happy with your edits, you can either press "ENTER" to execute the command directly, or if you wish to resume the command-line, you can press CTRL-C to go back to the usual command-line, accepting the edits performed in the command-line window. Highlight or select the text that you want to covert from uppercase to lowercase.
You can then use gU to make any parts of the command uppercase, in addition to the full power of normal mode commands. Any time you change the case format of text in Word use the CtrlZ shortcut to undo it. Or, if you're in normal mode, you can type q: instead of : to go straight to the command-line window to write your command from scratch. You can enter it with CTRL-F from the command-line itself.
You have the full power of Vim to edit your Vim command-lines, what's not to like?
Instead, just use the command-line window instead, which allows you to use any arbitrary normal mode commands to edit your command-line. Ben Knoble, I'd also recommend skipping on this kind of mapping altogether. (.*) instead, match a sequence of non-blank characters, you can use this regex instead: let re = '\v(.*\s)?%U eCmdUpcaseWord()įinally, in another point made by D.\v: Use the "very magic" flavor of regexes, so that it works independent of set nomagic and fewer backslashes are needed." whitespace or on a non-keyword character.) " the cursor, if the cursor is at the end, on " one is the word under the cursor (or before " Split cmdline into 3 parts, where the middle vimrc, but it should be easy to adapt it to use a s: function and refer to it by as well. (I was thinking of writing a split() and a for loop and quickly got stuck there.) matchlist() with a suitable regex, and in particular using the \%Nc family for matching on a column is the way to go to find the word under the cursor.Using q: or CTRL-F make mappings easier to write, by acting on a buffer with normal mode commands, but it doesn't seem like it's possible to dismiss that window upon returning to the command-line. CTRL-\ e is the most flexible way to write mappings for the command-line mode.In particular, I agree with dedowsdi's choice of Vim features to implement this: This is useful to turn the last typed word to uppercase by simply typing it and pressing CTRL-U, and you'll be able to resume the command-line from there.
If the cursor is on whitespace, on a non-keyword character, or at the end of the line, it will act on the word before the cursor. Acts on keyword characters (as you mentioned and not, and I assume you did so intentionally.).Doesn't change the cursor position while doing that.Turns the word under the cursor into uppercase (cursor doesn't have to be at the start of the word.).This answer builds on dedowsdi's answer, but implements something closer to your specification: