발표 스크립트를 한국어 자막으로 추가해 두었습니다.
안드로이드 앱을 개발할 때 사용하는 IDE(Android Studio) 장점과 Vim의 장점을 섞어 개발하면 코드 생산성을 높이는데 도움을 줍니다. 오픈소스 JetBrains Plugin ideaVim을 커스터마이징한 경험을 공유합니다.
3. kimkevin@DroidNights2018: ~
What is Vim?
Vim is a highly configurable text editor
built to enable efficient text editing. It is
an improved version of the vi editor
distributed with most UNIX systems.
Vim is often called a "programmer's editor,"
and so useful for programming that many
consider it an entire IDE. Vim is perfect for
all kinds of text editing, from composing
email to editing configuration files.
– Johnny Appleseed
4. kimkevin@DroidNights2018: ~
What is Vim?
Vim is a highly configurable text editor
built to enable efficient text editing. It is
an improved version of the vi editor
distributed with most UNIX systems.
Vim is often called a "programmer's editor,"
and so useful for programming that many
consider it an entire IDE. Vim is perfect for
all kinds of text editing, from composing
email to editing configuration files.
– Johnny Appleseed
Vim는 유닉스 환경에서 가장 많이 사용되
는 문서 에디터이다. 리눅스에서 뿐만 아니
라 macOS에서도 기본 에디터로 사용되고
있다. 책이나 문서를 통해 혼자서 배우기는
어렵지만 익히고 나면 코드 생산성에 큰
도움을 준다.
5. kimkevin@DroidNights2018: ~
IdeaVim is a Vim emulation plugin for IDEs
based on the IntelliJ platform. IdeaVim can
be used with IntelliJ IDEA, PyCharm, CLion,
PhpStorm, WebStorm, RubyMine, AppCode,
DataGrip, GoLand, Cursive, and Android
Studio.
– Jetbrains ideavim GitHub
What is IdeaVim?
6. kimkevin@DroidNights2018: ~
IdeaVim is a Vim emulation plugin for IDEs
based on the IntelliJ platform. IdeaVim can
be used with IntelliJ IDEA, PyCharm, CLion,
PhpStorm, WebStorm, RubyMine, AppCode,
DataGrip, GoLand, Cursive, and Android
Studio.
– Jetbrains ideavim GitHub
What is IdeaVim?JetBrains에서 개발한 오픈 소스이며
IntelliJ 플랫폼 기반의 IDE에서 vim을 사용
할 수 있도록 플러그인으로 제공한다.
Android Studio의 Plugins 메뉴에
‘Browse Repositories’에서 검색하면 설치
할 수 있다.
15. kimkevin@DroidNights2018: ~
public void setUser(User user)
// $ : the end of line
public void setUser(User user)
// 0 : the start of the line
public void setUser(User user)
// w : move forward word
public void setUser(User user)
// b : move backward word
public void setUser(User user)
16. kimkevin@DroidNights2018: ~
public void setUser(User user)
// 2w : move forward two words
public void setUser(User user)
// dw : delete forward word
public void (User user)
// u : undo
public void setUser(User user)
// db : delete backward word
public setUser(User user)
19. kimkevin@DroidNights2018: ~
1. Basic Vim Shortcuts
2. Useful Mappings
in .ideavimrc
vim을 사용하다 보면 기본키로 만족 못 할
때가 있다. 사용자 정의를 통해 단축키를 사
용하고 싶다면 .ideavimrc 파일을 생성해서
키맵을 추가하면 된다.
21. kimkevin@DroidNights2018: ~
The Most Used Action is ‘Run’
Ctrl + Shift + r or
in my case, rr
Android Studio에서 가장 많이 사용하는
액션으로는 ‘Run’이다. 단축키로는 Ctrl + R
또는 마우스로 Run을 클릭하면 된다.
하지만 키맵을 사용하면 ‘rr’을 입력해서
Run을 할 수 있다.
23. kimkevin@DroidNights2018: ~
vi ~/.ideavimrc
File for your specific Vim
initialization commands
홈 폴더에 .ideavimrc를 생성해서 키맵을
정의할 수 있다.
IDE을 시작 또는 재시작하면 .ideavimrc
파일을 읽어서 명령어들을 초기화 해준다.
그리고 IDE의 Action(리팩토링, 깃, 디버
깅, 빌드 등) 또한 키맵을 추가해서 사용할
수 있다.
30. kimkevin@DroidNights2018: ~
nnoremap <leader>rr :action Run<cr>
n + nore + map
normal mode + non-reculsive + map
{cmd} {attr} {lhs} {rhs}
nnoremap 은 나누어 보면 Normal 모드에서 비재
귀적인 키맵을 의미한다.
여기에서 ‘non-reculsive’는
예를 들어, A를 눌렀을 때 B가 실행되고 (A -> B)
B를 눌렀을 때 A가 실행되는 (B->A)
키맵 설정이 있다면 무한 루프에 빠질 수 있어서 이
를 방지하기 위해서다.
32. kimkevin@DroidNights2018: ~
nnoremap <leader>rr :action Run<cr>
// {lhs} : left hand side
// {rhs} : right hand side
:actionlist (Show all actions)
ex) Run, RenameElement, FindUsages
<cr> : carriage return
{cmd} {attr} {lhs} {rhs}
33. kimkevin@DroidNights2018: ~
nnoremap <leader>rr :action Run<cr>
// {lhs} : left hand side
// {rhs} : right hand side
:actionlist (Show all actions)
ex) Run, RenameElement, FindUsages
<cr> : carriage return
{cmd} {attr} {lhs} {rhs}IDE에서 제공해주는 모든 action은 vim을
설치하고 ‘:actionlist’를 입력하면 모든
action들을 확인할 수 있다.
41. kimkevin@DroidNights2018: ~
Cmd + Tab
Cmd + Tab
Cmd + Tab
Cmd + Tab
Android Studio에서 코드를 작성 Cmd + Tab
터미널에서 adb로 기기를 wifi로 연결 Cmd + Tab
구글 검색을 하기 위해 Cmd + Tab
터미널에서 Git 명령어로 소스 관리 Cmd + Tab
계속해서 반복되는 ‘Cmd + Tab’ 줄이거나 할 수 있
는 방법이 없을까를 고민하게 되었다.
43. kimkevin@DroidNights2018: ~
The problem is
So boring…
What’s Wifi address?…
and port…
EVERYDAY
EVERYTIME
Cmd + Tab의 사용을 줄여보자.
Wifi 주소나 Port 등 무엇인가 기억해야
하고 반복해서 입력해야 하는 것이 지루하
다.
49. kimkevin@DroidNights2018: ~
1. EX mode is which is invoked
using the ex command.
2. This is for the Ex commands,
3. ”:", the pattern search
4. commands, "?" and "/", and the
5. filter command, "!".
~
~
~
~
:%s/command/cmd/g
50. kimkevin@DroidNights2018: ~
1. EX mode is which is invoked
using the ex command.
2. This is for the Ex commands,
3. ”:", the pattern search
4. commands, "?" and "/", and the
5. filter command, "!".
~
~
~
~
:%s/command/cmd/g
‘:’ 입력하면 EX 모드에서
EX 명령어를 실행할 수 있다.
51. kimkevin@DroidNights2018: ~
1. EX mode is which is invoked
using the ex cmd.
2. This is for the Ex cmds,
3. ”:", the pattern search
4. cmds, "?" and "/", and the
5. filter cmd, "!".
~
~
~
~
~
70. kimkevin@DroidNights2018: ~
https://github.com/kimkevin/ideavim-as
git
git commands
adb
adb start <device_ip_address>
adb start : Once it's connected,
IP address will be existed.
Google Search
gg <query_string>
gg : If clipboard has a string
Supported:adb의 경우 한번 Wifi 주소를 입력하고 나면 캐
싱이 되기 때문에 ‘:adb start’를 통해 곧바로
디바이스와 연결할 수 있다.
구글 검색을 위해서 Cmd + Tab으로 브라우저
이동 없이 클립보드에 복사된 내용이 있으면
‘:gg’ 명령어를 통해 자동으로 브라우저가 실행
되고 검색된 결과를 한번에 확인할 수 있다.
75. kimkevin@DroidNights2018: ~
DataContext
- Data Object by
Identifier
ExCommand
- Command
- Arguments
Editor
- Project (path, document)
- EditorColorsScheme
- EditorSettings
하나 더 기능을 추가한다면
‘:morning’을 입력하면 IDE의 테마를 밝은 것으로
‘:night’을 입력하면 IDE의 테마를 어두운 것으로
변경해보는 Handler를 만들어 볼 예정이다.
‘execute’ 함수의 파라미터로 ‘Editor’ 클래스에서
제공해주는 API가 많고 다양하며,
EditorColorsSchemes에도 접근이 가능하다.
76. kimkevin@DroidNights2018: ~
1. Create EX command Handler and
Register CommandParser
2. Set command and flags on super
class
3. Write codes in execute()
4. Run and Test
87. kimkevin@DroidNights2018: ~
Make you lazy!
vim을 끄고 싶을 때, 생각한 것은 ‘내가 더
게을러 지는 것이다.’ 누구나 오른손에 있는
마우스가 편하기 때문에 습관을 버리기가
어렵다. 이를 위해, 마우스를 왼쪽으로 옮겨
마우스 사용이 더 불편한 상황을 만들어 보
자.