Vim commands: Difference between revisions
From wikinotes
No edit summary |
|||
(One intermediate revision by the same user not shown) | |||
Line 6: | Line 6: | ||
| <code>:h wildmenu</code> || https://neovim.io/doc/user/options.html#'wildmenu' | | <code>:h wildmenu</code> || https://neovim.io/doc/user/options.html#'wildmenu' | ||
|- | |- | ||
| <code>:h index</code> (builtin commands) || https://vimhelp.org/index.txt.html#index | |||
|- | |||
| <code>:map</code> (user/plugin commands) || n/a | |||
|} | |} | ||
</blockquote><!-- Documentation --> | </blockquote><!-- Documentation --> | ||
Line 44: | Line 47: | ||
UP " complete parent dir | UP " complete parent dir | ||
DOWN " complete child dirs | DOWN " complete child dirs | ||
</syntaxhighlight> | |||
Configuration | |||
<syntaxhighlight lang="vim"> | |||
set ignorecase " ignore case when completing vim-commands | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Command Completion --> | </blockquote><!-- Command Completion --> |
Latest revision as of 17:18, 18 February 2023
Documentation
:h cmdline
https://neovim.io/doc/user/cmdline.html :h wildmenu
https://neovim.io/doc/user/options.html#'wildmenu' :h index
(builtin commands)https://vimhelp.org/index.txt.html#index :map
(user/plugin commands)n/a
Command Mode
:
enters the command mode interpreterctrl-f
from within command mode opens command/history in a buffer: "enter commandmode <c-f> "edit command in buffer (w/ vim navigation etc) !<command> "run shell command :<command>:<command> "each command-mode command is prefixed by a ':' :%s/search/replace/gc "search/replace text in entire file (confirming before replacing for each occurrence) :%s/search/replace/g "search/replace text in entire file 0-9<command> "prefix a command with a number to perform command N times u "undo <c-r> "redo
Command Completion
Command mode completion controlled by the
wildmenu
.
See:h wildmenu
.Hotkeys
CTRL-Y, SPACE " accept completion CTRL-E " abort completion CTRL-N, RIGHT " prev completion CTRL-P, LEFT " next completion " if completing filepaths UP " complete parent dir DOWN " complete child dirsConfiguration
set ignorecase " ignore case when completing vim-commands
Commands
Search
vim[grep]
vimgrep lets you search files
:vim[grep] test % " find all occurrences of 'test' in current file (%) :copen " list occurrences :cnext " jump to next occurrence :cprev " jump to prev occurrencegrep
grep lets you search with the cli grep (faster).
:grep searchterm **/*.md " search files glob-matched :grep searchterm `find . -type f '*.rb' -not -path 'test/*'` " search files provided by `find`Or directly cli grep to create repors (cannot jump results)
:!grep '^[a-zA-Z].*{' % | awk -F' ' '{ print $1 }' | sort | uniqcfdo
cfdo
will execute a command on all files in the quickfix list (:copen
)." cfdo execute in each file in quickfix " (ex: search-replace all sourcefiles in project) :grep foo :cfdo %s/foo/bar/g | write " cdo execute for each match in quickfix " (ex: unfold all modules in ruby file) vim '\(module \|class \)' % | cdo :normal zo