Combine . with @:

28 views
Skip to first unread message

Paolo Bolzoni

unread,
Feb 23, 2015, 9:47:10 AM2/23/15
to vim...@googlegroups.com
Dear everyone,

It is possible to change the meaning of . so it repeats the last
command, whatever it was a normal command or a ex command? I find
confusing that I can type dw..., but not :cNext<cr>..

Yours faithfully,
Paolo

Nikolay Pavlov

unread,
Feb 23, 2015, 12:00:35 PM2/23/15
to vim...@googlegroups.com
2015-02-23 17:47 GMT+03:00 Paolo Bolzoni <paolo.bol...@gmail.com>:
Dear everyone,

It is possible to change the meaning of . so it repeats the last
command, whatever it was a normal command or a ex command? I find
confusing that I can type dw..., but not :cNext<cr>..

Dot was *never* meant to repeat non-editing commands. `dw` is repeated because you edit buffer with it, but something like `/foo` is not repeated by dot (though `d/foo` will). Repeating `:cNext` will completely break the meaning of dot because :cNext is not about editing anything.

Though Ex commands that edit something are not repeated by the dot as well.
 

Yours faithfully,
Paolo

--
--
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 vim_use+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dave R

unread,
Feb 23, 2015, 12:10:39 PM2/23/15
to vim...@googlegroups.com
Perhaps not what you're wanting, but you could always use key-remapping to short-cut editing and ex-cmd sequences, thus making 'repeating' easier.
---Dave.

John Little

unread,
Feb 23, 2015, 7:01:00 PM2/23/15
to vim...@googlegroups.com
On Tuesday, February 24, 2015 at 3:47:10 AM UTC+13, Paolo Bolzoni wrote:

> It is possible to change the meaning of .

IMO we can't change the meaning of .; too many of us rely on it working the way it is.

It sounds like you want to record a macro. Maybe vim could always record a "default macro" if it's not otherwise recording; often I find myself regretting "I should have recorded that". Sorting out what resets that recording might be difficult...

Regards, John Little

Tim Chase

unread,
Feb 23, 2015, 7:44:44 PM2/23/15
to vim...@googlegroups.com, paolo.bol...@gmail.com
On 2015-02-23 15:47, Paolo Bolzoni wrote:
> It is possible to change the meaning of . so it repeats the last
> command, whatever it was a normal command or a ex command? I find
> confusing that I can type dw..., but not :cNext<cr>..

As others have mentioned, there's no way to expand the behavior of
the "." command to include things other than normal-mode changes. But
as you've found, using "@:" re-executes the last Ex command. However,
since it's a macro, subsequent executions can be performed with "@@"
which I find MUCH easier to type. And, as you detail, I do it
frequently with ":cn"ext to browse the quick-fix results. On rare
occasions where I'm doing a lot of them, I'll do a temporary
(non-.vimrc) mapping, something like

:nnoremap <space> :cn<cr>

which lets me just hit the space-bar to jump to the next result.

Also, just in case you need it, "g&" is an obscure "across all lines
in the file, repeat the last substitution with the same flags"
command, even if it's several items back in your command-line history.

:help g&
:help @@

-tim





toothpik

unread,
Feb 24, 2015, 12:45:42 AM2/24/15
to vim...@googlegroups.com
On Mon, Feb 23, 2015 at 06:46:07PM -0600, Tim Chase wrote:
> On 2015-02-23 15:47, Paolo Bolzoni wrote:
> > It is possible to change the meaning of . so it repeats the last
> > command, whatever it was a normal command or a ex command? I find
> > confusing that I can type dw..., but not :cNext<cr>..

> As others have mentioned, there's no way to expand the behavior of
> the "." command to include things other than normal-mode changes. But
> as you've found, using "@:" re-executes the last Ex command. However,
> since it's a macro, subsequent executions can be performed with "@@"
> which I find MUCH easier to type. And, as you detail, I do it
> frequently with ":cn"ext to browse the quick-fix results. On rare
> occasions where I'm doing a lot of them, I'll do a temporary
> (non-.vimrc) mapping, something like

> :nnoremap <space> :cn<cr>

> which lets me just hit the space-bar to jump to the next result.

I found a leader command useful:

let mapleader = ','
nnoremap <Leader>hhh :call HelpgrepScrollers()<CR>
function! HelpgrepScrollers()
silent! nmap <F6> :cnext<CR>
silent! nmap <S-F6> :cprev<CR>
echo 'helpgrep scrollers :cn and :cp mapped to F6 and S-F6'
endfunction


--
_|_ _ __|_|_ ._ o|
|_(_)(_)|_| ||_)||<
|
Reply all
Reply to author
Forward
0 new messages