mapping :W to :w...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

mapping :W to :w...

tuxic
Hi,

if my PC is heavily compiling things and I am editing and saving
things repeatedly if often hit :W instead of :w (that is, I am
still pressing SHIFT when hitting w.

So I tried to map :W to :w...but it does not work for me.

I tried

[n]map W w
and
[n]map :W :w

.

Is there any way to map the accidentally hit :W
command to :w somehow?

Cheers!
mcc

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20210224040623.p4fmrhjxbiyf5e5n%40solfire.
Reply | Threaded
Open this post in threaded view
|

Re: mapping :W to :w...

Salman Halim
I actually prefer to never hit shift, so map ; to : instead. 

You could simply define a command called W to do what you want:

command! W w

--

Salman

On Tue, 23 Feb 2021, 23:06 , <[hidden email]> wrote:
Hi,

if my PC is heavily compiling things and I am editing and saving
things repeatedly if often hit :W instead of :w (that is, I am
still pressing SHIFT when hitting w.

So I tried to map :W to :w...but it does not work for me.

I tried

[n]map W w
and
[n]map :W :w

.

Is there any way to map the accidentally hit :W
command to :w somehow?

Cheers!
mcc

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20210224040623.p4fmrhjxbiyf5e5n%40solfire.

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CANuxnEcDbZWngA-58DHuvdG_fesuz5%3DCxUh_LBmOqFTzx7YTTA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: mapping :W to :w...

tuxic
Hi Salman,

oh! :)

The first is genious and while reading the second one I had
the distinctive feeling of flat-hand-against-my-fronthead... ;)
Of course!

Thank you very much! That helps me a lot!

Cheers!
mcc


On 02/23 11:11, Salman Halim wrote:

