Getting the current row number?

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.


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.


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>