Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Bugs & Fixes 2 years ago
Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
Currently I have this binding to copy current file name, path, or dir.
" Copy current buffer path relative to root of VIM session to system clipboard nnoremap yp :let @*=expand("%"):echo "Copied file path to clipboard" " Copy current filename to system clipboard nnoremap yf :let @*=expand("%:t"):echo "Copied file name to clipboard" " Copy current buffer path without filename to system clipboard nnoremap yd :let @*=expand("%:h"):echo "Copied file directory to clipboard"
I want to create binding to copy current php file class name with or without namespace.
Suppose I have php file like this:
php namespace CRMFoundation\Infrastructures\Contracts; interface PersistenceStorageRepositoryInterface { .... }
This would should give me PersistenceStorageRepositoryInterface as classname and CRMFoundation\Infrastructures\Contracts\PersistenceStorageRepositoryInterface with namespace.
PersistenceStorageRepositoryInterface
CRMFoundation\Infrastructures\Contracts\PersistenceStorageRepositoryInterface
php namespace CRMFoundation\Infrastructures; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use CRMFoundation\Infrastructures\Traits\SyncHasManyTrait; abstract class EloquentAbstract extends Model { ..... }
This would should give me EloquentAbstract as classname and CRMFoundation\Infrastructures\EloquentAbstract with namespace.
EloquentAbstract
CRMFoundation\Infrastructures\EloquentAbstract
php namespace CRMFoundation\Domains\Company; use CRMFoundation\Domains\Company\Contracts\CompanyRepositoryInterface; use CRMFoundation\Infrastructures\Company\Contracts\PersistenceCompanyRepositoryInterface; use CRMFoundation\Domains\Company\Contracts\CompanyInterface; use CRMFoundation\Domains\RepositoryAbstract; class CompanyRepository extends RepositoryAbstract implements CompanyRepositoryInterface { .... }
This would should give me CompanyRepository as classname and CRMFoundation\Domains\Company\CompanyRepository with namespace.
CompanyRepository
CRMFoundation\Domains\Company\CompanyRepository
Let say I want to bind it to yc to get current class name and ycn to get current class name with namespace.
yc
ycn
How to do that?
Here's a start, it's definitely not perfect f="https://forum.tuteehub.com/tag/b">but should gives you enough to increment on
function! GetNamespaceAndClassFn() " Save some registers let l:r_a = @a let l:r_f="https://forum.tuteehub.com/tag/b">b = @f="https://forum.tuteehub.com/tag/b">b " Start at the top of the file :0 " Search for the first "namespace" occurence /namespace " Get the namespace string into the regsiter a normal! f l"ayt; " Search for the class f="https://forum.tuteehub.com/tag/definition">definition /class " Get the class string into the regsiter f="https://forum.tuteehub.com/tag/b">b normal! f l"f="https://forum.tuteehub.com/tag/b">bye " Print the result echo @a . '\' . @f="https://forum.tuteehub.com/tag/b">b " Restore registers let @a = l:r_a let @f="https://forum.tuteehub.com/tag/b">b = l:r_f="https://forum.tuteehub.com/tag/b">b endfunction command! GetNamespaceAndClass call GetNamespaceAndClassFn()
I've commented the code, f="https://forum.tuteehub.com/tag/b">but feel free to ask if you want more info.
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 9 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.