> I actually prefer to never hit shift, so map ; to : instead.
>
> You could simply define a command called W to do what you want:
>
> command! W w
>
> --
>
> Salman
>
> On Tue, 23 Feb 2021, 23:06 , <[hidden email]> wrote:
>
> > Hi,
> >
> > if my PC is heavily compiling things and I am editing and saving
> > things repeatedly if often hit :W instead of :w (that is, I am
> > still pressing SHIFT when hitting w.
> >
> > So I tried to map :W to :w...but it does not work for me.
> >
> > I tried
> >
> > [n]map W w
> > and
> > [n]map :W :w
> >
> > .
> >
> > Is there any way to map the accidentally hit :W
> > command to :w somehow?
> >
> > Cheers!
> > mcc
> >
> > --
> > --
> > You received this message from the "vim_use" 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
> >
> > ---
> > You received this message because you are subscribed to the Google Groups
> > "vim_use" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to [hidden email].
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/vim_use/20210224040623.p4fmrhjxbiyf5e5n%40solfire
> > .
> >
>
> --
> --
> You received this message from the "vim_use" 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
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CANuxnEcDbZWngA-58DHuvdG_fesuz5%3DCxUh_LBmOqFTzx7YTTA%40mail.gmail.com.

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20210224043343.y734qf2kskrdfjtm%40solfire.
Reply | Threaded
Open this post in threaded view
|

Re: mapping :W to :w...

Tony Mechelynck
In reply to this post by tuxic
On Wed, Feb 24, 2021 at 5:06 AM <[hidden email]> wrote:

>
> Hi,
>
> if my PC is heavily compiling things and I am editing and saving
> things repeatedly if often hit :W instead of :w (that is, I am
> still pressing SHIFT when hitting w.
>
> So I tried to map :W to :w...but it does not work for me.
>
> I tried
>
> [n]map W w
> and
> [n]map :W :w
>
> .
>
> Is there any way to map the accidentally hit :W
> command to :w somehow?
>
> Cheers!
> mcc

Like Salman said, you could define a user-comand W executing just w ;
but the reason your nmap didn't work is that by the time you'tr typing
the W, you aren't in Normal mode anymore, but in Command-line mode;
OTOH you don't want any W in the middle of a command's parameters to
always lowercased; so another possibility is a command-mode
abbreviation, as follows:

        :cabbrev <expr> W ((getcmdtype() == ':' && getcmdpos() <= 4)? 'w' : 'W')

Testing getcmdtype() avoids lowercasing the W in a search command, and
testing getcmdpos() allows doing it only near the left margin. A
user-command is more elegant however; but in order to make it behave
like the w command you may want to define that :W command with the
appropriate parameters, as follows (untested):

        :command -nargs=* -complete=file -range=% -bang -bar W
<line1>,<line2>w<bang> <args>

which, after all, makes it somewhat less elegant; so you may choose a
command or an abbrev to suit youor taste.

Best regards,
Tony.

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXvzVvZZaZ8vEY9grSZNrO_soPwE0oGczrVy1yHF8_m0pA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: mapping :W to :w...

Tony Mechelynck
P.S. My solution to a similar problem was a little different:

        map <F3> :wa|wv<CR>
        map! <F3> <C-O>:wa|wv<CR>

Best regards,
Tony.

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXvXKsyjh5z_8%3D1AYja9fF0NvceHbiBkLBnghs9Ai848Ug%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: mapping :W to :w...

Salman Halim
I use <f2> in much the same way and just call :update. I also save automatically when the Vim window loses focus. 

--

Salman

On Wed, 24 Feb 2021, 02:33 Tony Mechelynck, <[hidden email]> wrote:
P.S. My solution to a similar problem was a little different:

        map <F3> :wa|wv<CR>
        map! <F3> <C-O>:wa|wv<CR>

Best regards,
Tony.

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXvXKsyjh5z_8%3D1AYja9fF0NvceHbiBkLBnghs9Ai848Ug%40mail.gmail.com.

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CANuxnEdbq6Qqm5jt%2BA%3DqvUbOK8ZuJwMC8%2B%3D7cdXsMS7TXhttFA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: mapping :W to :w...

rwmit...@gmail.com
"I use <f2> in much the same way and just call :update. I also save automatically when the Vim window loses focus."

Tell me more about this.
On Wednesday, February 24, 2021 at 2:54:17 AM UTC-5 Salman Halim wrote:
I use <f2> in much the same way and just call :update. I also save automatically when the Vim window loses focus. 

--

Salman

On Wed, 24 Feb 2021, 02:33 Tony Mechelynck, <[hidden email]> wrote:
P.S. My solution to a similar problem was a little different:

        map <F3> :wa|wv<CR>
        map! <F3> <C-O>:wa|wv<CR>

Best regards,
Tony.

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/952f24b6-e2f9-47c3-a651-b05683f054c4n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: mapping :W to :w...

arocker
In reply to this post by tuxic

> the distinctive feeling of flat-hand-against-my-fronthead... ;)
>

Aka (Also known as:) a face-palm. :-)*

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/03b0da16fc3d8e12971a9d203ee0b12d.squirrel%40webmail.vybenetworks.com.
Reply | Threaded
Open this post in threaded view
|

Re: mapping :W to :w...

tuxic
On 02/24 08:59, [hidden email] wrote:
>
> > the distinctive feeling of flat-hand-against-my-fronthead... ;)
> >
>
> Aka (Also known as:) a face-palm. :-)*

Ok :) another face-palm (this time correctly spoke...I am no native
speaker...sorry...

But...how can I ensure, that I am talking about my face and
someone else face...?


>
> --
> --
> You received this message from the "vim_use" 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
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/03b0da16fc3d8e12971a9d203ee0b12d.squirrel%40webmail.vybenetworks.com.
>

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20210224141114.2bdpvgl7fnobzesk%40solfire.
Reply | Threaded
Open this post in threaded view
|

Re: mapping :W to :w...

Lifepillar
In reply to this post by tuxic
>>On 02/23 11:11, Salman Halim wrote:
>> I actually prefer to never hit shift, so map ; to : instead.
>>
>On 2021-02-24, [hidden email] <[hidden email]> wrote:
> Hi Salman,
>
> oh! :)
>
> The first is genious

Keep in mind that ; is a useful mapping in Vim. Sure, you can remap it
to :, but, in my experience, in the long term it is better not to change
Vim's default mappings (this is a matter of personal taste, of course),
except when their functionality is replicated by other mappings (as in
the next paragraph).


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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/s15nab%24ph5%241%40ciao.gmane.io.