A block-quote desired

10 views
Skip to first unread message

Barrie Stott

unread,
Apr 16, 2011, 4:45:33 AM4/16/11
to macvim, Barrie Stott
I would like a block quote to use in files like .gvimrc so that I'm not forever typing " at the start of each line; if I justify the line they go all over the place. I tried using the following:

if 0 == 1
...
endif

Unfortunately, this gives errors when sourcing the file if some line (in the ... replacement) begins with a word like else or insert.

If someone has a block quote mechanism they can share that would be wonderful. If not, a way of finding all the words that can give problems (such as else, insert, ...) would be a good second best.

Barrie.

Kyle Lippincott

unread,
Apr 16, 2011, 4:52:46 AM4/16/11
to vim...@googlegroups.com, Barrie Stott
You want to insert text at the beginning of each line? Easiest way
(for me to remember, at least) is to hit shift-v, highlight the lines,
ctrl-v to convert to a block visual mode in the 0th column, shift-i to
start insert, hit " and then esc. You can play with some of those
steps like using only ctrl-v block visual mode and highlighting
whatever column you want to insert at (to get it not flush-left) or
using a range substitute once you have the lines highlighted (instead
of the block insertion).

> --
> You received this message from the "vim_mac" 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

Barrie Stott

unread,
Apr 16, 2011, 5:00:31 AM4/16/11
to macvim, Barrie Stott, vim...@googlegroups.com
I gave the wrong subject! I want a block COMMENT - not a block QUOTE. I'm sorry about that.

Barrie.

Ben Schmidt

unread,
Apr 16, 2011, 9:07:04 AM4/16/11
to vim...@googlegroups.com
On 16/04/11 7:00 PM, Barrie Stott wrote:
> I gave the wrong subject! I want a block COMMENT - not a block QUOTE. I'm sorry about that.

I'm pretty sure you can't do it in Vimscript.

If your comment is at the end of your file, though, you could put a
'finish' command before it.

Otherwise, the previous suggestion of using block-visual mode to insert
(with shift-I) or delete (d or x) a " from the beginning of all the
lines in the comment is, I think, the way to go.

I guess another possible way to avoid problems is to use :insert or
:append, and then :undo. But that's hardly elegant.

Ben.

P.S. This is a general Vim question, not a Mac-specific one, so you may
get more/better answers on the vim_use mailing list.

Barrie Stott

unread,
Apr 16, 2011, 9:46:03 AM4/16/11
to vim...@googlegroups.com, Barrie Stott

On 16 Apr 2011, at 14:07, Ben Schmidt wrote:

> On 16/04/11 7:00 PM, Barrie Stott wrote:
>> I gave the wrong subject! I want a block COMMENT - not a block QUOTE. I'm sorry about that.
>
> I'm pretty sure you can't do it in Vimscript.

Many thanks for the reply. I can almost do it but not quite. If I use ':while 0' to start the comment then I would have thought it would be looking only for :endwhile. This fails though if an 'insert' or 'append' is the first non-blank on a line.

> Otherwise, the previous suggestion of using block-visual mode to insert
> (with shift-I) or delete (d or x) a " from the beginning of all the
> lines in the comment is, I think, the way to go.

In principle I'd agree but it would then have to appear on the growing list of snippets that are used too infrequently for me to remember them. It's already becoming unwieldy.

> I guess another possible way to avoid problems is to use :insert or
> :append, and then :undo. But that's hardly elegant.

About on a par with :while ... :endwhile.

> P.S. This is a general Vim question, not a Mac-specific one, so you may
> get more/better answers on the vim_use mailing list.

Thank you for this; I'd never even considered it.

Barrie.

Tim Gray

unread,
Apr 16, 2011, 10:14:38 AM4/16/11
to vim...@googlegroups.com
On Apr 16, 2011, at 9:46 AM, Barrie Stott <zen1...@zen.co.uk> wrote:
>> Otherwise, the previous suggestion of using block-visual mode to insert
>> (with shift-I) or delete (d or x) a " from the beginning of all the
>> lines in the comment is, I think, the way to go.
>
> In principle I'd agree but it would then have to appear on the growing list of snippets that are used too infrequently for me to remember them. It's already becoming unwieldy.

Sorry, but it's vim. Those are the commands. And it's not like it's some arcane combination of keys. The block selection is useful in other situations, as is using I to insert at the beginning of a line.

Otherwise, look into The NERD Commenter. It's a plugin. Gives you several different comment/uncomment commands, mappings for them, and I think it even adds a menu in Macvim.

Barrie Stott

unread,
Apr 16, 2011, 10:58:31 AM4/16/11
to vim...@googlegroups.com, Barrie Stott

On 16 Apr 2011, at 15:14, Tim Gray wrote:

