Home Explore Blog CI



neovim

40th chunk of `runtime/doc/vimfn.txt`
a21ecdd2bc62f4122d418539f7c85f7a15afda0e0f67727f0000000100000fb4
 v:mouse_col .. "|"
			endif
<
		There is no prompt, you will somehow have to make clear to the
		user that a character has to be typed.  The screen is not
		redrawn, e.g. when resizing the window.

		There is no mapping for the character.
		Key codes are replaced, thus when the user presses the <Del>
		key you get the code for the <Del> key, not the raw character
		sequence.  Examples: >vim
			getchar() == "\<Del>"
			getchar() == "\<S-Left>"
<		This example redefines "f" to ignore case: >vim
			nmap f :call FindChar()<CR>
			function FindChar()
			  let c = nr2char(getchar())
			  while col('.') < col('$') - 1
			    normal l
			    if getline('.')[col('.') - 1] ==? c
			      break
			    endif
			  endwhile
			endfunction
<

                Parameters: ~
                  • {expr} (`-1|0|1?`)
                  • {opts} (`table?`)

                Return: ~
                  (`integer|string`)

getcharmod()                                                      *getcharmod()*
		The result is a Number which is the state of the modifiers for
		the last obtained character with getchar() or in another way.
		These values are added together:
			2	shift
			4	control
			8	alt (meta)
			16	meta (when it's different from ALT)
			32	mouse double click
			64	mouse triple click
			96	mouse quadruple click (== 32 + 64)
			128	command (Mac) or super
		Only the modifiers that have not been included in the
		character itself are obtained.  Thus Shift-a results in "A"
		without a modifier.  Returns 0 if no modifiers are used.

                Return: ~
                  (`integer`)

getcharpos({expr})                                                *getcharpos()*
		Get the position for String {expr}. Same as |getpos()| but the
		column number in the returned List is a character index
		instead of a byte index.
		If |getpos()| returns a very large column number, equal to
		|v:maxcol|, then getcharpos() will return the character index
		of the last character.

		Example:
		With the cursor on '세' in line 5 with text "여보세요": >vim
			getcharpos('.')		returns [0, 5, 3, 0]
			getpos('.')		returns [0, 5, 7, 0]
<

                Parameters: ~
                  • {expr} (`string`)

                Return: ~
                  (`integer[]`)

getcharsearch()                                                *getcharsearch()*
		Return the current character search information as a {dict}
		with the following entries:

		    char	character previously used for a character
				search (|t|, |f|, |T|, or |F|); empty string
				if no character search has been performed
		    forward	direction of character search; 1 for forward,
				0 for backward
		    until	type of character search; 1 for a |t| or |T|
				character search, 0 for an |f| or |F|
				character search

		This can be useful to always have |;| and |,| search
		forward/backward regardless of the direction of the previous
		character search: >vim
			nnoremap <expr> ; getcharsearch().forward ? ';' : ','
			nnoremap <expr> , getcharsearch().forward ? ',' : ';'
<		Also see |setcharsearch()|.

                Return: ~
                  (`table`)

getcharstr([{expr} [, {opts}]])                                   *getcharstr()*
		The same as |getchar()|, except that this always returns a
		String, and "number" isn't allowed in {opts}.

                Parameters: ~
                  • {expr} (`-1|0|1?`)
                  • {opts} (`table?`)

                Return: ~
                  (`string`)

getcmdcomplpat()                                              *getcmdcomplpat()*
		Return completion pattern of the current command-line.
		Only works when the command line is being edited, thus
		requires use of |c_CTRL-\_e| or |c_CTRL-R_=|.
		Also see |getcmdtype()|, |setcmdpos()|, |getcmdline()|,
		|getcmdprompt()|, |getcmdcompltype()| and |setcmdline()|.
		Returns an empty string when completion is not defined.

                Return: ~
                  (`string`)

getcmdcompltype()                                

Title: Vimscript: getcharmod(), getcharpos(), getcharsearch(), getcharstr(), and getcmdcomplpat()
Summary
This section explains `getcharmod()`, which returns a number representing the modifier keys (Shift, Control, Alt, Meta, Command/Super, Mouse clicks) pressed with the last character obtained via `getchar()`. It also describes `getcharpos()`, similar to `getpos()` but returns character indices instead of byte indices for column numbers. The function `getcharsearch()` returns a dictionary containing information about the last character search (character, direction, type). `getcharstr()` is introduced as a string variant of `getchar()`. Finally, the function `getcmdcomplpat()` retrieves the completion pattern of the current command line.