Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ターミナルアプリケーションとしてのVim

 ターミナルアプリケーションとしてのVim

A12373843afc54857a845404bdd5f5cb?s=128

Toshikazu Ohashi

March 11, 2019
Tweet

More Decks by Toshikazu Ohashi

Other Decks in Programming

Transcript

  1. λʔϛφϧ ΞϓϦέʔγϣϯ ͱͯ͠ͷ 7JN ΰϦϥWJN !MJHIUUJHFS

  2. ΠϯτϩμΫγϣϯ   

  3. 7JNͷྑ͞ͱ͍͑͹ʁ • λʔϛφϧͷதͰىಈ͢Δ • ϞʔυʹΑΔҠಈ/ฤू͕ͱͬͯ΋ศར • VimscriptʹΑΔ֦ுੑͷߴ͞ • ىಈͷ଎͞ •

    େମͷαʔόϚγϯͰΠϯετʔϧࡁΈ
  4. ຊ೔ͷςʔϚ • λʔϛφϧͷதͰىಈ͢Δ • ϞʔυʹΑΔҠಈ/ฤू͕ͱͬͯ΋ศར • VimscriptʹΑΔ֦ுੑͷߴ͞ • ىಈͷ଎͞ •

    େମͷαʔόϚγϯͰΠϯετʔϧࡁΈ
  5. λʔϛφϧ಺Ͱىಈ͢Δྑ͞ ͱ͍͑͹ʁ • αʔόϚγϯ಺ͩͱͦ΋ͦ΋GUIΤσΟλ͕࢖͑ͳ͍ • ଞͷίϚϯυ͔Βͷ࿈ܞ͕εϜʔζʹߦ͑Δ

  6. ຊ೔࿩͢಺༰ • αʔόϚγϯ಺ͩͱͦ΋ͦ΋GUIΤσΟλ͕࢖͑ͳ͍ • ଞͷίϚϯυ͔Βͷ࿈ܞ͕εϜʔζʹߦ͑Δ

  7. ίϚϯυ͔Β7JNΛίʔϧ ͢Δͱ͍͏͜ͱ   

  8. 7JNΛίʔϧ͢ΔίϚϯυͱ͸ • crontab -e • git commit • etc... ࣮ߦ͢ΔͱΤσΟλ(Vimͱ͔)Λىಈͯ͠ϑΝΠϧΛ։͘->

    อଘͯ͠ดͨ͡ͱ͖ɺฤू݁ՌΛύʔεͯ͠࢖͏ίϚϯυ
  9. %FNP • git commit • SQL client(mysql, psql, etc)

  10. ౾஌ࣝ git commit ͱ͔ git rebase -i Ωϟϯηϧ͍ͨ͠Μ Ͱ͚͢Ͳ •

    :cq ͠·͠ΐ͏ • ฤू಺༰Λഁغͯ͠ΤϥʔίʔυΛฦ͠·͢
  11. ؀ڥม਺&%*503   

  12. 7JNͰ͔͠։͔ͳ͍ʁ • ΤσΟλΛ։͘ίϚϯυ͸ଟ͘ͷ৔߹EDITORʹઃఆ͞ Ε͍ͯΔίϚϯυΛ࣮ߦ͢Δ • export EDITOR=vim ͩͱVimΛىಈ͢Δ • ׳शͱͯ͠ͷ͜͏ͳ͍ͬͯΔ͚ͩͳͷͰɺEDITORΛ࢖

    ༻͠ͳ͍ίϚϯυ΋͋Δ
  13. 74$PEFΛىಈ͍ͨ͠ • ୯७ʹ export EDITOR=code ͩͱବ໨ • ىಈޙϓϩηε͕ৗற͢ΔλΠϓͷΤσΟλͩͱฤू ׬ྃΛ଴ͨͳ͍ •

    ϑΝΠϧ։͍ͯଈ࠲ʹίϚϯυͱͯ͠͸ऴΘΔ • export EDITOR='code --wait' • --waitΛ͚ͭΔ͜ͱͰฤू׬ྃ·Ͱ଴ͭΑ͏ʹͳΔ
  14. %FNP • git commit on vscode

  15. 74$PEFͰ͍͍ͷͰ͸ʁ • (ྲྀੴʹVimʹൺ΂Δͱ)ىಈ͕஗͍ • λʔϛφϧʹ໭Δ·Ͱʹϫϯεςοϓඞཁ • VimͳΒ :wq Ͱ໭Δ •

    VSCodeͳΒ อଘͯ͠ด͡Δ > λʔϛφϧʹ໭Δ
  16. ͜͜·Ͱͷ·ͱΊ • λʔϛφϧ্ͰίϚϯυ͔ΒVimΛݺͼग़͢ͷศར • ىಈ଎౓΋૬·ͬͯɺίϚϯυ͔Βίʔϧ͞ΕΔΤσΟ λͱͯ͠͸VimʹΞυόϯςʔδ͕͋Δͱࢥ͍ͬͯΔ

  17. ͖Έ͸WJNEJ⒎Λ ͍ͬͯ͠Δ͔   

  18. WJNEJ⒎ͱ͸ Vimʹ಺ଂ͞Ε͍ͯΔࠩ෼දࣔ/Ϛʔδπʔϧ • vimdiff file1 file2 [file3 [file4]] • vim

    -d file1 file2 [file3 [file4]]
  19. %FNP • vimdiff

  20. (JU࿈ܞ   

  21. (JU WJNEJ⒎ • git difftool Ͱࠩ෼৘ใΛ֎෦πʔϧʹ࿈ܞ͢Δ͜ͱ ͕Ͱ͖Δ • Gitͷࠩ෼ΛVim্ͰݟΔ͜ͱ͕Ͱ͖Δ •

    git mergetool ͰίϯϑϦΫτ৘ใΛ֎෦πʔϧʹ࿈ ܞ͢Δ͜ͱ͕Ͱ͖Δ • GitͷίϯϑϦΫτΛVimͰղফ͢Δ͜ͱ͕Ͱ͖Δ
  22. (JUͷEJ⒎UPPMʹ7JNΛ࢖͏ • ҎԼͷઃఆΛ~/.gitconfigʹ௥Ճ͢Δ͜ͱͰvimdiff ΛGitͷdifftoolͳ͍͠mergetoolͱͯ͠ొ࿥Ͱ͖Δ [diff] tool = vimdiff [merge] tool

    = vimdiff
  23. Ԡ༻ฤ5JH࿈ܞ   

  24. 5JHͱ͸ • λʔϛφϧ্ͰGitΛϦονʹදࣔ͢ΔTUIΞϓϦ • ઃఆϑΝΠϧ(~/.tigrc)ͰڍಈΛΧελϚΠζͰ͖Δ • ҎԼͷઃఆΛೖΕΔ͜ͱͰɺtigͰબ୒ͨ͠diffΛ vimdiffͰݟΔ͜ͱ͕Ͱ͖Δ bind main

    D !sh -c "git difftool %(commit)~ %(commit)" bind diff D !sh -c "git difftool %(commit)~ %(commit)" bind refs D !sh -c "git difftool %(branch)"
  25. %FNP • tig & git difftool

  26. ෇࿥/FP7JNͷWJNEJ⒎   

  27. /FP7JNͷWJNEJ⒎ •vimdiffͱ͍͏ίϚϯυ͸VimͷγϯϘϦοΫϦϯΫ •NeoVimΠϯετʔϧࡁΈͰ΋vimdiffΛୟ͘ͱVim͕ىಈ •NeoVimͷࠩ෼ϞʔυΛvimdiffͰ࣮ߦ͢Δ৔߹ɺҎԼͷ ΤΠϦΞεઃఆ͕ඞཁ alias vimdiff='nvim -d'

  28. /FP7JNͷHJU<EJ⒎NFSHF>UPPM • git [diff/merge]tool͸ΤΠϦΞεΛݟͳ͍ • NeoVimͷvimdiffΛ࢖͏৔߹ɺ~/.gitconfigʹҎԼ ͷઃఆ͕ඞཁ [difftool "vimdiff"] cmd

    = "nvim -R -d -c \"wincmd l\" -d \"$LOCAL\" \"$REMOTE\"" [mergetool "vimdiff"] cmd = "nvim -d -c \"4wincmd w | wincmd J\" \"$LOCAL\" \"$BASE\" \"$REMOTE\" \"$MERGED\""
  29. ࠷ޙʹ   

  30. ࠓ೔఻͔͑ͨͬͨϝοηʔδ • Vim͕ϑΟοτ͢Δൣғ͸෯޿͍ • ϝϞॻ͖ͷΑ͏ͳͪΐͬͱͨ͠ฤू • IDEͷΑ͏ͳॏ͍ฤू • VimΛىಈͯ͠Ӡʑ͚ͩͰͳ͘ɺ֎෦͔ΒVimΛىಈ͢Δ ͱ޾ͤͳ͜ͱ͕͋Δύλʔϯ΋͋Δ

  31. 7JNͦΕ͸Մೳੑͷ्

  32. ࣗݾ঺հ lighttiger2505 •αʔόαΠυΤϯδχΞ@iRidge •࢓ࣄ:Python •झຯ:Golang࣌ʑVimscript •lab •deoplete-vim-lsp