For those who want to write Python with vim

Target person

People who want / write Python using vim and who want to know about editing color schemes I will introduce the .vimrc that I use, the syntax script for Python, and finally the color scheme.

table of contents

[For first-time users](#For first-time users) -[Basic understanding](#Basic understanding) -[Command](#command) -[First setting](#First setting) -[Enable copy / paste via clipboard](# Enable copy / paste via clipboard) -
[Plugin Management `NeoBundle`](#Plugin Management neobundle) -[`NeoBundle` body related](#neobundle body related) -[Color scheme](#Color scheme) -[Flower characters](#Flower characters) -[Check color scheme](#Check color scheme) -[Enhanced status line display](#Enhanced status line display) -[Indent visualization](#Indent visualization) -[Highlight unnecessary space](#Highlight unnecessary space) --[Syntax error check](#Syntax error check) -[Multi-function selector](# Multi-function selector) -[Code completion](# code completion) -[Enable Color Scheme](#Enable Color Scheme) -[Character code setting](#Character code setting) --[Enable Status Line](#Enable Status Line) -[Command mode settings](# Command mode settings) --[Tab and indent settings](#Tab and indent settings) -[String Search](#String Search) -[Move cursor, etc.](#Move cursor, etc.) -[Correspondence of parentheses and tags](# Correspondence of parentheses and tags) -[Mouse enable](#Mouse enable) -[File management](# File management) -[Display related](# Display related) -[Macro and key settings](# Macro and key settings) -[`neocomplete` settings](#neocomplete settings) -[`Syntastic` settings](#syntastic settings) -[CtrlP settings](#ctrlp settings) -[For color scheme editing](# For color scheme editing) -[Edit Color Scheme](#Edit Color Scheme) -[First, find the original color scheme](#First, find the original color scheme) -[Which part do you like? ](# I don't like which part) -[Open Color Scheme](#Open Color Scheme) -[Search target syntax group](#Search target syntax group) -[Try to write](# Try to write) -[Confirm](# Confirm) -[Syntax file](#Syntax file) - [pyceberg](#pyceberg) -[Conclusion](#Conclusion)

vimrc vim is a high-performance editor, but unlike Visual Studio and jupyter notebook, for example, the UI Somehow the threshold is high because it is not fulfilling at all (without using a plug-in). I'm not very good at using it, so it feels like I'm practicing ... But ** I've been wondering or not recently thinking that vim's good point is that you can write crisply ** if you get used to the default key bindings, and ** you can customize it freely **. Various plugins are published on github. With that said, today I would like to introduce the .vimrc that I am using now.

I copy and paste the .vimrc introduced in here and customize it a little. ** I want to make .vimrc with all copy! In that case, please copy and paste after going to [here](# enable copy and paste via clipboard) and adjust. ** **

.vimrc

.vimrc


set encoding=utf-8
scriptencoding utf-8
"↑ The first line is the character code setting when reading
"↑ The second line is the setting when using multibyte in Vim Script
"Since vimrc is also included in Vim scritpt, this setting is required at the beginning when writing comments in Japanese

"----------------------------------------------------------
" NeoBundle
"----------------------------------------------------------
if has('vim_starting')
  "Specify the NeoBundle path in runtimepath only at the first startup
  set runtimepath+=~/.vim/bundle/neobundle.vim/

  "Git clone if NeoBundle is not installed
  if !isdirectory(expand("~/.vim/bundle/neobundle.vim/"))
    echo "install NeoBundle..."
    :call system("git clone git://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim")
  endif
endif

call neobundle#begin(expand('~/.vim/bundle/'))

"Describe the Vim plugin to install below
"Manage NeoBundle itself
NeoBundleFetch 'Shougo/neobundle.vim'
"Color scheme
"NeoBundle 'tomasr/molokai'
"NeoBundle 'flrnd/plastic.vim'
"NeoBundle 'sainnhe/edge'
NeoBundle 'cocopon/iceberg.vim'
"Flower character
"NeoBundle 'sainnhe/icursive-nerd-font'
"Examine the color scheme
NeoBundle 'guns/xterm-color-table.vim'
"Enhanced status line display
NeoBundle 'itchyny/lightline.vim'
"Indent visualization
NeoBundle 'Yggdroot/indentLine'
"Highlight full-width and half-width blank characters at the end in red
NeoBundle 'bronson/vim-trailing-whitespace'
"Syntax error checking
NeoBundle 'scrooloose/syntastic'
"Multi-function selector
NeoBundle 'ctrlpvim/ctrlp.vim'
"CtrlP extension plugin.Function search
NeoBundle 'tacahiroy/ctrlp-funky'
"CtrlP extension plugin.Command history search
NeoBundle 'suy/vim-ctrlp-commandline'
"Use ag to search for CtrlP
NeoBundle 'rking/ag.vim'
"Load the ESLint contained in the project
NeoBundle 'pmsorhaindo/syntastic-local-eslint.vim'
"python code completion
NeoBundle 'davidhalter/jedi-vim'
NeoBundle 'ervandew/supertab'
autocmd FileType python setlocal completeopt-=preview
let g:SuperTabContextDefaultCompletionType = "context"
let g:SuperTabDefaultCompletionType = "<c-n>"
"let g:jedi#rename_command = "<c-r>"
let g:jedi#force_py_version="3"

"Install the following Vim plugins only when you can use vim's lua feature
if has('lua')
  "Code auto-completion
  NeoBundle 'Shougo/neocomplete.vim'
  "Snippet completion
  NeoBundle "Shougo/neosnippet"
  "Snippet collection
  NeoBundle 'Shougo/neosnippet-snippets'
endif

call neobundle#end()

"Vim plugins by file type/Enable indentation
filetype plugin indent on

"Settings to ask if you want to install any Vim plugins that you haven't installed
NeoBundleCheck

"----------------------------------------------------------
"Color scheme
"----------------------------------------------------------
"Set molokai for the color scheme
"if neobundle#is_installed('molokai')
"  colorscheme molokai
"endif
"colorscheme murphy
"Set to plastic
"if neobundle#is_installed('plastic')
"  colorscheme plastic
"endif
"Set to neon
"if neobundle#is_installed('edge')
"  set termguicolors
"  set background=dark
"  let g:edge_style = 'neon'
"  let g:edge_disable_italic_comment = 1
"  let g:edge_enable_italic = 0
"  colorscheme edge
"endif
"Set to iceberg
if neobundle#is_installed('iceberg.vim')
  colorscheme iceberg
endif

set t_Co=256 "It is not necessary to already have a 256-color environment such as iTerm2
syntax enable "Color the syntax

"----------------------------------------------------------
"letter
"----------------------------------------------------------
set fileencoding=utf-8 "Character code at the time of saving
set fileencodings=ucs-boms,utf-8,euc-jp,cp932 "Automatic determination of character code at the time of reading.The left side has priority
set fileformats=unix,dos,mac "Automatic detection of line feed code.The left side has priority
set ambiwidth=double "Solved the problem that □ and ○ characters collapsed

"----------------------------------------------------------
"Status line
"----------------------------------------------------------
set laststatus=2 "Always show status line
set showmode "Show current mode
set showcmd "Show the command you typed below the status line
set ruler "Show cursor position to the right of the status line

"----------------------------------------------------------
"Command mode
"----------------------------------------------------------
set wildmenu "Command mode completion
set history=5000 "Number of command histories to save

"----------------------------------------------------------
"Tab indent
"----------------------------------------------------------
set expandtab "Replace tab input with multiple blank inputs
set tabstop=2 "The width occupied by tab characters on the screen
set softtabstop=2 "The width that the cursor moves with the tab key and backspace key for consecutive blanks
set autoindent "Continue indenting the previous line at line break
set smartindent "Check the syntax of the previous line at line breaks and increase or decrease the indentation of the next line
set shiftwidth=2 "Width that increases or decreases with smart indent

"----------------------------------------------------------
"String search
"----------------------------------------------------------
set incsearch "Incremental search.Search for each character entered
set ignorecase "Search patterns are not case sensitive
set smartcase "If the search pattern contains uppercase letters, it is case sensitive
set hlsearch "Highlight search results

"Press the ESC key twice to switch highlights
nnoremap <silent><Esc><Esc> :<C-u>set nohlsearch!<CR>

"----------------------------------------------------------
"cursor
"----------------------------------------------------------
set whichwrap=b,s,h,l,<,>,[,],~ "You can move the cursor left and right from the end of the line to the beginning of the next line.
set number "Show line number
set cursorline "Highlight cursor line

"If the line is wrapped, move the cursor by the displayed line instead of the line.
nnoremap j gj
nnoremap k gk
nnoremap <down> gj
nnoremap <up> gk

"Enable backspace key
set backspace=indent,eol,start

"----------------------------------------------------------
"Correspondence of parentheses and tags
"----------------------------------------------------------
set showmatch "Display the correspondence of parentheses for a moment
set matchtime=3
set matchpairs& matchpairs+=<:>
source $VIMRUNTIME/macros/matchit.vim "Vim's "%To extend

"----------------------------------------------------------
"Cursor movement and scrolling with mouse
"----------------------------------------------------------
if has('mouse')
  set mouse=a
  if has('mouse_sgr')
    set ttymouse=sgr
  elseif v:version > 703 || v:version is 703 && has('patch632')
    set ttymouse=sgr
  else
    set ttymouse=xterm2
  endif
endif

"----------------------------------------------------------
"Paste from clipboard
"----------------------------------------------------------
"Prevent automatic indentation when pasting from the clipboard in insert mode
if &term =~ "xterm"
  let &t_SI .= "\e[?2004h"
  let &t_EI .= "\e[?2004l"
  let &pastetoggle = "\e[201~"

  function XTermPasteBegin(ret)
    set paste
    return a:ret
  endfunction

  inoremap <special> <expr> <Esc>[200~ XTermPasteBegin("")
endif

"----------------------------------------------------------
"File management
"----------------------------------------------------------
"Do not create backup or swap files
set nowritebackup
set nobackup
set noswapfile

"----------------------------------------------------------
"Display relation
"----------------------------------------------------------
set list "Visualization of invisible characters
set wrap "Wrapping long text
set colorcolumn=100 "Put a line on the 100th character
"Disable screen bell
set t_vb=
set novisualbell
"Clean invisible characters in Unicode
set listchars=tab:»-,trail:-,extends:»,precedes:«,nbsp:%,eol:↲

"----------------------------------------------------------
"Macro and key settings
"----------------------------------------------------------
inoremap jj <Esc> "If you type jj quickly while in input mode, it is considered ESC.
"Bring the search word that jumped to the search word to the center of the screen
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#zz
vnoremap v $h "Select v twice to the end of the line
"Jump to the corresponding pair with TAB
nnoremap <Tab> %
vnoremap <Tab> %
" Shift +Resize window with arrow
"nnoremap <S-Left> <C-w><<CR>
"nnoremap <S-Right> <C-w>><CR>
"nnoremap <S-Up> <C-w>-<CR>
"nnoremap <S-Down> <C-w>+<CR>
"Press the arrow twice to move to the beginning or end of the line
inoremap <S-Left><S-Left> <Esc>_i
inoremap <S-Right><S-Right> <Esc>$i<Right>

"----------------------------------------------------------
"neocomplete / neosnippet settings
"----------------------------------------------------------
if neobundle#is_installed('neocomplete.vim')
  "Enable neocomplete when starting Vim
  let g:neocomplete#enable_at_startup = 1
  "smartcase enabled.Ignore case sensitivity until uppercase is entered
  let g:neocomplete#enable_smart_case = 1
  "Enable completion for words with 3 or more letters
  let g:neocomplete#min_keyword_length = 3
  "Complete up to the delimiter
  let g:neocomplete#enable_auto_delimiter = 1
  "Display the completion pop-up from the input of the first character
  let g:neocomplete#auto_completion_start_length = 1
  "Close the completion pop-up in backspace
  inoremap <expr><BS> neocomplete#smart_close_popup()."<C-h>"

  "Confirm complement candidates with enter key.The deployment of snippets is also confirmed with the enter key
  imap <expr><CR> neosnippet#expandable() ? "<Plug>(neosnippet_expand_or_jump)" : pumvisible() ? "<C-y>" : "<CR>"
  "Select completion candidates with the tab key.Jump in the snippet with the tab key
  imap <expr><TAB> pumvisible() ? "<C-n>" : neosnippet#jumpable() ? "<Plug>(neosnippet_expand_or_jump)" : "<TAB>"
endif

"----------------------------------------------------------
" Syntastic
"----------------------------------------------------------
""Syntax error line">>"Show
let g:syntastic_enable_signs = 1
"Prevent conflicts with other Vim plugins
let g:syntastic_always_populate_loc_list = 1
"Hide syntax error list
let g:syntastic_auto_loc_list = 0
"Perform syntax error checking when opening a file
let g:syntastic_check_on_open = 1
" 「:Check for syntax errors when ending with "wq"
let g:syntastic_check_on_wq = 1

"For Javascript.Use ESLint for syntax error checking
let g:syntastic_javascript_checkers=['eslint']
"For python.Use pep8 and pyflakes for syntax error checking
let g:syntastic_python_checkers=['pep8', 'pyflakes']
" Javascript,No syntax error checking except for python
let g:syntastic_mode_map = { 'mode': 'passive',
                           \ 'active_filetypes': ['javascript', 'python'],
                           \ 'passive_filetypes': [] }

"----------------------------------------------------------
" CtrlP
"----------------------------------------------------------
let g:ctrlp_match_window = 'order:ttb,min:20,max:20,results:100' "Match window settings."Display at the bottom,Fixed in size 20 lines,100 search results "
let g:ctrlp_show_hidden = 1 " .(Dot)Search for files starting with
let g:ctrlp_types = ['fil'] "Use only file search
let g:ctrlp_extensions = ['funky', 'commandline'] "Use "funky" and "command line" as extensions to CtrlP

"Enable CtrlPCommandLine
command! CtrlPCommandLine call ctrlp#init(ctrlp#commandline#id())

"CtrlP Funky refined search settings
let g:ctrlp_funky_matchtype = 'path'

if executable('ag')
  let g:ctrlp_use_caching=0 "Do not use CtrlP cache
  let g:ctrlp_user_command='ag %s -i --hidden -g ""' "Search settings for "ag"
endif

"----------------------------------------------------------
"For editing color schemes
"----------------------------------------------------------
"Command to know the highlight group:Implemented SyntaxInfo
function! s:get_syn_id(transparent)
  let synid = synID(line("."), col("."), 1)
  if a:transparent
    return synIDtrans(synid)
  else
    return synid
  endif
endfunction
function! s:get_syn_attr(synid)
  let name = synIDattr(a:synid, "name")
  let ctermfg = synIDattr(a:synid, "fg", "cterm")
  let ctermbg = synIDattr(a:synid, "bg", "cterm")
  let guifg = synIDattr(a:synid, "fg", "gui")
  let guibg = synIDattr(a:synid, "bg", "gui")
  return {
        \ "name": name,
        \ "ctermfg": ctermfg,
        \ "ctermbg": ctermbg,
        \ "guifg": guifg,
        \ "guibg": guibg}
endfunction
function! s:get_syn_info()
  let baseSyn = s:get_syn_attr(s:get_syn_id(0))
  echo "name: " . baseSyn.name .
        \ " ctermfg: " . baseSyn.ctermfg .
        \ " ctermbg: " . baseSyn.ctermbg .
        \ " guifg: " . baseSyn.guifg .
        \ " guibg: " . baseSyn.guibg
  let linkedSyn = s:get_syn_attr(s:get_syn_id(1))
  echo "link to"
  echo "name: " . linkedSyn.name .
        \ " ctermfg: " . linkedSyn.ctermfg .
        \ " ctermbg: " . linkedSyn.ctermbg .
        \ " guifg: " . linkedSyn.guifg .
        \ " guibg: " . linkedSyn.guibg
endfunction
command! SyntaxInfo call s:get_syn_info()

Beginner's Guide

If you are not new to this, please skip to [here](#first setting).

Let's create .vimrc for the time being.

$ cd
$ vi .vimrc

** You might think, "Well, is vim's startup command vi instead of vim?" **, but at least for now, both can be considered the same command.

For the time being, I think that you should have opened .vimrc in vim. I think vim is quite difficult if you don't get used to it, so for the time being, I will only introduce the basic understanding and commands that are in the beginning.

Basic understanding

vim has several modes.

--Normal mode (command input) --Insert mode (text editing) --Visual mode (range selection)

Normal mode is a mode for entering commands with vim. It will be in this mode when you open the file with vim. In other modes, press ʻEsc to enter this mode. Insert mode is a mode for rewriting sentences and chords themselves. If you enter ʻi or ʻoin normal mode, you will be in this mode and you will be able to edit the text. Visual mode is a mode for selecting a range. Enterv` etc. in normal mode to enter this mode. You may not use it much at first.

command

For the time being, I think it's okay if you keep in mind only the following commands in this article. If you don't have enough, please google at any time.

Commands in normal mode

1 2
i Change to insert mode
:w Save
:q Quit vim
:wq Save and exit vim
dd Delete one line
yy 1 line copy
p pasting(Only from within vim into vim)

Commands in other modes

1 2
Esc Return to normal mode

Initial setting

Write the following script at the beginning of .vimrc. This is a script to enable Japanese.

.vimrc


set encoding=utf-8
scriptencoding utf-8

If you are writing .vimrc for the first time, write it so far and press ʻEsc to enter normal mode, save it with: wq` and close it. If you open it again, Japanese will be valid.

Enable copy and paste via clipboard

If you want to do everything with copy and paste, do it manually so far. Copying and pasting normally should be annoying. If you do, enter : q! In normal mode and close it without saving if it is troublesome to fix.

Copy and paste enable

.vimrc


"----------------------------------------------------------
"Paste from clipboard
"----------------------------------------------------------
"Prevent automatic indentation when pasting from the clipboard in insert mode
if &term =~ "xterm"
  let &t_SI .= "\e[?2004h"
  let &t_EI .= "\e[?2004l"
  let &pastetoggle = "\e[201~"

  function XTermPasteBegin(ret)
    set paste
    return a:ret
  endfunction

  inoremap <special> <expr> <Esc>[200~ XTermPasteBegin("")
endif

You can now copy and paste from the clipboard. In other words, you will be able to copy texts from internet sites and paste them into files opened with vim. Convenient!

Plugin management NeoBundle

It seems that the end of development of NeoBundle has been declared long ago. The developer seems to recommend dein. If you wish, please rewrite it referring to here. I may move if I feel like it, so I may write an article again at that time ...

NeoBundle

.vimrc


"----------------------------------------------------------
" NeoBundle
"----------------------------------------------------------
if has('vim_starting')
  "Specify the NeoBundle path in runtimepath only at the first startup
  set runtimepath+=~/.vim/bundle/neobundle.vim/

  "Git clone if NeoBundle is not installed
  if !isdirectory(expand("~/.vim/bundle/neobundle.vim/"))
    echo "install NeoBundle..."
    :call system("git clone git://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim")
  endif
endif

call neobundle#begin(expand('~/.vim/bundle/'))

"Describe the Vim plugin to install below
"Manage NeoBundle itself
NeoBundleFetch 'Shougo/neobundle.vim'
"Color scheme
"NeoBundle 'tomasr/molokai'
"NeoBundle 'flrnd/plastic.vim'
"NeoBundle 'sainnhe/edge'
NeoBundle 'cocopon/iceberg.vim'
"Flower character
"NeoBundle 'sainnhe/icursive-nerd-font'
"Examine the color scheme
NeoBundle 'guns/xterm-color-table.vim'
"Enhanced status line display
NeoBundle 'itchyny/lightline.vim'
"Indent visualization
NeoBundle 'Yggdroot/indentLine'
"Highlight full-width and half-width blank characters at the end in red
NeoBundle 'bronson/vim-trailing-whitespace'
"Syntax error checking
NeoBundle 'scrooloose/syntastic'
"Multi-function selector
NeoBundle 'ctrlpvim/ctrlp.vim'
"Load the ESLint contained in the project
NeoBundle 'pmsorhaindo/syntastic-local-eslint.vim'
"CtrlP extension plugin.Function search
NeoBundle 'tacahiroy/ctrlp-funky'
"CtrlP extension plugin.Command history search
NeoBundle 'suy/vim-ctrlp-commandline'
"Use ag to search for CtrlP
NeoBundle 'rking/ag.vim'
"python code completion
NeoBundle 'davidhalter/jedi-vim'
NeoBundle 'ervandew/supertab'
autocmd FileType python setlocal completeopt-=preview
let g:SuperTabContextDefaultCompletionType = "context"
let g:SuperTabDefaultCompletionType = "<c-n>"
"let g:jedi#rename_command = "<c-r>"
let g:jedi#force_py_version="3"

"Install the following Vim plugins only when you can use vim's lua feature
if has('lua')
  "Code auto-completion
  NeoBundle 'Shougo/neocomplete.vim'
  "Snippet completion
  NeoBundle "Shougo/neosnippet"
  "Snippet collection
  NeoBundle 'Shougo/neosnippet-snippets'
endif

call neobundle#end()

"Vim plugins by file type/Enable indentation
filetype plugin indent on

"Settings to ask if you want to install any Vim plugins that you haven't installed
NeoBundleCheck

The explanation of each plug-in is roughly explained here [https://qiita.com/ahiruman5/items/4f3c845500c172a02935) because it has an ultra-careful explanation.

NeoBundle body relations

Extract the parts related to the NeoBundle body. Each operation is as described in the comments.

Main body relations

.vimrc


if has('vim_starting')
  "Specify the NeoBundle path in runtimepath only at the first startup
  set runtimepath+=~/.vim/bundle/neobundle.vim/

  "Git clone if NeoBundle is not installed
  if !isdirectory(expand("~/.vim/bundle/neobundle.vim/"))
    echo "install NeoBundle..."
    :call system("git clone git://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim")
  endif
endif

call neobundle#begin(expand('~/.vim/bundle/'))

"Describe the Vim plugin to install below
"Manage NeoBundle itself
NeoBundleFetch 'Shougo/neobundle.vim'

...

call neobundle#end()

"Vim plugins by file type/Enable indentation
filetype plugin indent on

"Settings to ask if you want to install any Vim plugins that you haven't installed
NeoBundleCheck

Color scheme

The color scheme I personally tried but the wreckage is commented out ... molokai is famous. However, I personally like iceberg. Also, I will introduce pyceberg, which is slightly customized to make it easier for me to see, later ~~ (Daima) ~~.

.vimrc


"Color scheme
"NeoBundle 'tomasr/molokai'
"NeoBundle 'flrnd/plastic.vim'
"NeoBundle 'sainnhe/edge'
NeoBundle 'cocopon/iceberg.vim'

I'll show you how to enable it later [later) (#Enable color scheme).

Flower character

I couldn't use the flower letters for some reason. ~~ I wanted to use it because it was cool. ~~ I did a lot of research, but it just highlighted the background of the string ... Please let me know if anyone has any information

.vimrc


"Flower character
"NeoBundle 'sainnhe/icursive-nerd-font'

Examine the color scheme

For more information here You will be able to use the command : XtermColorTable, which can display a list of available colors. It is very useful for Color scheme color adjustment.

.vimrc


"Examine the color scheme
NeoBundle 'guns/xterm-color-table.vim'

Enhanced status line display

For more information [here](https://qiita.com/ahiruman5/items/4f3c845500c172a02935#-lightlinevim%E3%82%B9%E3%83%86%E3%83%BC%E3%82%BF%E3%82 % B9% E3% 83% A9% E3% 82% A4% E3% 83% B3% E3% 81% AE% E8% A1% A8% E7% A4% BA% E5% 86% 85% E5% AE% B9 % E5% BC% B7% E5% 8C% 96) Well, in short, I'm grateful that more information is displayed.

.vimrc


"Enhanced status line display
NeoBundle 'itchyny/lightline.vim'

You need to enable the status line, so please refer to [here](#Enable status line).

Indent visualization

As it is. You will be able to see the indent. Indentation is important in any language, isn't it?

.vimrc


"Indent visualization
NeoBundle 'Yggdroot/indentLine'

Highlight unnecessary space

Makes whitespace characters in the code visible with a red highlight. I can't compile because of space! I'm very grateful for that. What's more, you can even delete all the unwanted spaces highlighted with the command : FixWhitespace! Well, don't rely too much on this, and always code carefully.

.vimrc


"Highlight full-width and half-width blank characters at the end in red
NeoBundle 'bronson/vim-trailing-whitespace'

Syntax error checking

The operation is [here](https://qiita.com/ahiruman5/items/4f3c845500c172a02935#-syntastic%E6%A7%8B%E6%96%87%E3%82%A8%E3%83%A9%E3%83 You can see it by looking at% BC% E3% 83% 81% E3% 82% A7% E3% 83% 83% E3% 82% AF). It feels like it will tell you if there is a grammatical mistake.

.vimrc


"Syntax error checking
NeoBundle 'scrooloose/syntastic'
"Load the ESLint contained in the project
NeoBundle 'pmsorhaindo/syntastic-local-eslint.vim'

It doesn't check Python syntax by itself, so see [here](#syntastic settings).

Multi-function selector

It's a plugin that searches files and buffers. I don't think I'm using it ... Does that mean that there is still not enough training ...

.vimrc


"Multi-function selector
NeoBundle 'ctrlpvim/ctrlp.vim'
"CtrlP extension plugin.Function search
NeoBundle 'tacahiroy/ctrlp-funky'
"CtrlP extension plugin.Command history search
NeoBundle 'suy/vim-ctrlp-commandline'
"Use ag to search for CtrlP
NeoBundle 'rking/ag.vim'

Click here for CtrlP settings related to this (#ctrlp settings)

Code completion

It's a coding ally, code completion. Speaking of which, I thought it would be okay to use jedi-vim even if it wasn't neocomplete, but I'm putting it because it's okay to have it separately. I may sort it out soon.

Code completion

.vimrc


"python code completion
NeoBundle 'davidhalter/jedi-vim'
NeoBundle 'ervandew/supertab'
autocmd FileType python setlocal completeopt-=preview
let g:SuperTabContextDefaultCompletionType = "context"
let g:SuperTabDefaultCompletionType = "<c-n>"
"let g:jedi#rename_command = "<c-r>"
let g:jedi#force_py_version="3"

"Install the following Vim plugins only when you can use vim's lua feature
if has('lua')
  "Code auto-completion
  NeoBundle 'Shougo/neocomplete.vim'
  "Snippet completion
  NeoBundle "Shougo/neosnippet"
  "Snippet collection
  NeoBundle 'Shougo/neosnippet-snippets'
endif

The setting of neocomplete is [here](setting of #neocomplete)

Enable color scheme

Enable color scheme. As in the example, the commented out part is the wreckage. Please use the one you like.

Color scheme setting collection

.vimrc


"----------------------------------------------------------
"Color scheme
"----------------------------------------------------------
"Set molokai for the color scheme
"if neobundle#is_installed('molokai')
"  colorscheme molokai
"endif
"colorscheme murphy
"Set to plastic
"if neobundle#is_installed('plastic')
"  colorscheme plastic
"endif
"Set to neon
"if neobundle#is_installed('edge')
"  set termguicolors
"  set background=dark
"  let g:edge_style = 'neon'
"  let g:edge_disable_italic_comment = 1
"  let g:edge_enable_italic = 0
"  colorscheme edge
"endif
"Set to iceberg
if neobundle#is_installed('iceberg.vim')
  colorscheme iceberg
endif

set t_Co=256 "It is not necessary to already have a 256-color environment such as iTerm2
syntax enable "Color the syntax

Be sure to check out pyceberg! !! ~~ (2nd Daima) ~~ For an introduction such as introduction here

Character code setting

A collection of settings related to character codes.

.vimrc


"----------------------------------------------------------
"letter
"----------------------------------------------------------
set fileencoding=utf-8 "Character code at the time of saving
set fileencodings=ucs-boms,utf-8,euc-jp,cp932 "Automatic determination of character code at the time of reading.The left side has priority
set fileformats=unix,dos,mac "Automatic detection of line feed code.The left side has priority
set ambiwidth=double "Solved the problem that □ and ○ characters collapsed

Status line activation

Enable the status line (at the bottom of the vim editor).

"----------------------------------------------------------
"Status line
"----------------------------------------------------------
set laststatus=2 "Always show status line
set showmode "Show current mode
set showcmd "Show the command you typed below the status line
set ruler "Show cursor position to the right of the status line

Command mode settings

You can type various commands in normal mode, but this is a function that assists you. Even if you have less command history, you probably won't have any problems.

.vimrc


"----------------------------------------------------------
"Command mode
"----------------------------------------------------------
set wildmenu "Command mode completion
set history=5000 "Number of command histories to save

Tab and indent settings

It's super important for writing tabs, indents, and easy-to-read code. I personally feel that it is difficult to see if the indent width is too large, so I set it to 2, but for some reason it becomes 4 without permission when writing Python code. Well, Python has a tacit understanding and the indent width is like 4, so it's good. It will be [Indent or Visualization](#Indent Visualization).

.vimrc


"----------------------------------------------------------
"Tab indent
"----------------------------------------------------------
set expandtab "Replace tab input with multiple blank inputs
set tabstop=2 "The width occupied by tab characters on the screen
set softtabstop=2 "The width that the cursor moves with the tab key and backspace key for consecutive blanks
set autoindent "Continue indenting the previous line at line break
set smartindent "Check the syntax of the previous line at line breaks and increase or decrease the indentation of the next line
set shiftwidth=2 "Width that increases or decreases with smart indent

String search

This is also an important setting. String search becomes convenient.

.vimrc


"----------------------------------------------------------
"String search
"----------------------------------------------------------
set incsearch "Incremental search.Search for each character entered
set ignorecase "Search patterns are not case sensitive
set smartcase "If the search pattern contains uppercase letters, it is case sensitive
set hlsearch "Highlight search results

"Press the ESC key twice to switch highlights
nnoremap <silent><Esc><Esc> :<C-u>set nohlsearch!<CR>

By the way, the character string search is / (the character string you want to search) Character string replacement is basically :% s / (character string to be replaced) / (character string after replacement).

Cursor movement etc.

In vim, in normal mode, you can use h, j, k, l to move tolower left, upper right, respectively, but when moving with such a command, one line wraps and is displayed because you wrote a long code. If it is, for example, if you move with j, the cursor will move to the next line instead of one line down as it looks. Here, it is set to solve it and highlight the cursor line.

Cursor related

/.vimrc


"----------------------------------------------------------
"cursor
"----------------------------------------------------------
set whichwrap=b,s,h,l,<,>,[,],~ "You can move the cursor left and right from the end of the line to the beginning of the next line.
set number "Show line number
set cursorline "Highlight cursor line

"If the line is wrapped, move the cursor by the displayed line instead of the line.
nnoremap j gj
nnoremap k gk
nnoremap <down> gj
nnoremap <up> gk

"Enable backspace key
set backspace=indent,eol,start

Correspondence of parentheses and tags

The corresponding parentheses flash for a moment while coding. This is useful when writing a lot of parentheses.

.vimrc


"----------------------------------------------------------
"Correspondence of parentheses and tags
"----------------------------------------------------------
set showmatch "Display the correspondence of parentheses for a moment
set matchtime=3
set matchpairs& matchpairs+=<:>
source $VIMRUNTIME/macros/matchit.vim "Vim's "%To extend

Mouse activation

I can't use the mouse with the default vim. You can't use the trackpad either. So let's set it.

Mouse enablement

.vimrc


"----------------------------------------------------------
"Cursor movement and scrolling with mouse
"----------------------------------------------------------
if has('mouse')
  set mouse=a
  if has('mouse_sgr')
    set ttymouse=sgr
  elseif v:version > 703 || v:version is 703 && has('patch632')
    set ttymouse=sgr
  else
    set ttymouse=xterm2
  endif
endif

File management

When I edit a file with vim, it automatically creates a backup file and a swap file, but I don't need it separately, so turn it off. (If you need a file backup, I think you should use git in the first place)

.vimrc


"----------------------------------------------------------
"File management
"----------------------------------------------------------
"Do not create backup or swap files
set nowritebackup
set nobackup
set noswapfile

Display relation

Visualize whitespace, line breaks, tabs, etc. I will wrap it when the sentence becomes longer.

Display-related settings

.vimrc


"----------------------------------------------------------
"Display relation
"----------------------------------------------------------
set list "Visualization of invisible characters
set wrap "Wrapping long text
set colorcolumn=100 "Put a line on the 100th character
"Disable screen bell
set t_vb=
set novisualbell
"Clean invisible characters in Unicode
set listchars=tab:»-,trail:-,extends:»,precedes:«,nbsp:%,eol:↲

Macros and key settings

Here, the default key bindings are overridden or newly set for intuitive use. Please add or delete as you like.

--nnoremap is the key setting in normal mode --ʻInoremap is the key setting in insert mode --vnoremap is the key setting in visual mode --is theShift key --is theCtrl` key

Macro and key settings

.vimrc


"----------------------------------------------------------
"Macro and key settings
"----------------------------------------------------------
inoremap jj <Esc> "If you type jj quickly while in input mode, it is considered ESC.
"Bring the search word that jumped to the search word to the center of the screen
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#zz
vnoremap v $h "Select v twice to the end of the line
"Jump to the corresponding pair with TAB
nnoremap <Tab> %
vnoremap <Tab> %
" Shift +Resize window with arrow
"nnoremap <S-Left> <C-w><<CR>
"nnoremap <S-Right> <C-w>><CR>
"nnoremap <S-Up> <C-w>-<CR>
"nnoremap <S-Down> <C-w>+<CR>
"Press the arrow twice to move to the beginning or end of the line
inoremap <S-Left><S-Left> <Esc>_i
inoremap <S-Right><S-Right> <Esc>$i<Right>

neocomplete settings

The setting of neocomplete and the setting of neosnippet. It seems that there are various other options, but I think the following is generally sufficient. For more information

--neocomplete is here --neosnippet is here

Please refer to the.

Code completion settings

.vimrc


"----------------------------------------------------------
"neocomplete / neosnippet settings
"----------------------------------------------------------
if neobundle#is_installed('neocomplete.vim')
  "Enable neocomplete when starting Vim
  let g:neocomplete#enable_at_startup = 1
  "smartcase enabled.Ignore case sensitivity until uppercase is entered
  let g:neocomplete#enable_smart_case = 1
  "Enable completion for words with 3 or more letters
  let g:neocomplete#min_keyword_length = 3
  "Complete up to the delimiter
  let g:neocomplete#enable_auto_delimiter = 1
  "Display the completion pop-up from the input of the first character
  let g:neocomplete#auto_completion_start_length = 1
  "Close the completion pop-up in backspace
  inoremap <expr><BS> neocomplete#smart_close_popup()."<C-h>"

  "Confirm complement candidates with enter key.The deployment of snippets is also confirmed with the enter key
  imap <expr><CR> neosnippet#expandable() ? "<Plug>(neosnippet_expand_or_jump)" : pumvisible() ? "<C-y>" : "<CR>"
  "Select completion candidates with the tab key.Jump in the snippet with the tab key
  imap <expr><TAB> pumvisible() ? "<C-n>" : neosnippet#jumpable() ? "<Plug>(neosnippet_expand_or_jump)" : "<TAB>"
endif

Syntastic settings

It's a collection of syntax check function settings. However, why doesn't it seem to work in my environment ...? Something is wrong ...

`Syntastic` settings

.vimrc


"----------------------------------------------------------
" Syntastic
"----------------------------------------------------------
""Syntax error line">>"Show
let g:syntastic_enable_signs = 1
"Prevent conflicts with other Vim plugins
let g:syntastic_always_populate_loc_list = 1
"Hide syntax error list
let g:syntastic_auto_loc_list = 0
"Perform syntax error checking when opening a file
let g:syntastic_check_on_open = 1
" 「:Check for syntax errors when ending with "wq"
let g:syntastic_check_on_wq = 1

"For Javascript.Use ESLint for syntax error checking
let g:syntastic_javascript_checkers=['eslint']
"For python.Use pep8 and pyflakes for syntax error checking
let g:syntastic_python_checkers=['pep8', 'pyflakes']
" Javascript,No syntax error checking except for python
let g:syntastic_mode_map = { 'mode': 'passive',
                           \ 'active_filetypes': ['javascript', 'python'],
                           \ 'passive_filetypes': [] }

By the way, pep8 and pyflakes are

$ pip install pep8 pyflakes

You can install it with. For more information here

CtrlP settings

[Multi-function selector](# Multi-function selector) plug-in settings. I am setting file detection.

CtrlP settings

.vimrc


"----------------------------------------------------------
" CtrlP
"----------------------------------------------------------
let g:ctrlp_match_window = 'order:ttb,min:20,max:20,results:100' "Match window settings."Display at the bottom,Fixed in size 20 lines,100 search results "
let g:ctrlp_show_hidden = 1 " .(Dot)Search for files starting with
let g:ctrlp_types = ['fil'] "Use only file search
let g:ctrlp_extensions = ['funky', 'commandline'] "Use "funky" and "command line" as extensions to CtrlP

"Enable CtrlPCommandLine
command! CtrlPCommandLine call ctrlp#init(ctrlp#commandline#id())

"CtrlP Funky refined search settings
let g:ctrlp_funky_matchtype = 'path'

if executable('ag')
  let g:ctrlp_use_caching=0 "Do not use CtrlP cache
  let g:ctrlp_user_command='ag %s -i --hidden -g ""' "Search settings for "ag"
endif

For editing color schemes

This is a convenient command that tells you the syntax group of the code you are currently hovering over when editing a color scheme.

`: Enable the SyntaxInfo` command

.vimrc


"----------------------------------------------------------
"For editing color schemes
"----------------------------------------------------------
"Command to know the highlight group:Implemented SyntaxInfo
function! s:get_syn_id(transparent)
  let synid = synID(line("."), col("."), 1)
  if a:transparent
    return synIDtrans(synid)
  else
    return synid
  endif
endfunction
function! s:get_syn_attr(synid)
  let name = synIDattr(a:synid, "name")
  let ctermfg = synIDattr(a:synid, "fg", "cterm")
  let ctermbg = synIDattr(a:synid, "bg", "cterm")
  let guifg = synIDattr(a:synid, "fg", "gui")
  let guibg = synIDattr(a:synid, "bg", "gui")
  return {
        \ "name": name,
        \ "ctermfg": ctermfg,
        \ "ctermbg": ctermbg,
        \ "guifg": guifg,
        \ "guibg": guibg}
endfunction
function! s:get_syn_info()
  let baseSyn = s:get_syn_attr(s:get_syn_id(0))
  echo "name: " . baseSyn.name .
        \ " ctermfg: " . baseSyn.ctermfg .
        \ " ctermbg: " . baseSyn.ctermbg .
        \ " guifg: " . baseSyn.guifg .
        \ " guibg: " . baseSyn.guibg
  let linkedSyn = s:get_syn_attr(s:get_syn_id(1))
  echo "link to"
  echo "name: " . linkedSyn.name .
        \ " ctermfg: " . linkedSyn.ctermfg .
        \ " ctermbg: " . linkedSyn.ctermbg .
        \ " guifg: " . linkedSyn.guifg .
        \ " guibg: " . linkedSyn.guibg
endfunction
command! SyntaxInfo call s:get_syn_info()

SyntaxInfo.gif

Editing color schemes

I referred to here. Color schemes are surprisingly important when coding with vim. If you use only bright colors, your eyes will get tired, and if they are all the same color, you will not notice spelling mistakes, and coding efficiency will deteriorate anyway. You can see "This is the color scheme!" On various sites, or look for something good for you on the existing Site where you can search for color schemes. Isn't it subtly unconvincing even if you come? So, it's very easy, but I will explain how to edit the color scheme.

First, find the original color scheme

Creating your own color scheme from scratch can be daunting, so don't do it. You can edit your favorite color scheme little by little to get it right. I like iceberg, so I edited it a little based on this.

Which part do you like?

Once you've decided on the underlying color scheme, find out which parts of the color you don't like. You can find the highlight group in : SyntaxInfo in [Introduced earlier](#for editing the color scheme), so edit it based on it. In the following, we will change the color of the PythonString group as an example. PythonString.gif

** Keep this Python code open! ** **

Open color scheme

If the color scheme is managed by NeoBundle

~/.vim/bundle/

I think it is inside. This time I will edit ʻiceberg`

$ vi ~/.vim/bundle/iceberg.vim/colors/iceberg.vim

Open the color scheme with.

Search for the target syntax group

Let's look at the definition as a vim string search / pythonstring. search_PythonString.gif No, yes. That means you have to write it yourself. You can add it anywhere, but make it easy to understand. This time, I will put it at the very end of the part that directly defines the color of the color scheme. define_last.png

I will write

You can write it by imitating it. What color do you have? For that, let's refer to the : XtermColorTable introduced in [here](#Check the color scheme). This time we will use ctermfg = 40, guifg = # 00df00. You can see the hexadecimal number of guifg by selecting the range in visual mode ~ colortable.png write_pythonstring.png If you can write it, save it as ** : w for the time being. ** ** ** Don't close yet! ** **

Confirm

Now let's move on to the Python code screen. Type : syntax on and the new color should be reflected. reflect.gif It's too flashy ~ Let's stop it after all This color may be different from the color I thought, so go back to [Write](# Write) and edit it again Check and repeat ~.

This is the end of the explanation of how to edit the color scheme!

Syntax file

Well, I edited the color scheme and it's perfect! For those of you who think, I've forgotten another important factor! It is the existence of a ** syntax file **. A syntax file is a file that summarizes the grammar as it is. If you write Python in vim, you should include this. There is a Python syntax file in here, but this (for some reason) attributes such as class methods Sometimes I can't change the color of (foo in hoge.foo). So I modified a little here python.vim according to README.md

~/.vim/syntax/

Let's put it in. Then you should be able to change the color of the attributes too!

pyceberg Lastly, I would like to promote pyceberg, which has been dimmed through this article. The basic is iceberg, and I changed the color to my liking. Please use it if you like.

The installation method is described in README.md. The easiest is to .vimrc

.vimrc


NeoBundle ‘kuroitu/pyceberg’
colorscheme pyceberg

Is it the way to do it?

It looks like this ↓ (The image is from the numpy code) screenshot1.png screenshot2.png

in conclusion

It was a very long article ... Well, I hope it will be helpful for you.

reference

-[Detailed explanation] A must-see for Vimmer who wants to be popular. Vimrc explanation for comfortable coding -Original python.vim

Recommended Posts