sponsor Vim development Vim logo Vim Book Ad

make_target.vim : Make target for Makefile recipe under cursor

 script karma  Rating 1/1, Downloaded by 16  Comments, bugs, improvements  Vim wiki

created by
Tom Ryder
script type
This filetype plugin for Makefiles ("make" filetype) provides an autoload function make#target#Make() and buffer-local mapping <Plug>(MakeTarget) to make! the target for the recipe under the cursor, if it can be identified.
install details
Put autoload/make/target.vim in ~/.vim/autoload/make/target.vim. The ftplugin itself should probably be saved as ~/.vim/after/ftplugin/make/target.vim (per the distribution layout) or ~/.vim/after/ftplugin/make_target.vim (if you prefer), so that it definitely loads *after* the primary make.vim plugin; or, just use your favourite Vim plugin manager.

There is no default key binding; you could do this in your .vimrc to bind _m, for example:

    autocmd FileType make
          \ nmap <buffer> _m <Plug>MakeTarget

A cleaner and more complete implementation that correctly clears the group on reload and the mapping on filetype switch might be:

    let g:maplocalleader = '_'
    augroup vimrc_filemap
      autocmd FileType *
            \ silent! nmapclear <buffer> <LocalLeader>m
      autocmd FileType make
            \ nmap <buffer> <LocalLeader>m <Plug>(MakeTarget)
    augroup END

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vim-make-target-1.0.2.tar.gz 1.0.2 2018-09-06 7.0 Tom Ryder Parenthesize map names, correct faulty unmap, correct documentation
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
OSDN.net Logo