> On Apr 16, 2011, at 9:46 AM, Barrie Stott <zen1...@zen.co.uk> wrote:
>>> Otherwise, the previous suggestion of using block-visual mode to insert
>>> (with shift-I) or delete (d or x) a " from the beginning of all the
>>> lines in the comment is, I think, the way to go.
>>
>> In principle I'd agree but it would then have to appear on the growing list of snippets that are used too infrequently for me to remember them. It's already becoming unwieldy.
>
> Sorry, but it's vim. Those are the commands. And it's not like it's some arcane combination of keys. The block selection is useful in other situations, as is using I to insert at the beginning of a line.

The problem is not with vim; I think it's an excellent program and have used it for many years. The problem is with me; some people have difficulty remembering how to do something when they haven't done it for a few days and I am now one of them.

Barrie.

Tim Gray

unread,
Apr 16, 2011, 12:17:50 PM4/16/11
to vim...@googlegroups.com
On Apr 16, 2011, at 10:58 AM, Barrie Stott <zen1...@zen.co.uk> wrote:
> The problem is not with vim; I think it's an excellent program and have used it for many years. The problem is with me; some people have difficulty remembering how to do something when they haven't done it for a few days and I am now one of them.

Understood. Well that plugin I mentioned might be of some use. Otherwise maybe look into an editor that has more functions in menus for when you can't remember the key commands. Like BBEdit.

Though I must say I use 'i' for inserting all of the time in vim and visual mode gets used multiple times a day as well. So for me at least it's not really remembering any new commands...

Christopher Stone

unread,
Apr 16, 2011, 12:34:49 PM4/16/11
to vim...@googlegroups.com
On Apr 16, 2011, at 10:58 AM, Barrie Stott <zen1...@zen.co.uk> wrote:
The problem is not with vim; I think it's an excellent program and have used it for many years. The problem is with me; some people have difficulty remembering how to do something when they haven't done it for a few days and I am now one of them.
______________________________________________________________________

That's what cheat-sheets are for.  :)

--
Best Regards,
Chris

dacresni

unread,
Apr 18, 2011, 9:56:35 PM4/18/11
to vim...@googlegroups.com
i remember there being a code snipit menu for Gvim which would work on macvim. look up vim IDE perhaps throw bash into your search

dacresni

unread,
Apr 18, 2011, 9:59:20 PM4/18/11
to vim...@googlegroups.com
http://www.vim.org/scripts/script.php?script_id=213 

there it is, it has a menu for snipits. 

Steve Huff

unread,
Apr 20, 2011, 12:52:07 PM4/20/11
to vim...@googlegroups.com

On Apr 16, 2011, at 4:45 AM, Barrie Stott wrote:

> If someone has a block quote mechanism they can share that would be wonderful.


i've gotten tons of mileage out of TComment (http://www.vim.org/scripts/script.php?script_id=1173).

-steve

--
http://five.sentenc.es
PGP 8477B706 (A92A 1F7E 6D76 16A0 BFF9 E61D AD54 0251 8477 B706)

PGP.sig

Barrie Stott

unread,
Apr 20, 2011, 1:15:25 PM4/20/11
to vim...@googlegroups.com, Barrie Stott

On 20 Apr 2011, at 17:52, Steve Huff wrote:

>
> On Apr 16, 2011, at 4:45 AM, Barrie Stott wrote:
>
>> If someone has a block quote mechanism they can share that would be wonderful.
>
>
> i've gotten tons of mileage out of TComment (http://www.vim.org/scripts/script.php?script_id=1173).

I had been a bit put off by it saying that vimball would need updating for vim version 7, which is the one that I use. With your recommendation, I'l see what the difficulty is with vimball before writing things off.

Thanks for your email.

Barrie.

Tim Gray

unread,
Apr 20, 2011, 2:29:30 PM4/20/11
to vim...@googlegroups.com
On Apr 20, 2011 at 12:52 PM -0400, Steve Huff wrote:
>i've gotten tons of mileage out of TComment
>(http://www.vim.org/scripts/script.php?script_id=1173).

Thanks for mentioning this plugin. I like it more than Nerd commenter
and switched over.

Charles Campbell

unread,
Apr 20, 2011, 4:02:51 PM4/20/11
to vim...@googlegroups.com
vimball needed updating for vim 7.0; if you have 7.1 or later, there
should be no problem.
Chip Campbell

ivar vasara

unread,
Apr 20, 2011, 1:20:59 PM4/20/11
to vim...@googlegroups.com, Barrie Stott
The TComment git source repository is here -
https://github.com/tomtom/tcomment_vim
(This way you can use pathogen or added it to your Janus Rakefile)

Reply all
Reply to author
Forward
0 new messages