Skip to content

Latest commit

 

History

History
57 lines (37 loc) · 1.29 KB

tip28.md

File metadata and controls

57 lines (37 loc) · 1.29 KB

Tip28: Execute a Command on One or More Consecutive Lines

tip28_1

:print

echo the specified lines below Vim's command line.

:digit (:1)

move cursor to the specified line.

:$

move cursor to the end line of the file.

:3p

move cursor to line 3 and echo the content of that line.

:3d (3G dd)

jump to line 3 and delete it.

:2,5p (:{start},{end})

print each line from 2 to 5. and cursor would be left positioned on line 5.

.

represent current line.

:%p

%: represent all the lines in the current file.

:%s/old/new/

replace the first occurrence of 'old' with 'new' on each line.

2G VG

make a visual selection if we press the : key, the command-line prompt will be prepopulated with the range :'<,'>: stand for the visual selection. and if you press :'<,'>p: will print the selection!

'<

standing for the first line of the visual selection.

'>

standing for the last line of the visual selection.

:/<html>/,/</html>/p (:{start},{end})

print the tags.

:/<html>/+1,/</html>/-1p (:{address}+n)

print the content of the tag except the tag! if n is omitted, it defaults to 1.

:2 && :.,.+3p

equals to :2,5p

tip28_2