How to bind to multiple keymaps with one line? - tig

I'm trying to remap/bind G in tig to match vim's functionality (move to last line) in all of tig's keymaps.
I read the tigrc manpage, here's all that's mentioned about binding to keymaps
Keymaps
Valid keymaps are: main, diff, log, help, pager, status, stage,
tree, blob, blame, refs, stash, grep and generic. Use generic to
set key mapping in all keymaps. Use search to define keys for
navigating search results during search.
here's what currently works, but not optimal or preferable:
bind main G move-last-line
bind help G move-last-line
bind grep G move-last-line
here's what I expected would work:
bind generic G move-last-line or bind main,help,grep G move-last-line
PS: I feel questions of this type are more appropriate for unix stack exchange, but there's no tag for tig there yet, and there are similar questions to it on SO.

As you mentioned, bind generic G move-last-line is enough.
It works for me.

Related

Trigger a Vim custom g# command on a single line?

In Vim 8.x, is there a way to specify a same-line action when using g# and :set opfunc to define a custom command? In other words, I know how to use map to:
noremap <silent> <a-z> :set opfunc=MyFuncOp<cr>g#
Let's say MyFuncOp does some custom type of yank or delete. It works perfectly to press alt-z then j and do that on two lines. But what if you need it on just one line... just like you would with repeated operators like dd or yy? Mapping g#g# doesn't work. How do you convey a single linewise (i.e., the current line) to a g# custom command?
It may depend on how your MyFuncOp() is implemented but, in general, you should only need to do <A-z>l, <A-z>h, or basically use any motion that stays on the current line: 0, $, etc. Just like with a real operator.
Showing us your MyFuncOp() would help.
No, it's not to be implemented by custom g# only. Basically, you have two options.
Either, (1) create also a custom motion (mapmode-o) that includes the whole current line. So, say, you have Y to perform custom "yank" and al to select current line in operator pending mode. Then typing Yal will do. There are many existing implementations of such "custom motion" out there. And it's also pretty easy to devise another one yourself.
Or (2), define special version of your mapping. That is, both Y to invoke g-at, and YY to perform custom operation on the current line without entering the operator pending mode. Proper use of functions and commands should help to avoid code duplication in this case.

EasyMotion repeat

I've replaced my fFtT completely with EasyMotion's equivalent and I've found it to be adequate in most cases except when I need to repeat the last motion with text objects. For example, dot command following ct or cf don't work the way they're supposed to. Is there a way make this work somehow, or do I have to resort to mapping the original ftFT for cases like this?
I try to be bold, without testing and say, NO, it cannot be repeated.
you typed some magic key (for example, f . Default <leader><leader>f), triggered easyMotion, try to move to letter x. but on your current screen, there are 10 x after your cursor. Then you typed c to move to the right one. now you try to type dot . to repeat it. how easyMotion know which x you want to go to next?

vim-7 with ctags

running VIM-7.0.237 on CentOS-5.6. I have a large C code base with tags generated with ctags-5.6, there are functions with the same name defined in several places and I remember back when I used vim-6.3, I could jump over those multiple definitions easily -- VIM used to suggest me what definition I want to jump at. Now with vim-7 it gives me only first.
Is there a way to have a old-style behavior? Thanks.
PS. I have a default VIM configuration.
You can either precede the command with a count to jump to a specific match or use
:ts {identifier}. It will list the tags available for the given identifier.
You may find the ctrlrctrlw command
(et similars) useful to insert the word under cursor. A map may help you with
it.
nnoremap \] :ts <c-r><c-w><CR>
Use g] (g$ on french azerty keyboards) to display a list of definitions.

Is there a reason some of VIM's motion commands are restricted to one line?

I'm beginning to learn VIM (I've downloaded an emulator plugin for my IDE) and unsurprisingly it's making me irritated and extremely slow. That is all fine and I realize it's a phaze everyone goes through.
However this one feature is quite frustrating - being unable to jump to the next line via l, previous with h or search more than one line with f.
Is there a valid, typing speed enhancing reason for this?
You can make h and l wrap lines by adding h and l to the whichwrap option (:he whichwrap), although for the sake of compatibility with scripts and macros that don't expect h and l to wrap, you might want to avoid adding them, and add the < and > options instead (which allow the left and right arrow keys to wrap).
As for f (and F and t and T), they're just really not meant to do that, but you can use / and ? as movements -- d/foo<Enter> to delete everything between here and a following "foo" (whether it's on this line or a later one).

How can I operate on more Emacs buffers at the same time?

I am looking for an equivalent of the :bufdo Vim command in Emacs. :bufdo takes an argument - another command - and executes the command on all open buffers. I have not yet found a similar feature in Emacs.
Depending on what your command is, you can do:
M-: (mapc (lambda (b) (set-buffer b) (*command*)) (buffer-list))
But, I have a feeling you want something not so lispy. Take a look at keyboard macros. Namely, decide what you want to do:
C-x ( <do-your-command> C-x )
M-: (mapc (lambda (b) (set-buffer b) (kmacro-end-and-call-macro)) (buffer-list))
You'd probably want to define that last part as a function if you use it much:
(defun bufdo ()
"execute last macro on all buffers, ala bufdo from vi"
(interactive)
(mapc (lambda (b)
(with-current-buffer b
(kmacro-end-and-call-macro)))
(buffer-list)))
Note: code is untested
You can also checkout ibuffer, it allows you to mark buffers you like to operate on with m and then you can execute something on it with E. Other common operations are also available, e.g. query-replace on Q. Just check out the menu or the mode description (C-h m).
BTW, similar things are also possible from dired, although it doesn't seem to give you an eval command.
Take a look at buffer-list (function). It returns a list of all the open buffers (BUFFER objects). See the manual for a simple example of using it with mapcar (which operates on every element of the list, and accumulates the results). You would probably also find set-buffer, which programatically sets the current buffer from Emacs Lisp, useful.

Resources