Matt or Whomever,
How would I select text in VIM and save it to a different file. Specifically, I’m view mail queue files and need to select out individual emails to be able to see MIME-encoded objects (images, documents, etc)
I’m a vim newbie so keep that in mind. I need it kinda quick otherwise I’d figure it our myself.
Thanks
Weed
Matt or Whomever,
How would I select text in VIM and save it to a different file. Specifically, I’m view mail queue files and need to select out individual emails to be able to see MIME-encoded objects (images, documents, etc)
I’m a vim newbie so keep that in mind. I need it kinda quick otherwise I’d figure it our myself.
Thanks Weed
Please tell me
Please tell me you are about to turn in a co-worker for misusing corporate assets for personal gain; specifically, using email to make sexual advances to another co-worker.
Because then you will have to post the entire string of emails online for my amusement.
Uhm
Do you remember when we went out one night in Perryville, and came back to my parents house at 2 AM and found the handheld Wheel Of Fortune game? And we were playing it and the puzzle came up and you pulled “Bugs Bunny” out of the air and hit it before we had ANY letters? You remember how you guessed it without any clues>?
Please allow my silence to speak volumes…
Weed
Obfuscated, but possibly helpful
In command mode, position the cursor at the start of the text:
ma
Position the cursor at the end of the text:
:’a,.w cut_file.txt
Thank You
Muchos Gracias oh Czar of Logic! 🙂
Weed
You can also use Visual mode
You can also use Visual mode to select the text, by pressing “v”. Then press “v” again when your selection is complete.
Then follow Dan’s advice for writing it out. I’m a visual mode fan, myself. But maybe that’s just because text selection in visual mode works using a mouse over an SSH connection…
—
Matthew P. Barnson
While we’re here
So, I never would have thought I’d have occasion to share this, but it’s been the best initialization script I’ve ever used. Particularly suited to C coding, but there’s some old-school charm to that, wouldn’t you say? Anyway, in case anyone finds it useful (straight from the .cshrc, with ^M’s written out), here it is. (It’s driven by marking, as discussed earlier, with “ma” and “mb”.)
If anyone knows how to add such initialization scripts to gvim, I’d be much obliged. I feel helpless without my “}” shortcut.
# # set up the VI environment # # { move a block of lines to the left one shift width # } move a block of lines to the right one shift width # # put line numbers down the left side # * get rid of the line numbers # = save the contents of the file into the file "stuff" # @ prevent a block of code from being compiled # ^X cut # v copy # V paste # K go to the first line in the file # Q :q! # ^R insert a ruler into the text # ^H insert a header into the text # ^K delete the ruler from the text # setenv EXINIT "set redraw showmatch shiftwidth=3 autoindent\ map { :'a,'b <^M\ map } :'a,'b >^M\ map # :set number^M\ map * :set nonumber^M \ map = :w! stuff^M\ map @ :set noautoindent^M'bo#endif^['aO#if 0^[:set autoindent^M:^M\ map ^X :'a,'bw! $HOME/.VIjunk^M:'a,'b d^M\ map v :'a,'bw! $HOME/.VIjunk^M\ map V :r $HOME/.VIjunk^M\ map K 1G\ map ^R :r $HOME/.VIruler^M:^M\ map ^H :r $HOME/.VIheader^M:^M\ map ^K /\^---\^----\^----\^----\^----\^^M3dd"gvim
Are you talking about the Windows version of gvim, or the UNIX version? If it’s the Windows version, you should have a file here that you can edit to make it do what you want:
c:\Program Files\vim\_vimrc
On UNIX, it’s your .vimrc. Here’s my UNIX version. I run on a black screen, white letters (easier on my eyes than a white background).
I mainly use that one for email, but some Python editing, too. Things beginning with the (“) quote mark are comments. Some stuff I have commented out because it wasn’t as useful as I thought it would be.
I think my Windows “_vimrc” is very basic, and probably the default that ships with vim:
—
Matthew P. Barnson
Driving the station wagon
I’m in a Microsoft environment, all the way. (I have, due to an oversight on the part of our IT department, become a super-user on my laptop, which has since been filled with all manner of evil, such as Perl, Services for Unix, IIS, etc. Why use Access when I can write a Perl script to tie into the Oracle servers in 1/10th the time?) I’m probably the kind of guy you tech support folk love to hate. Should have raised flags when I requested a copy of Gvim in the first place (which was installed before I got SU priviledges). An MBA asking for a vi clone? Danger, Will Robinson, Danger!)
Which leads to another, more hypothetical tech question. If you had SU access in Windows, but thought you might lose it in the near future, what would you do to preserve it?
Thanks for the tip.
Backdoor…
Set up Cygwin sshd as a daemon. Turn off privilege separation. Set it to run as the system account.
Then I’d do something with mkpasswd to make it all work out. I’ll have to try to figure it out.
—
Matthew P. Barnson