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

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

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

Toshikazu Ohashi

March 11, 2019
Tweet

More Decks by Toshikazu Ohashi

Other Decks in Programming

Transcript

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

    View full-size slide

  2. ΠϯτϩμΫγϣϯ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  8. 7JNΛίʔϧ͢ΔίϚϯυͱ͸
    • crontab -e
    • git commit
    • etc...
    ࣮ߦ͢ΔͱΤσΟλ(Vimͱ͔)Λىಈͯ͠ϑΝΠϧΛ։͘->
    อଘͯ͠ดͨ͡ͱ͖ɺฤू݁ՌΛύʔεͯ͠࢖͏ίϚϯυ

    View full-size slide

  9. %FNP
    • git commit
    • SQL client(mysql, psql, etc)

    View full-size slide

  10. ౾஌ࣝ
    git commit ͱ͔ git rebase -i Ωϟϯηϧ͍ͨ͠Μ
    Ͱ͚͢Ͳ
    • :cq ͠·͠ΐ͏
    • ฤू಺༰Λഁغͯ͠ΤϥʔίʔυΛฦ͠·͢

    View full-size slide

  11. ؀ڥม਺&%*503

    View full-size slide

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

    View full-size slide

  13. 74$PEFΛىಈ͍ͨ͠
    • ୯७ʹ export EDITOR=code ͩͱବ໨
    • ىಈޙϓϩηε͕ৗற͢ΔλΠϓͷΤσΟλͩͱฤू
    ׬ྃΛ଴ͨͳ͍
    • ϑΝΠϧ։͍ͯଈ࠲ʹίϚϯυͱͯ͠͸ऴΘΔ
    • export EDITOR='code --wait'
    • --waitΛ͚ͭΔ͜ͱͰฤू׬ྃ·Ͱ଴ͭΑ͏ʹͳΔ

    View full-size slide

  14. %FNP
    • git commit on vscode

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  19. %FNP
    • vimdiff

    View full-size slide

  20. (JUWJNEJ⒎
    • git difftool Ͱࠩ෼৘ใΛ֎෦πʔϧʹ࿈ܞ͢Δ͜ͱ
    ͕Ͱ͖Δ
    • Gitͷࠩ෼ΛVim্ͰݟΔ͜ͱ͕Ͱ͖Δ
    • git mergetool ͰίϯϑϦΫτ৘ใΛ֎෦πʔϧʹ࿈
    ܞ͢Δ͜ͱ͕Ͱ͖Δ
    • GitͷίϯϑϦΫτΛVimͰղফ͢Δ͜ͱ͕Ͱ͖Δ

    View full-size slide

  21. (JUͷEJ⒎UPPMʹ7JNΛ࢖͏
    • ҎԼͷઃఆΛ~/.gitconfigʹ௥Ճ͢Δ͜ͱͰvimdiff
    ΛGitͷdifftoolͳ͍͠mergetoolͱͯ͠ొ࿥Ͱ͖Δ
    [diff]
    tool = vimdiff
    [merge]
    tool = vimdiff

    View full-size slide

  22. Ԡ༻ฤ5JH࿈ܞ

    View full-size slide

  23. 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)"

    View full-size slide

  24. %FNP
    • tig & git difftool

    View full-size slide

  25. ෇࿥/FP7JNͷWJNEJ⒎

    View full-size slide

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

    View full-size slide

  27. /FP7JNͷHJUUPPM
    • 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\""

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide