usr_03 Moving around
03.1 Word movement
This is a line with example text
--->-->->----------------->
w w w 3w
This is a line with example text
<----<--<-<---------<---
b b b 2b b
This is a line with example text
<- <--- -----> ---->
ge ge e e
:set iskeyword&
ge b w e
<- <- —> —>
This is-a line, with special/separated/words (and some more).
<----- <----- --------------------> ----->
gE B W E
03.2 Moving to the start or end of a line
^
<------------
.....This is a line with example text
<----------------- --------------->
0 $
03.3 Moving to a character
To err is human. To really foul up you need a computer.
---------->--------------->
fh fy
To err is human. To really foul up you need a computer. ~
--------------------->
3fl
To err is human. To really foul up you need a computer. ~
<---------------------
Fh
To err is human. To really foul up you need a computer. ~
<------------ ------------->
Th tn
03.4 Matching a parenthesis
%
<----->
if (a == (b * c) / d) ~
<---------------->
%
03.5 Moving to a specific line
| first line of a file ^
| text text text text |
| text text text text | gg
7G | text text text text |
| text text text text
| text text text text
V text text text text |
text text text text | G
text text text text |
last line of a file V
+---------------------------+
H --> | text sample text |
| sample text |
| text sample text |
| sample text |
M --> | text sample text |
| sample text |
| text sample text |
| sample text |
L --> | text sample text |
+---------------------------+
03.6 Telling where you are
- Use the CTRL-G command.
- Set the ‘number’ option.
- Set the ‘ruler’ option.
03.7 Scrolling around
The CTRL-U command scrolls down half a screen of text.
The CTRL-D command scrolls the text up half a screen.
To scroll one line at a time use CTRL-E (scroll up) and CTRL-Y (scroll down).
Fortunately CTRL-F is Forward and CTRL-B is Backward.
±-----------------+ ±-----------------+
| some text | | some text |
| some text | | some text |
| some text | | some text |
| some text | zz --> | line with cursor |
| some text | | some text |
| some text | | some text |
| line with cursor | | some text |
±-----------------+ ±-----------------+
03.8 Simple searches
/include
?word
n N search direction
IGNORING CASE
:set ignorecase
:set noignorecase
HISTORY
SEARCHING FOR A WORD IN THE TEXT
* # command
SEARCHING FOR WHOLE WORDS
/<the>
HIGHLIGHTING MATCHES
:set hlsearch
:set nohlsearch
:nohlsearch
TUNING SEARCHES
:set incsearch
:set nowrapscan
INTERMEZZO
:scriptnames
:edit ~/.vimrc
03.9 Simple search patterns
BEGINNING AND END OF A LINE
/^the$
MATCHING ANY SINGLE CHARACTER
c.m
MATCHING SPECIAL CHARACTERS
ter.
03.10 Using marks
``
CTRL-O
CTRL-I
The “:jumps” command gives a list of positions you jumped to.
NAMED MARKS
ma
ms
`a
:marks