Comments on: Vim – Add Line Numbers http://www.terminally-incoherent.com/blog/2009/09/08/vim-add-line-numbersde/ I will not fix your computer. Tue, 04 Aug 2020 22:34:33 +0000 hourly 1 https://wordpress.org/?v=4.7.26 By: Luke Maciak http://www.terminally-incoherent.com/blog/2009/09/08/vim-add-line-numbersde/#comment-13148 Fri, 11 Sep 2009 01:43:57 +0000 http://www.terminally-incoherent.com/blog/?p=3753#comment-13148

@ mcai8sh4:

I actually did the same thing when I first saw the line(‘.’) thing used. I tried to google it and failed. Then I was like: “hey, vim has inline help – let me try that” :)

@ Tino:

Yep, that works too. I usually use awk for bigger things though – for example, if I had 20 documents like this one, I wouldn’t even bother with vim and would go directly to awk. When I’m working with a single data file however I usually prefer to have it loaded in the editor and do these things one step at a time so I can see how the data shapes up.

Reply  |  Quote
]]>
By: SheriffFatman http://www.terminally-incoherent.com/blog/2009/09/08/vim-add-line-numbersde/#comment-13145 Thu, 10 Sep 2009 19:56:50 +0000 http://www.terminally-incoherent.com/blog/?p=3753#comment-13145

@ Luke Maciak: For Windows line-endings, you can always do :set fileformat=dos.

Reply  |  Quote
]]>
By: Tino http://www.terminally-incoherent.com/blog/2009/09/08/vim-add-line-numbersde/#comment-13141 Thu, 10 Sep 2009 07:45:31 +0000 http://www.terminally-incoherent.com/blog/?p=3753#comment-13141

OR you could just have done:
awk -v RS=”, ” ‘{print $0}’ ugly.csv | sort -u | awk ‘{print FNR “. ” $0}’

;)

Reply  |  Quote
]]>
By: mcai8sh4 http://www.terminally-incoherent.com/blog/2009/09/08/vim-add-line-numbersde/#comment-13139 Wed, 09 Sep 2009 20:59:42 +0000 http://www.terminally-incoherent.com/blog/?p=3753#comment-13139

lol – I googled….and failed. But not even thinking about the help files – major fail.

/me takes his red face and cowers in the corner.

@Chris : I know what you mean, although, as with most things it’s about the right tool for the job. Now imagine a full featured IDE that is fused with Vim – everyone would be a winner

Reply  |  Quote
]]>
By: Chris Wellons http://www.terminally-incoherent.com/blog/2009/09/08/vim-add-line-numbersde/#comment-13136 Tue, 08 Sep 2009 19:30:02 +0000 http://www.terminally-incoherent.com/blog/?p=3753#comment-13136

And yet most programmers dismiss vim (and/or emacs) as some kind of pointless historical relic! They don’t know what they’re missing.

I like your note about how this post is mostly for your own memory. I do the exact same thing.

Reply  |  Quote
]]>
By: Luke Maciak http://www.terminally-incoherent.com/blog/2009/09/08/vim-add-line-numbersde/#comment-13135 Tue, 08 Sep 2009 18:44:06 +0000 http://www.terminally-incoherent.com/blog/?p=3753#comment-13135

@ mcai8sh4:

Here it is:

line({expr})	The result is a Number, which is the line number of the file
		position given with {expr}.  The accepted positions are:
		    .	    the cursor position
		    $	    the last line in the current buffer
		    'x	    position of mark x (if the mark is not set, 0 is
			    returned)
		    w0	    first line visible in current window
		    w$	    last line visible in current window

This is taken directly from the vim’s inline help (ie. I typed in :help line). :)

@ Zel:

Oh… Because I was working with Windows file. The file needed to have windows line endings. It probably should have been \n\r but whatever.

Reply  |  Quote
]]>
By: Zel http://www.terminally-incoherent.com/blog/2009/09/08/vim-add-line-numbersde/#comment-13133 Tue, 08 Sep 2009 17:46:11 +0000 http://www.terminally-incoherent.com/blog/?p=3753#comment-13133

Nice tip. Maybe this will be a stupid question, but why use “\r” instead of “\n” ?

Reply  |  Quote
]]>
By: mcai8sh4 http://www.terminally-incoherent.com/blog/2009/09/08/vim-add-line-numbersde/#comment-13132 Tue, 08 Sep 2009 16:33:42 +0000 http://www.terminally-incoherent.com/blog/?p=3753#comment-13132

It’s these little ‘tricks’ that distinguishes vim from other text editors.

The \=line bit is new to me. Any explanation regarding the (‘.’) would be appreciated.

Thanks for the tip.

Reply  |  Quote
]]>