Vimdagi fayllar seriyasini navigatsiya qilish

Kodni o'zgartirganda, eng oddiy narsalarni o'zgartirish uchun ko'plab fayllar bilan o'tishim kerak. Masalan, pretty_print funktsiyasiga ega deb aytish imkonini beradi va men buni prettyPrint tugmachasiga mos kelish uchun o'zgartiraman. Endi apple1.js fayllarini apple99.js ga va ehtimol, bir necha orange.js fayllari orqali o'tmoqchiman. Buni Vimda qilishning tez yo'li bormi?

QAYD: bu men avtomatlashtirishim mumkin emas, aslida kodni o'zimga o'zgartirishim kerak.

I know I can do :b , but, although it supports name completion/pattern matching, I don't think the pattern is carried over.

Masalan, agar qilsam

:b apple*.js

va men yorlig'ni urgan edim, men olaman

:b apple1.js

(agar : + upArrow yoki q: tugmachalarini bosib, bu funktsiyani qayta tekshirsam,

:b apple2.js

Men istagan narsaga o'xshash narsani aniqlashdir

:b apple*.js

keyin faylni tahrir qiling, keyin : w yozganda, keyingi buferga o'tadi. Men Vimda qolishni afzal ko'rmoqchiman, chiqish istamayman, vim apple * .js yozing, Vimga qaytib, keyin : x buyrug'ini ishlating. Ushbu asarlarni tushunaman, lekin men istagan holatda ham boshqa barcha fayllarga muhtojman, masalan, teglar orasidan o'tish.

3

3 javoblar

shu bilan boshlang:

:set hidden "required because `argdo` won't load next argument into current window
            "if there is a modified buffer displayed inside this window
:args apple*.js
:argdo %s/\/prettyPrint/g
:rewind " if you want to proofread all files then use :next and :prev
:wa

O'zingizning fayllaringizni yaxshiroq tanlaysiz va bunday o'zgarishlardan keyin farq qilasiz.

1
qo'shib qo'ydi

Wikia'dan BufSel vazifasi ehtiyojlaringizga mos keladimi?

Agar siz ro'yxatdagi buferni tanlashni xohlasangiz   qisman mosliklar quyidagi funksiyadan foydalanish mumkin. U o'tishadi   agar bitta o'yin topilsa, yoki ko'p bo'lsa, mos keladigan bufer   mos keladigan bu mos keladigan buferlarning ro'yxatini chop etadi   buyruq satri maydonini tanlang va mos keladigan buferlardan birini tanlab belgilang   bufer raqami bilan.

function! BufSel(pattern)
  let bufcount = bufnr("$")
  let currbufnr = 1
  let nummatches = 0
  let firstmatchingbufnr = 0
  while currbufnr <= bufcount
    if(bufexists(currbufnr))
      let currbufname = bufname(currbufnr)
      if(match(currbufname, a:pattern) > -1)
        echo currbufnr . ": ". bufname(currbufnr)
        let nummatches += 1
        let firstmatchingbufnr = currbufnr
      endif
    endif
    let currbufnr = currbufnr + 1
  endwhile
  if(nummatches == 1)
    execute ":buffer ". firstmatchingbufnr
  elseif(nummatches > 1)
    let desiredbufnr = input("Enter buffer number: ")
    if(strlen(desiredbufnr) != 0)
      execute ":buffer ". desiredbufnr
    endif
  else
    echo "No matching buffers"
  endif
endfunction

"Bind the BufSel() function to a user-command
command! -nargs=1 Bs :call BufSel("")
1
qo'shib qo'ydi
Men aslida bufselni o'rnatdim va uni birinchi marta ishlatganman, lekin keyin voz kechib, bu erda istagan narsani qiladimi, deb o'ylayman. Har qanday holatda ham : b ga nisbatan ancha yaxshilanish yo'q edi va u faqat vimni yopish uchun juda oson bo'lib chiqdi va tahrirlashni istagan fayllar bilan qayta ishga tushirildi.
qo'shib qo'ydi muallif puk, manba

Probably the most suitable solution for you in this case would be to use the grep capabilities integrated in Vim. The following command performs a search for the pattern \ in files matching the wildcard apple*.js, and stores locations of the pattern's occurrences in the quickfix list allowing to easily jump through all the matches.

:vimgrep /\/ apple*.js

Qidirib topish uchun tezkor ro'yxatga batafsil ma'lumot olish uchun fayllar uchun qarang: mening savolim " Olingan fayllar to'plamini yuklash Vim buffers-da cmd-exec orqali .

Agar ma'lum bir faylga mos keladigan fayllar ro'yxatini ochmoqchi bo'lsangiz joker belgilar, fayllarning nomlarini dalillar ro'yxatiga yuklang

:args apple*.js

keyin odatdagidek : n va : N yordamida navigatsiya qiling.

1
qo'shib qo'ydi