mirror of
https://github.com/mhinz/vim-galore.git
synced 2025-02-24 01:59:28 +08:00
Commands: :normal and :execute
This commit is contained in:
parent
33932b5195
commit
a6b229305d
@ -23,6 +23,7 @@ All notable changes to this project will be documented in this file.
|
||||
- Basics: [Completion?](README.md#completion)
|
||||
- Basics: [Undo tree?](README.md#undo-tree)
|
||||
- Commands: [:redir](README.md#redir)
|
||||
- Commands: [:normal and :execute](README.md#normal-and-execute)
|
||||
- Tips: [Saner command-line history](README.md#saner-command-line-history)
|
||||
- Tips: [Reload a file on saving](README.md#reload-a-file-on-saving)
|
||||
- Tips: [Smarter cursorline](README.md#smarter-cursorline)
|
||||
|
27
README.md
27
README.md
@ -76,6 +76,7 @@ Twitter](https://twitter.com/_mhinz_). Thanks!
|
||||
|
||||
#### [Commands](#commands-1)
|
||||
|
||||
- [:normal and :execute](#normal-and-execute) - The scripting dream team.
|
||||
- [:redir](#redir) - Redirect messages.
|
||||
|
||||
#### [Debugging](#debugging-1)
|
||||
@ -1878,6 +1879,32 @@ set complete-=t " disable searching tags
|
||||
|
||||
Useful commands that are good to know.
|
||||
|
||||
#### :normal and :execute
|
||||
|
||||
These commands are commonly used in Vim scripts.
|
||||
|
||||
With `:normal` you can do normal mode mappings from the command-line. E.g.
|
||||
`:normal! 4j` will make the cursor go down 4 lines (without using any custom
|
||||
mapping for "j" due to the "!").
|
||||
|
||||
Mind that `:normal` also takes a count, so `:%norm! Iabc` would prepend "abc" to
|
||||
every line.
|
||||
|
||||
With `:execute` you can mix commands with expressions. Assume you edit a C
|
||||
source file and want to switch to its header file:
|
||||
|
||||
```vim
|
||||
:execute 'edit' fnamemodify(expand('%'), ':r') . '.h'
|
||||
```
|
||||
|
||||
Both commands are often used together. Assume you want to make the cursor go
|
||||
down "n" lines:
|
||||
|
||||
```vim
|
||||
:let n = 4
|
||||
:execute 'normal!' n . 'j'
|
||||
```
|
||||
|
||||
#### :redir
|
||||
|
||||
Many commands print messages and `:redir` allows to redirect that output. You
|
||||
|
Loading…
x
Reference in New Issue
Block a user