FAQ Search Today's Posts Mark Forums Read

» Linux Archive
Home
New Posts
Search
FAQ


Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 02-12-2009, 08:42 PM
Stroller
 
Default Commenting out multiple lines in vim

On 12 Feb 2009, at 20:16, Alexander Pilipovsky wrote:

Stroller написав(ла):


Hi there,

I can find numerous references on the net to this behaviour:

In vim, you can just select the rectangular region with Ctrl-v,
then type "I#<ESC>". This will insert # in each line at the same
column. Very convenient.


...
Exuse me, but it works on my computer And thanks about this
topic, I didn't know about this feature!


I selected region by Ctrl-v, pressed Shift-I and white selection
disappeared, I pressed # and ESC and got this effect...


Blimey! I overlooked the instruction to use the <escape> key!

Having recently made a resolution to take better advantage of vim's
features I have only just learned selection using shift-v, so had to
test again using ctrl-v before posting. I also tried both combinations
using just "i" and also shift-I.


*slaps self*

Stroller.
 
Old 02-12-2009, 08:44 PM
Alan
 
Default Commenting out multiple lines in vim

On Thu, Feb 12, 2009 at 07:53:30PM +0000, Stroller wrote:
> Hi there,
>
> I can find numerous references on the net to this behaviour:
>
> In vim, you can just select the rectangular region with Ctrl-v,
> then type "I#<ESC>". This will insert # in each line at the same
> column. Very convenient.
>
> EG:
> http://mail.python.org/pipermail/python-list/2001-May/084540.html
> http://hurley.wordpress.com/2007/06/13/vim-tip-comment-out-multiple-lines/
>
> Yet it doesn't seem to work on any of my Gentoo systems.
>
> Is this something that is caused by a Gentoo-specific /etc/vimrc or has vim
> evolved?

Couple of things to check:
- you're running vim not vi or vim-tiny which has a bunch of behaviour
removed. Ensure that syntax highlighting works for example is what I
do to make sure. ESC :help will show your version also
- ensure you're not running with the 'compatible' setting.
ESC :set nocompatible
will make sure this is off

Alan


--
Alan <alan@ufies.org> - http://arcterex.net
--------------------------------------------------------------------
"Beware of computer programmers that carry screwdrivers." -- Unknown
 
Old 02-12-2009, 11:53 PM
Philip Webb
 
Default Commenting out multiple lines in vim

090212 Stroller quoted:
> In vim, you can just select the rectangular region with Ctrl-v,
> then type "I#<ESC>". This will insert # in each line at the same column.

If you want to comment a series of lines m-n , it's quicker to do :

:m,ns/^/#/

