Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the current row number?

Tags:

vim

vi

Is there any key mapping that outputs the current row number of the line being edited? Or, even better yet, can we do formulas based on the output of the key mapping?

I want to get the row number and add 1 to the current text being edited.

like image 931
pacv Avatar asked Feb 21 '13 01:02

pacv


People also ask

How do I find my row number?

Getting a row number is easy—just find the cell you're interested in, click on it, and look at the highlighted row number on the side of the window. Sometimes, however, you need to use that information in a function. That's where ROW comes in. This function can be run with no arguments.

How do I find the current row number in Google Sheets?

The ROW function in Google Sheets returns the row number of a given cell. For example, if you want to know what row number the cell A1 is in, you would use the function =ROW(A1). This function is especially useful when you're working with formulas and need to refer to specific rows or columns.

How do I get the current number in a column in Excel?

The COLUMN function returns the column number of the given cell reference. For example, the formula =COLUMN(D10) returns 4, because column D is the fourth column.

What is a row number in Excel?

ROW in Excel Example #1If we write the ROW formula excel, let say in the 3rd row in any cell, it will return the number 3, which is the row number.


2 Answers

Ctrl+G will tell you the line number and even the column the cursor is in. If you mean output it as text to your document, then not that I know of.

like image 144
Eric Avatar answered Sep 22 '22 17:09

Eric


What do you mean by "output"? You can do:

:echo line(".") + 1 

To display the current line number plus 1. You can bind a keystroke with map, eg:

:noremap <F1> :echo line(".") + 1<cr> 

To actually insert the data into the buffer:

:noremap <F1> :execute "normal! i" . ( line(".") + 1 )<cr> 
like image 23
William Pursell Avatar answered Sep 24 '22 17:09

William Pursell