From the course: Learning Vim
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Regular expressions
- [Instructor] A lot of times, you'll see where you'd like to be in the text. In other editors you'd leave the keyboard and use the mouse. In Vim you have many other ways to navigate to the text that doesn't require taking your hands off the keyboard. One that I use a lot is regular expressions. Let's open sherlock.txt, vim sherlock.txt. Say you'd like to move to the word trained, which is in line 11. If you know how many lines and words you need to move, you can use these motions. But an easier way is to search. Make sure you are in normal mode by hitting Escape, or Control + C if you don't have Escape. And then type /tra, and then Enter. And we see that we are right where we want to. You can use more than words for searching, you can use regular expressions. A regular expression is a way to match text, and it's beyond the scope of this video. There are many resources out there about regular expressions that you can read. Check out our Learning Regular Expressions course for more…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Navigate using keys: H, J, K, L1m 11s
-
(Locked)
Words, sentences, and paragraphs1m 46s
-
(Locked)
Challenge: Find word19s
-
(Locked)
Solution: Find word31s
-
(Locked)
Regular expressions1m 56s
-
(Locked)
Challenge: Search word8s
-
(Locked)
Solution: Search word14s
-
(Locked)
Screen movement47s
-
Challenge: Move screens5s
-
Solution: Move screens12s
-
(Locked)
Lines1m 40s
-
(Locked)
Challenge: Move lines14s
-
(Locked)
Solution: Move lines16s
-
(Locked)
Current word59s
-
(Locked)
Challenge: Find next instance of word23s
-
(Locked)
Solution: Find next instance of word22s
-
(Locked)
-
-
-
-
-
-