This is the 4th post of my post series on nifty Nvim/Vim techniques that will make my editing experience easier.
There are two simple ways:
match(str, pattern)=~# or =~?For match() function, Vim assumes that magic (see :h /magic) option is
set for patterns. If pattern is found in str, it will return the index
where the pattern starts. Otherwise, it will return -1.
You can also use regex match via =~# and =~? (see :h expr4). =~#
matches cases during matching, while =~? ignores cases. During matching, it
is always assumed that magic option is set.
For custom global functions, i.e., functions without the s: (see
local-function), the function name must start with an uppercase letter. But
for script local functions and auto-loaded functions (see :h autoload), you
do not need to start the actual function name with uppercase letter.
ALT key in mapping? M or A ?#According to documentation (:h key-notation), <M-...> and <A-...> are the
same. Both can be used to refer to Alt key.
Sometimes, due to various reasons, when you press some key, what Nvim receives
is not that key press. To check the key that Nvim actually receives, press
Ctrl-V in insert mode and then press the key you want to check.
If you are in normal mode, use <NUM>a<Chars><ESC> to input <NUM> repeated
<Chars>.
Ctrl-O is used to leave insert mode, execute one normal mode
command and go back to insert mode. For example, if you want to see your
runtimepath value, you can first press ctrl-o and then use :echo &runtimepath to see the option’s value.
Install vim-surround. Go to visual
block mode (press v in normal mode), select text you want to wrap, press S,
and press the wrapping characters such ' or " or {.
If you want to indent the code and as well as wrap it, then you need to go to
visual line mode (press V in normal mode)
First, search the variable you want to rename. Then press cgn to change it.
Go back to normal mode, press . (dot), the next match will be replaced with
the new name. If you want to skip some match, press n.
It is not as powerful as the Sublime Text multiple cursor feature, but should suffice for refactoring your code most of the time.
For example, if we would like to search a (Unicode code point is u+0041) in
Neovim, the correct format is /\%u0041, see :h /character-classes for more
info.
This is the 4th post of my post series on nifty Nvim/Vim techniques that will make my editing experience easier.
There are two simple ways:
match(str, pattern)=~# or =~?For match() function, Vim assumes that magic (see :h /magic) option is
set for patterns. If pattern is found in str, it will return the index
where the pattern starts. Otherwise, it will return -1.
You can also use regex match via =~# and =~? (see :h expr4). =~#
matches cases during matching, while =~? ignores cases. During matching, it
is always assumed that magic option is set.
For custom global functions, i.e., functions without the s: (see
local-function), the function name must start with an uppercase letter. But
for script local functions and auto-loaded functions (see :h autoload), you
do not need to start the actual function name with uppercase letter.
ALT key in mapping? M or A ?#According to documentation (:h key-notation), <M-...> and <A-...> are the
same. Both can be used to refer to Alt key.
Sometimes, due to various reasons, when you press some key, what Nvim receives
is not that key press. To check the key that Nvim actually receives, press
Ctrl-V in insert mode and then press the key you want to check.
If you are in normal mode, use <NUM>a<Chars><ESC> to input <NUM> repeated
<Chars>.
Ctrl-O is used to leave insert mode, execute one normal mode
command and go back to insert mode. For example, if you want to see your
runtimepath value, you can first press ctrl-o and then use :echo &runtimepath to see the option’s value.
Install vim-surround. Go to visual
block mode (press v in normal mode), select text you want to wrap, press S,
and press the wrapping characters such ' or " or {.
If you want to indent the code and as well as wrap it, then you need to go to
visual line mode (press V in normal mode)
First, search the variable you want to rename. Then press cgn to change it.
Go back to normal mode, press . (dot), the next match will be replaced with
the new name. If you want to skip some match, press n.
It is not as powerful as the Sublime Text multiple cursor feature, but should suffice for refactoring your code most of the time.
For example, if we would like to search a (Unicode code point is u+0041) in
Neovim, the correct format is /\%u0041, see :h /character-classes for more
info.