Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 20, 2022. It is now read-only.

A text object for Laravel's Blade directives

NotificationsYou must be signed in to change notification settings

adriaanzon/vim-textobj-blade-directive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ever felt like using this text object in a different filetype?I did, so I created this other one.

vim-textobj-blade-directive

A text object for Laravel'sBladedirectives.

Example

Installation

Depends onvim-textobj-user andvim-blade.

Plug'kana/vim-textobj-user'Plug'jwalton512/vim-blade'Plug'adriaanzon/vim-textobj-blade-directive'

Also requires the matchit.vim plugin to be enabled. You can check if it'senabled by running:echo g:loaded_matchit, it should return1.

If it's not enabled yet, you can do so by putting the following in your vimrc:

runtime macros/matchit.vim

Usage

When textobj-blade-directive is installed you will gain two new text objects,which are triggered byad andidrespectively. These follow Vim convention, so thatadselectsall of a Blade directive, andid selects theinner portion of a Blade directive.

Tips

In the example GIF, the@if statement got surrounded with a@can statement.This isn't directly related to this plugin, but it was achieved using thevim-surround plugin, with thefollowing configuration inafter/ftplugin/blade.vim:

" Use 'd' to surround with a Blade directive.letb:surround_{char2nr("d")}="@\1Blade directive: @\1\r @end\1\r\[(\]\\+.*\r\1"" Some aliases for convenience.letb:surround_{char2nr("D")}=b:surround_{char2nr("d")}letb:surround_{char2nr("@")}=b:surround_{char2nr("d")}

Now you can surround anything with a Blade directive. For example, if youwanted to surround a paragraph, you could select the paragraph withvip, followed by anS to activatevim-surround, followed by ad. This will open a prompt where you maytype your blade directive.

Limitations

  • Operations are done line wise, so this text object doesn't work forstatements on a single line.

  • Some text objects in Vim respond to a count. For example, thea{ text object will selectall of the current{}delimited block, but if you prefix it with the number 2 (e.g.v2i{) then it will select all ofthe block that contains the current block. The Blade directive text objectdoes not respond in this way if you prefix a count. This is due to alimitation in thetextobj-user plugin.

    However, you can achieve a similar effect by repeating the Blade directivetext-object manually. So if you pressvad toselect the current Blade directive, you can expand your selection outwards byrepeatingad, or contract your selection inwards byrepeatingid.

Credits

Thanks to Drew Neil for his pluginvim-textobj-rubyblock.This plugin was made by simply changing the search patterns in his plugin.

I also thank Kana Natsuno for providinga framework to build custom textobjects.

License

Copyright © Adriaan Zonnenberg. Distributed under the same terms as Vim itself.See:help license.

About

A text object for Laravel's Blade directives

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp