Tuesday, August 20, 2013

Re: Basic calculation in Vim

On 2013-08-20 12:19, tjg wrote:
> @TimChase : thanks for your answer, but I run into an error E20 :
> Mark not set. I must have made a mistake (I put the cursor on the
> second data line and ran your command : was I supposed to do that,
> or must I insert something like :2,3'<,'>s etc...?).

I'd presumed you were visually selecting the range of lines you
wanted to perform the calculations, so I used the range

:'<,'>

which means "from the first line of the visual selection, through the
last line of the visual selection". So common in fact, that when
you're in visual mode and hit the colon, it auto-populates that range
on the assumption that's what you want to operate on.

So you can specify any range you want. If your example text is the
sole content of the file, you could do

:2,$

to indicate that you want to operate from line#2 through the end of
the file (skipping line #1 which had the headers; if you included
line#1, it would just throw up peculiar warnings about the bad values
in the math for that line). If you don't have headers and your
entire file consists of your data, you can just use the short-hand
range

:%

to indicate the whole file.

There's a lot more power to Vim's ranges, which you can read about at

:help :range

-tim


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: