ABOUT ME

-

  • Sublime Text 3 파이썬 개발 환경 만들기
    컴퓨터/파이썬 2020. 6. 14. 10:44
    728x90
    반응형

     

    https://www.sublimetext.com/3 

     

    결과물

    사용 중인 패키지 목록 보기 ↓

    더보기
    사용 중인 패키지 목록

    A File Icon - 탐색기 아이콘

    All Autocomplete - 모든 열려있는 파일에서 매치된 글자 찾기

    BracketHighlighter (아래 사진)

    Color Highlighter - CSS 파일 같은 곳에서 #FFF 입력하면 색깔 미리 보기

    ConvertToUTF8 - 섭라임에서 지원 안 되는 인코딩 지원 (GBK, BIG5, EUC-KR, EUC-JP)

    Diffy - 파일 비교

    Emmet - 웹 개발을 편히 할 수 있는 도구 (참고 : https://emmet.io/)

    Formatter - 여러 가지 언어 Beautify, Minify

    KiteSublime - Kite, AI 파이썬 코딩 어시스턴트 (프로그램을 깔아야 깔림 링크)

    Pug - Node, 웹 브라우저 템플릿 엔진

    Python PEP8 Autoformat - PEP8 스타일 도우미

    SublimeREPL - 파이썬 인터프리터를 SL3에서 열 수 있음

    SublimeCodeIntel - Kite와 비슷한 code intelligence engine

    Theme - One Dark - Atom 편집기 One Dark UI


    1. 테마 적용

    아톰 One Dark 테마가 이뻐서 (Theme - One Dark) 란 패키지를 다운로드했다.

    CTRL + SHIFT + P (Command Palette) 패키지 인스톨러에서 검색하고,

    Preferences - Theme 에서 One Dark 선택

    Preferences - Color Scheme 에서 One Dark 선택

    Preferences - Settings 누르고, user setting 에 다음 추가

    javascript
    "animation_enabled": false, "caret_extra_bottom": 1, "caret_extra_top": 2, "caret_extra_width": 1, "caret_style": "blink", "draw_white_space": "none", "ensure_newline_at_eof_on_save": true, "highlight_line": true, "line_padding_bottom": 1, "line_padding_top": 2, "margin": 0, "match_selection": false, "tree_animation_enabled": false, "scroll_past_end": false, "show_definitions": false, "show_tab_close_buttons": true // Mandatory if you want to see unsaved files in tab "one_dark_native_title_bar": true, // Only for Mac & Sublime Text 3 >= build 3127 "one_dark_show_scroll_tabs": true, // Only for Sublime Text 3 "one_dark_show_tabs_dropdown": true // Only for Sublime Text 3 "one_dark_bigger_sidebar": true, // Uses font-size 14 for the sidebar "one_dark_sidebar_font_fira_light": true, // Uses Fira Light for the sidebar

     

    CTRL + SHIFT + P (Command Palette) 패키지 인스톨러에서 A File Icon 을 검색하고, 설치한다.

    A File Icon 은 왼쪽 사이드 바에서 커스터마이징 가능한 아이콘을 사용할 수 있게 해 준다.

    ※ A File Icon 기본 색상으론 One Dark와 맞지 않는다. 그래서 기본 색상을 흰색으로 변경시켜준다.

    Preferences - Package Settings - A File Icon

    오른쪽 User 설정에 "color": "white", 를 추가한다.

     


    2. 파이썬 개발 환경

    CTRL + B로 실행할 수 있다. CTRL + SHIFT + B를 누르면 다른 빌드 시스템을 선택할 수 있다.

     

    KiteSublime - Kite, AI 파이썬 코딩 어시스턴트 (프로그램을 깔아야 깔림 링크)

    Python PEP8 Autoformat - PEP8 스타일 도우미

    Preferences - Package Settings - Python PEP8 Autoformat - Settings - Default

    아래를 추가하면 저장할 때마다 알아서 코드를 정리해준다.

    python
    "autoformat_on_save": true

    SublimeREPL - 파이썬 인터프리터를 SL3에서 열 수 있음 (지울 예정)

    SublimeCodeIntel - Kite와 비슷한 code intelligence engine

    FiraCode - 프로그래밍 최적화 폰트

    python
    "font_face": "Fira Code", "font_options": [ "subpixel_antialias" ],

     

    지금 사용하고 있는 SL3 옵션 ▼

    더보기

    프로그램 설정

    python
    { "animation_enabled": false, "bold_folder_labels": true, "caret_extra_bottom": 1, "caret_extra_top": 2, "caret_extra_width": 1, "caret_style": "smooth", "color_scheme": "Packages/Theme - One Dark/One Dark.tmTheme", "draw_white_space": "selection", "ensure_newline_at_eof_on_save": true, "font_face": "Fira Code", "font_options": [ "subpixel_antialias" ], "font_size": 16, "highlight_line": true, "ignored_packages": [ "Vintage" ], "line_padding_bottom": 1, "line_padding_top": 2, "margin": 0, "match_selection": false, "one_dark_bigger_sidebar": true, "one_dark_native_title_bar": true, "one_dark_show_scroll_tabs": true, "one_dark_show_tabs_dropdown": true, "one_dark_sidebar_font_fira_light": true, "scroll_past_end": false, "show_definitions": false, "show_line_endings": true, "show_tab_close_buttons": true, "theme": "One Dark.sublime-theme", "translate_tabs_to_spaces": true, "tree_animation_enabled": false }

    SideBarEnhacements

    python
    { "open_all_browsers": [ "chrome", "ie", "edge" ], "default_browser": "chrome", "use_powershell": false, "i_donated_to_sidebar_enhancements_developer": "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DD4SL2AHYJGBW" }

     

    더보기

    빌드 시스템 파이썬 베이스

    "cmd" : [ ~ ] 로 하면 PyQt5 같은 프로그램 실행 안 됨.

    python
    { "shell_cmd": "python -u \"$file\"", "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", "selector": "source.python", "env": {"PYTHONIOENCODING": "utf-8"}, "variants": [ { "name": "Syntax Check", "shell_cmd": "python -m py_compile \"${file}\"", } ] }

     

     


    3. 단축키 수정 (Preferences - Key Bindings)

    CTRL + D : 줄 복사

    CTRL + Q : 주석/주석 해제

    CTRL + K, CTRL+SHIFT + TAB : Tab을 4spaces 로 바꾸기

    CTRL + Break : 빌드 취소

    ALT + B : 빌드 결과 보기

    json
    [ { "keys": ["ctrl+j"], "command": "toggle_record_macro" }, { "keys": ["ctrl+shift+j"], "command": "run_macro" }, { "keys": ["ctrl+q"], "command": "toggle_comment", "args": { "block": false } }, { "keys": ["ctrl+shift+q"], "command": "toggle_comment", "args": { "block": true } }, { "keys": ["ctrl+d"], "command": "duplicate_line" }, { "keys": ["ctrl+k", "ctrl+shift+tab"], "command": "expand_tabs" }, { "keys" : ["alt+b"], "command" : "show_panel" , "args" : {"panel": "output.exec"}}, { "keys": ["ctrl+break"], "command": "cancel_build" }, ]

    4. 기타

    1. Python 결과 출력창 FAIL, *Error와 같은 키워드에 색깔을 입히려면

    대충 Batch file 문법 적용한 사진

    build system을 만들 때, custom syntax를 추가해서 원하는 글자에 색을 입힐 수 있다.

    json
    { "cmd": ["Anaconda3\\python.exe", "-u", "$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", "selector": "source.python", "env": {"PYTHONIOENCODING": "utf-8"}, "syntax": "Packages/User/PYTHON OUTPUT.sublime-syntax" }

     

    2. Custom Syntax를 만드는 법 :

    https://github.com/sublimehq/Packages 에서 원하는 언어의 syntax를 볼 수 있다.

    Tools - Developer - New Syntax를 눌러 새로운 syntax 파일을 만들 수 있다. SL3 Syntax DOC

    기본적 문법은

    php
    %YAML 1.2 --- # http://www.sublimetext.com/docs/3/syntax.html name: Python Output file_extensions: - py scope: custom.name contexts: main: - include: test test: - match: \b(?i:echo)\b # Regex scope: test.echo # echo에만 색깔을 따로 입히려면

    scope에 있는 이름을 따라, color scheme 을 수정해서 추가하면 되는데, 어렵다.

    ※ Syntax 파일을 만들고 AppData\Roaming\Sublime Text 3\Packages\User 경로에

    뭐뭐뭐뭐.sublime-syntax 형식으로 저장하면 된다. 그래도 Syntax에 안뜨면, CTRL + ` 콘솔을 이용해

    에러가 있는지 확인한다.

    728x90

    댓글