Eugene Yarmash
Eugene Yarmash

Reputation: 149963

How can I check if two lines are identical in vim?

I know I can select the lines and use something like

:w ! sort | uniq -c

Is there a better solution?

Upvotes: 8

Views: 566

Answers (1)

Benoit
Benoit

Reputation: 79205

With vimscript it is easy to do that:

if getline(line_number_1) ==# getline(line_number_2)
   echo 'hello'
endif

where *line_number_1* and *line_number_2* are integers. You can compute the current line number with line('.').

See :help getline() and help line(). Broader documentation is help eval.txt.

Upvotes: 9

Related Questions