not from freebsd to linux
24 May 2005, 8:36 ammore of those unix things i can never remember and always have to look up:
regexps
swap x=y; for y=x;
^(\t ]+)(.+)=(.+);$
\1\3=\2;
vi stuff
search and replace:
range/searchtext/replacetext/specifier e.g.,
%s/start/end/g
to get rid of extra ctrl-m’s from an improper transfer:
:%s/Ctrl-vCtrl-m//g
note: this is general unix-y stuff. another post has linux-specific stuff. i know, i know, it’s all in the man pages. you know what? nothing makes me feel more idiotic than canonical unix documentation.
how did i miss this post the first time around?
First off, you should look at the command “tr”. It usually makes swaps a lot easier. Don’t know if it would help you from within vi or some other text editor, but there is a handy perl tr operator, if you ever use perl.
Second, most unices have a command called “dos2unix” which will strip the ctrl-Ms out for you.
I am an emacs user, but I have to say, vi’s regexps kick ass; emacs totally misses the boat by giving some bogus prompted-search-and-replace features intstead. Being able to confine regexps to specific ranges is great, too.
Because the Original Information Architecture From Hell concealed it effectively.
I’m trying to remember specifically what I was doing, and I think that I was running that regexp either on perl or javascript files. I do underuse tr.
Neither my FreeBSD nor Linux RedHat installs included it by default — but I think I was mostly trying to give myself a way to remember to hit ctrl-v to enter control characters.
I (obviously) never attained vi master status. I know there’s a way to have 26 different cut and paste buffers, but I never remember how to invoke it. I’m pretty comfortable as a journeyman with vi and use it for all my server-side editing. At heart, however, I am a dyed-in-the-wool Edit+ man.