I generated a list of duplicated files with fdupes. The files have the size
included. I now want to start dedupping from the largest files.
How can I search numbers in vim larger than a given number.
Best regz
#2
A number greater than say number 100 is a number with more digits (eg
\d\{4,} or a number with 3 digits where the first digit is greater
than
2 or a number with 3 digits where the first number is 1 but the
second
ist greater than 0 ... etc.
\<\(\d\{4,}\|[2-9]\d\d\|1[1-9]\d\|10[1-9]\)\>
This regexp could be generated by a function. Maybe somebody has a
more
clever solution.
I'd stick with #1 anyway.
>#1
>Copy the numbers with leading zeros (so that every number has the same
>width) to the beginning of the line (using :s) & sort the lines.
>
>
>
I believe when using the 'n' flag to sort, the first step
becomes obsolete. I, as well, think this is the best way,
however ...
---
It is not clear, what you mean by 'searching numbers > x'.
thomas gave an approach with building regexps.
Another idea would be to search for a pattern and
test for a constraint :
[pseudo-code]
func! SearchCon(pat,flags,con)
let res = search(pat,flags)
while res && !con(res)
let res = search(pat,flags)
endwhil
return res
endfun
[/pseudo-code]
-ap
--
Ich hab geträumt, der Krieg wär vorbei.
> How can I search numbers in vim larger than a given number.
First, search for the numbers you wish to find, and confirm you're
getting what you want.
Then,
:while expand("<cword>") <= given | exe "norm n" | endw
Replace given by your number. To search again, repeat the command
(press <colon><up><cr>, or whatever, I mean). It's good if <ctrl-c>
works if you make a mistake.
This is esssentially ap's solution, fleshed out, and not in a
function. I've never made this into a function, it's easier to
remember the idea, though I vaguely thought it was simpler.
HTH, John
If you're lazy like I am, you can use the ":" register as a macro
and do
@:
to re-execute the command-line. Subsequent executions (as long
as you don't execute any other Ex commands) can be done with
@@
instead of <colon><up><cr> or <colon><control+P><cr>
As another alternative, you can textually highlight all such
numbers with a stunt such as
:%s/\d\+/\=(submatch(0) > 314) ? ("[".submatch(0).']') :
submatch(0)//g
which will wrap any numbers matching the condition ("> 314") in
square brackets.
I'd likely start with the "sort n" solution, but the above ":s"
command might be useful too.
-tim
This will be the simplest solution for me. I can regenerate the file with one
line per duplicate group. I'll check out the other solutions, though.
Well, if the lines are the same(ish) except for the file-size,
such as
1234 file1.txt
3456 file1.txt
56789 file1.txt
4321 file2.txt
543 file2.txt
you can sort them first by filename:
:%sort /\t/
(assuming that's a <tab> between the filesize and
filename...adjust accordingly)
You can repeatedly run the following until no matches are found
(should be about O(log N) where N is the max number of duplicates
of any given filename):
:%s/^\(\d\+\)\t\(.*\)\n\(\d\+\)\t\2$/\=((submatch(1) >
submatch(3))? submatch(3) : submatch(1)).'^I'.submatch(2)
(where the "^I" is entered with control+V followed by control+I)
This will compare each line with the line below it if the
filenames are the same, and replace both lines with the minimum
file-size followed by the filename.
Given that you haven't described your file contents, it's hard to
nail down an exact solution, but this should start you on the way
there...
-tim
(Sorry, OP, for the irrelevancy)
;) ;) :9
> If you're lazy like I am, you can use the ":" register as a macro
> and do
>
> @:
If you're lazy like I am, and prefer two independent key presses to
the coordinated key press using shift, @: is four keypresses, two
coordinated, and :<up><cr> is four key presses, only one coordinated.
Of course, lazy as I am, I have ; mapped to :, so my method is
actually only 3 key presses, two of them on large or isolated keys as
well.
John
Ah, but the payoff comes with multiple uses, where one can exploit
@@
which is only 2.5 key-presses after priming the pump with the
@:
and can be prefixed with a count (if your Ex command moves you to
the next place of interest).
It also doesn't take my hands off the home-row like an arrow key
does. However, if you prefer your method, you may like to use
control+P instead of the up-arrow, and (if timing the release of
the control-key is an issue) possibly even control+J or control+M
instead of <enter>. That arrow keys are waaaay out there. And
they're annoying to find accurately on my laptops.
Since we're already out whacking in the weeds of the rough in
this game of keystroke golf, what's one more OT question:
Has anybody on the list tried the new Asus EEE mini-laptop? I've
seen mixed reviews of it, some folks saying it's touch-typable.
However, I don't put great faith in generic reviewers without
knowing that they are more die-hard keyboardists. This list is a
much more keyboard-centric sample-set. Is it usable? And
workable for a vimmer? I could really groove on something that
small and light (and it's got better specs than my work-horse
laptop at home, except for the screen-res) and would be willing
to tighten my sloppy keyboarding to a slightly smaller target if
feasible.
Off-topic'ly yers,
-tim
Yes, the EEE has a terrible keyboard. The keys are small, light, and slippery
(they have a texture, but this seems to actually reduce grip). Also the keys
are poorly designed. They made the key topface larger by reducing the space
between the keys, but this only serves to make it harder to feel where one
key ends and the next key begins. They should have done the exact opposite --
make the top face of the keys smaller and put a bigger gap between the keys
so that you can more easily feel the keys... I'm sure that seems counter
intuitive because you would think a larger target would make typing easier,
but typing on the EEE is like typing to type on the iPhone. I tested Vim on
the EEE and it was not good. I like the idea of the EEE, but it's too
expensive for what you get. If it was $200 I might have overlooked the
keyboard... or if it came with more than 4GB and a higher-resolution
screen.
Even more off-topic: I thought the new Apple ultrathin keyboard would be
terrible for typing with Vim, but despite the very flat keys you actually get
a decent feel for the position of the keys. It's not the ideal keyboard, but
it works fine.
--
Noah Spurrier | email: no...@noah.org | http://www.noah.org/wiki/engineering
-------------------------------------------------------------------------------
* Tim Chase <v...@tim.thechases.com> dixit:
> Since we're already out whacking in the weeds of the rough in
> this game of keystroke golf, what's one more OT question:
Well, I dont' find it entirely offtopic: if I were to buy a new laptop,
I would be VERY interested in it being usable in touch typing and vim. I
spend most of my day on the console, ignoring my mouse, so a good
keyboard is very important for me, specially for vim.
> Has anybody on the list tried the new Asus EEE mini-laptop?
Not at all, but a friend's laptop commited partial suicide (it is still
usable, but hangs from time to time) last week, and he will be buying a
new laptop next month. One of the laptops he has considered is the EEE.
If he finally buys that, I can take some photographs of the keyboard and
some vim-editing sessions (apart from a review about keyboard quality
and size).
Currently he is considering a couple of models from Acer and a couple
from ASUS, but if the EEE is Linux compatible (if propietary hardware
has been kept low or not used) he will probably buy this. It has a good
relationship between quality and money (according to my friend, I still
haven't seen anyone in a shop here in Spain...).
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736 | http://www.dervishd.net
It's my PC and I'll cry if I want to... RAmen!
We are waiting for 13 Feb 2009 23:31:30 +0000 ...
I too...other than web browsing (and I admit, I'm a sucker for
Thunderbird for email, despite repeated attempts to learn/love
Mutt) I'm fairly content in a console with "screen", vim, and the
rest of my command-line utils.
>> Has anybody on the list tried the new Asus EEE mini-laptop?
>
> Not at all, but a friend's laptop commited partial suicide (it is still
> usable, but hangs from time to time) last week, and he will be buying a
> new laptop next month. One of the laptops he has considered is the EEE.
> If he finally buys that, I can take some photographs of the keyboard and
> some vim-editing sessions (apart from a review about keyboard quality
> and size).
I've seen a number of pictures of it, but it's impossible to
judge from a picture (okay, it's possible to judge in the
negative, such as a chiclet keyboard or the OLPC keyboard that
neither would do for touch-typing, but the EEE at least _looks_
like it might be touch-typable). So I'm looking for first-hand
"touch-typing Vim-veteran on an EEE" experience. If your friend
picks one up, I'd appreciated if you'd try vimming on it for 20
minutes or so and let me know if you want to throw the thing out
the window, or if it makes you want to run out and buy one :)
Thanks!
-tim
* Tim Chase <v...@tim.thechases.com> dixit:
> >> Since we're already out whacking in the weeds of the rough in this
> >> game of keystroke golf, what's one more OT question:
> >
> > Well, I dont' find it entirely offtopic: if I were to buy a new
> > laptop, I would be VERY interested in it being usable in touch
> > typing and vim. I spend most of my day on the console, ignoring my
> > mouse, so a good keyboard is very important for me, specially for
> > vim.
>
> I too...other than web browsing (and I admit, I'm a sucker for
> Thunderbird for email, despite repeated attempts to learn/love Mutt)
> I'm fairly content in a console with "screen", vim, and the rest of my
> command-line utils.
The same applies to me... except I'm a sucker for Mutt XDD
> >> Has anybody on the list tried the new Asus EEE mini-laptop?
> >
> > Not at all, but a friend's laptop commited partial suicide (it is
> > still usable, but hangs from time to time) last week, and he will be
> > buying a new laptop next month. One of the laptops he has considered
> > is the EEE. If he finally buys that, I can take some photographs of
> > the keyboard and some vim-editing sessions (apart from a review
> > about keyboard quality and size).
>
> I've seen a number of pictures of it, but it's impossible to judge
> from a picture (okay, it's possible to judge in the negative, such as
> a chiclet keyboard or the OLPC keyboard that neither would do for
> touch-typing, but the EEE at least _looks_ like it might be
> touch-typable). So I'm looking for first-hand "touch-typing
> Vim-veteran on an EEE" experience. If your friend picks one up, I'd
> appreciated if you'd try vimming on it for 20 minutes or so and let me
> know if you want to throw the thing out the window, or if it makes you
> want to run out and buy one :)
Make sure that if my friend buys this laptop I'm gonna stea^Wlend the
machine and use it heavily ;))) Moreover, he is also a vimmer, so if the
keyboard sucks, he will notice soon... In fact, I think that the only
reason why he would return the laptop is that the keyboard sucks or
Windows Vista is impossible to remove and return for a refund!
Anyway, even if he doesn't buy the laptop, if I can put my hands on one,
I'll tell you the look and feel of the keyboard. I've been touch typing
for more than 15 years, and I notice soon when a keyboard doesn't "fit".
It probably takes a while though until the keyboard "fits". I had used
a psion 3, psion 5, a zaurus c3100 and after some use I was able to
type quite fast on any of them -- although the c3100 can be tiresome
in this respect.
Does somebody know (maybe the person who seems to have actually tested
one) how difficult it is to compile, eg, vim? I assume gcc isn't
installed on-board? Is there a cross-compiling sdk or something? I
originally though that the eeepc would be a rather closed plattform
based on some statements I read.
Cross-compiling? I thought that's i386.
Bernhard
--
Es wird Wagen geben, die von keinem Tier gezogen werden und mit unglaublicher
Gewalt daherfahren.
-- Leonardo da Vinci
You're right of course. Somehow I simply assumed it's ARM-based.
Sorry.
* thomas <mica...@gmail.com> dixit:
> > I notice soon when a keyboard doesn't "fit".
>
> It probably takes a while though until the keyboard "fits".
Of course if you talk about proficiency but I was thinking about
"cozyness" (so to say, I cannot find a better word...). If I find
comfortable with the keyboard in the first half hour, it "fits".
Otherwise I try harder only if I cannot get a better keyboard.
When using vim, my fingers usually go much faster than my brain, going
to the keys without thinking (well, that's what touch-typing is about, I
suppose), so if the keyboard doesn't "fit" me, I make lots of mistakes,
no matter how good the keyboard is. For example, I cannot use a keyboard
with an "backwards-L-enter key", because then the closing brace is
misplaced. The same applies to foreign keyboards, of course.
This said, without being "fit", I can use proficiently (or at least,
good enough to use Vim) many laptop keyboards. In laptops I switch to
"conscious" mode, thinking a bit before hitting keys blindly, to make
sure I don't press two keys at the same time, or slip my finger over a
key (hitting the above key by mistake), etc. Using Vim in a laptop
keyboard is, for me, a problem of space. The keys are usually very near
one of another, so I hit two keys frequently. While typing text this is
not a problem (most of the time...) but when dealing with commands you
end up pressing "u" much more that you would like.
Laptop makers often think (this has been already said in the thread)
that is better to make the keys bigger. OK, small keys are difficult to
use, but large keys that are flat are a problem, too. I prefer a smaller
key slightly concave that a large-flat key. Hitting two keys at the same
time by mistake is a pain in the arse when using a modal editor like
Vim.
I hope the EEE doesn't suffer from that problem, but according to what a
list user has said, the EEE keyboard just stinks...