Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vim

line

I know I can select the lines and use something like

:w ! sort | uniq -c

Is there a better solution?

like image 266
Eugene Yarmash Avatar asked May 18 '11 14:05

Eugene Yarmash


1 Answers

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.

like image 200
Benoit Avatar answered Oct 21 '22 13:10

Benoit