--
========================,,======================== ====================
SUPPORT ___________//___, Philip Webb
ELECTRIC /] [] [] [] [] []| Cities Centre, University of Toronto
TRANSIT `-O----------O---' purslowatchassdotutorontodotca
 
Old 02-13-2009, 04:48 AM
Stroller
 
Default Commenting out multiple lines in vim

On 13 Feb 2009, at 00:53, Philip Webb wrote:


090212 Stroller quoted:

In vim, you can just select the rectangular region with Ctrl-v,
then type "I#<ESC>". This will insert # in each line at the same
column.


If you want to comment a series of lines m-n , it's quicker to do :

:m,ns/^/#/


I saw similar comments in my Google searches, but I am flummoxed how
one could find it so.


Is it only on my keyboard that forward-slash is a "lower-case"
character that is accessed *without* the shift key deployed?


How do you know m & n? Surely it's easier just to highlight the lines?

Stroller.
 
Old 02-13-2009, 05:49 AM
Eray Aslan
 
Default Commenting out multiple lines in vim

On 13.02.2009 07:48, Stroller wrote:
> On 13 Feb 2009, at 00:53, Philip Webb wrote:
>> 090212 Stroller quoted:
>>> In vim, you can just select the rectangular region with Ctrl-v,
>>> then type "I#<ESC>". This will insert # in each line at the same
>>> column.
>>
>> If you want to comment a series of lines m-n , it's quicker to do :
>>
>> :m,ns/^/#/
>
> I saw similar comments in my Google searches, but I am flummoxed how one
> could find it so.
>
> Is it only on my keyboard that forward-slash is a "lower-case" character
> that is accessed *without* the shift key deployed?
>
> How do you know m & n?

Column and line numbers are shown on the lower right part of the screen.

> Surely it's easier just to highlight the lines?

Not when you are working with the keyboard most of the time. Taking
your hands off the keyboard to use the mouse is time consuming and
becomes rather annoying.

--
Eray
 
Old 02-13-2009, 08:24 AM
"Joost Roeleveld"
 
Default Commenting out multiple lines in vim

On Fri, February 13, 2009 7:49 am, Eray Aslan wrote:
> On 13.02.2009 07:48, Stroller wrote:
>> On 13 Feb 2009, at 00:53, Philip Webb wrote:
>>> 090212 Stroller quoted:
>>>> In vim, you can just select the rectangular region with Ctrl-v,
>>>> then type "I#<ESC>". This will insert # in each line at the same
>>>> column.
>>>
>>> If you want to comment a series of lines m-n , it's quicker to do :
>>>
>>> :m,ns/^/#/
>>
>> I saw similar comments in my Google searches, but I am flummoxed how one
>> could find it so.
>>
>> Is it only on my keyboard that forward-slash is a "lower-case" character
>> that is accessed *without* the shift key deployed?
>>
>> How do you know m & n?
>
> Column and line numbers are shown on the lower right part of the screen.
>
>> Surely it's easier just to highlight the lines?
>
> Not when you are working with the keyboard most of the time. Taking
> your hands off the keyboard to use the mouse is time consuming and
> becomes rather annoying.

True, but with this method, you don't use the mouse, just the keyboard:
1) Go to first line
2) Press <CTRL>+V
3) go to last line
4) Press <ESC>
5) Press <SHIFT>+I
6) Press '#'
7) Press <ESC>

On my system I then need to move the cursor to actually see the change, is
this normal?

--
Joost
 
Old 02-13-2009, 11:37 AM
Nicolas Sebrecht
 
Default Commenting out multiple lines in vim

On Fri, Feb 13, 2009 at 10:24:34AM +0100, Joost Roeleveld wrote:

> True, but with this method, you don't use the mouse, just the keyboard:
> 1) Go to first line

Press gg

> 2) Press <CTRL>+V
> 3) go to last line

Press G

> 4) Press <ESC>

Why this stage ?

> 5) Press <SHIFT>+I
> 6) Press '#'
> 7) Press <ESC>
>
> On my system I then need to move the cursor to actually see the change, is
> this normal?

I don't have to here with vim72 or gvim. However, I have no idea of how
to fix this.

--
Nicolas Sebrecht
 
Old 02-13-2009, 11:54 AM
"Joost Roeleveld"
 
Default Commenting out multiple lines in vim

On Fri, February 13, 2009 1:37 pm, Nicolas Sebrecht wrote:
>
> On Fri, Feb 13, 2009 at 10:24:34AM +0100, Joost Roeleveld wrote:
>
>> True, but with this method, you don't use the mouse, just the keyboard:
>> 1) Go to first line
>
> Press gg

Actually meant going to first line of block you want to comment out

>
>> 2) Press <CTRL>+V
>> 3) go to last line
>
> Press G

Ditto, but last line of what you want to comment out

>
>> 4) Press <ESC>
>
> Why this stage ?

Oops, typo...

>
>> 5) Press <SHIFT>+I
>> 6) Press '#'
>> 7) Press <ESC>
>>
>> On my system I then need to move the cursor to actually see the change,
>> is
>> this normal?
>
> I don't have to here with vim72 or gvim. However, I have no idea of how
> to fix this.

I use vim-7.2 as well. Could easily be because it needs that to do a
redraw of the screen.
It's a minor annoyance which I can live with. And as I am the only one
facing this, I don't see the point of raising a bug-report for it.

--
Joost
 
Old 02-13-2009, 06:58 PM
Stroller
 
Default Commenting out multiple lines in vim

On 13 Feb 2009, at 06:49, Eray Aslan wrote:

...

Surely it's easier just to highlight the lines?


Not when you are working with the keyboard most of the time. Taking
your hands off the keyboard to use the mouse is time consuming and
becomes rather annoying.


LOL!

Stroller.
 
Old 02-13-2009, 07:01 PM
Stroller
 
Default Commenting out multiple lines in vim

On 13 Feb 2009, at 09:24, Joost Roeleveld wrote:

...
On my system I then need to move the cursor to actually see the
change, is

this normal?


Here the change appears when you move the cursor... or after a slow
second.


Stroller.
 

Thread Tools




All times are GMT. The time now is 09:13 AM.

VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org