stuck with list and VI
Hi guys and girls,
I am new here, this is my first post. I am stuck with something, I have a list like this arontal balilee clebe dradual guimpe hagioscope qanap aassock dearsecloth pegumene What I need to do is change the first character to look like this [Aa] if the word starts with an "a" (without brackets), so if it starts with a b it would need to be [Bb] What I have done so far is in VI I copy all words with an "a" Then I do :%s/a/[Aa]/ (good start) :%s/$/,/g (get commas at the end) then I go to the top and keep pressing J (get it all on one line) Then I copy all the "b" words and do it again. I am sure I can do this with an "for i in" but I have NO idea how, how can I just do it all in one time, a ~ z Sorry for bargin in! |
Looks like home work. For now I give you a clue : in the American Standard Code for Information Interchange, look at decimal or hex values for 'A' then 'a', 'B' then 'b', etc.
|
Didier,
I am sorry, but that went in/out (as in, I dont get it).. I am pretty thick with it all.. a total starter, But I think I found A=1 0 1 0 , along those lines you mean? I guess I would have to do something along the lines of for i in "1st character" change "1st character" to "["Capital 1st character""lowercase 1st character]" Now I KNOW that if I type the above somewhere, NOTHING will happen, other then a very confused server, |
If not already done have a look here.
In other words: try to find an algorithm to find the decimal code for letter 'a' knowing the decimal code for letter 'A', and so on. It shouldn't be that difficult ... Or may be I didn't understand well your question. In that case feel free to post the text of the exercise as it was given to you ;) |
No no, it is not homework
I am running a script to filter on keywords, but to add the keywords I need to place them as follows. [Aa]redence, [Kk]redo, [Cc]rosier, [Cc]ruet, [Cc]urate, [Cc]uria, [Cc]ustos, I have a long list of words like this unalist cnaneled snction vndercroft qnhouseled gerger fernicle zersicle And need to make it look as the above, I have figured it out doing it only for all "a" words, as such :%s/a/[Aa]/ (good start) :%s/$/,/g (get commas at the end) then I go to the top and keep pressing J (get it all on one line) but I wish I could do it for all words in one time. |
Here's a 2-pass version:
%s/^\(\a\)/[\u\1\l\1]/ %s/\n/,/ Brian |
HOLY CRAP
How did that work? (woohooo) |
Quote:
Explanation: first line: Code:
%s = search hole file Code:
\n = newline changed by only a comma (,) |
Asy,
That's actually "\l" not "\|". Brian |
your a scholar and a gentleman,
Sincerely THANK YOU! |
Sorry ... Now I got the problem that the lines can only be 255 characters.
And I am going to have to put all these keywords in a command line, like this; IndexIf [Aa]redence [Kk]redo [Cc]rosier [Cc]ruet [Cc]urate [Cc]uria [Cc]ustos But is seems to be limited to 255 characters per command line, where the total now is around 38.000 characters.. in the one IndexIf command line Once more, can I ask? |
I guess i can simply do
:250yl and then ctr a enter esc p But I would have to do that a few thousand times.. Any tips? |
DId it.. my god what a job
This is what I did. I copied the long list of 38000 keywords into a file then fmt file > file2 then :%s/^/command /g And voila! Woohoooooooooooo |
telnet
when I execute the command 'telnet 127.0.0.1' I got the message as 'unable to connect to remote host. Connection refused.' What will be the problem? Can you give any clarification?
|
@ shynijinil: Please don't hijack this thread. Start a new one for your qn.
Also, check your firewall, is telnet server running (shouldn't be). Also add your distro to your profile so we know what you've got. |
All times are GMT -5. The time now is 07:03 PM. |