gvim,tmux,zshの設定。おまけにcomptonの設定。 Ubuntu編

Ubuntuで設定しました。以前の記事はmacOS Sierraです。余談ですけど、High Sierraにいつあげようか決めかねてます。

comptonの設定もしておかないと透過できなかったので設定しました。Compizだと簡単に出来るらしいです。GVimvim-gtk3を使ってます。vim-gnomeでも通用すると思います。

.vimrc

syntax on

set nobackup
set encoding=utf-8
set fileencoding=utf-8
set number
set title
set showcmd
set ruler
set showmatch
set matchtime=3
set laststatus=2
set expandtab
set shiftwidth=2
set tabstop=2
set softtabstop=0
set list
set listchars=tab:>.,trail:_,eol:,extends:>,precedes:<,nbsp:%
set showtabline=2
set clipboard=unnamedplus
set backspace=indent,eol,start

nnoremap u g-
nnoremap <C-r> g+

function! ZenkakuSpace()
    highlight ZenkakuSpace cterm=reverse ctermfg=Blue gui=reverse guifg=Blue
endfunction

if has('syntax')
    augroup ZenkakuSpace
        autocmd!
        autocmd ColorScheme       * call ZenkakuSpace()
        autocmd VimEnter,WinEnter * match ZenkakuSpace / /
    augroup END
    call ZenkakuSpace()
endif

function! s:clang_format()
  let now_line = line(".")
  exec ":%! clang-format"
  exec ":" . now_line
endfunction

if executable('clang-format')
  augroup cpp_clang_format
    autocmd!
    autocmd BufWrite,FileWritePre,FileAppendPre *.[ch]pp call s:clang_format()
    autocmd BufWrite,FileWritePre,FileAppendPre *.[ch] call s:clang_format()
    autocmd BufWrite,FileWritePre,FileAppendPre *.js call s:clang_format()
    autocmd BufWrite,FileWritePre,FileAppendPre *.java call s:clang_format()
  augroup END
endif

"dein Scripts-----------------------------
if &compatible
  set nocompatible               " Be iMproved
endif

" Required:
set runtimepath+=/home/hirotoshi/.vim/bundles/repos/github.com/Shougo/dein.vim

" Required:
if dein#load_state('/home/hirotoshi/.vim/bundles')
  call dein#begin('/home/hirotoshi/.vim/bundles')

  " Let dein manage dein
  " Required:
  call dein#add('/home/hirotoshi/.vim/bundles/repos/github.com/Shougo/dein.vim')

  " Add or remove your plugins here:
  call dein#add('Shougo/neosnippet.vim')
  call dein#add('Shougo/neosnippet-snippets')
  call dein#add('tomasr/molokai')
  call dein#add('w0ng/vim-hybrid')
  call dein#add('altercation/vim-colors-solarized')
  call dein#add('scrooloose/nerdtree')
  call dein#add('Shougo/unite.vim')
  call dein#add('Shougo/neomru.vim')
  call dein#add('Shougo/neocomplete.vim')
  call dein#add('vim-airline/vim-airline')
  call dein#add('vim-airline/vim-airline-themes')
  call dein#add('Shougo/vimproc.vim', {'build' : 'make'})
  " You can specify revision/branch/tag.
  call dein#add('Shougo/vimshell', { 'rev': '3787e5' })

  " Required:
  call dein#end()
  call dein#save_state()
endif

" Required:
filetype plugin indent on
syntax enable

" If you want to install not installed plugins on startup.
"if dein#check_install()
"  call dein#install()
"endif

"End dein Scripts-------------------------

"Note: This option must be set in .vimrc(_vimrc).  NOT IN .gvimrc(_gvimrc)!
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplete#sources#syntax#min_keyword_length = 3

" Define dictionary.
let g:neocomplete#sources#dictionary#dictionaries = {
    \ 'default' : '',
    \ 'vimshell' : $HOME.'/.vimshell_hist',
    \ 'scheme' : $HOME.'/.gosh_completions'
        \ }

" Define keyword.
if !exists('g:neocomplete#keyword_patterns')
    let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'

" Plugin key-mappings.
inoremap <expr><C-g>     neocomplete#undo_completion()
inoremap <expr><C-l>     neocomplete#complete_common_string()

" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
  return (pumvisible() ? "\<C-y>" : "" ) . "\<CR>"
  " For no inserting <CR> key.
  "return pumvisible() ? "\<C-y>" : "\<CR>"
endfunction
" <TAB>: completion.
inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? "\<C-y>" : "\<Space>"

" AutoComplPop like behavior.
"let g:neocomplete#enable_auto_select = 1

" Shell like behavior(not recommended).
"set completeopt+=longest
"let g:neocomplete#enable_auto_select = 1
"let g:neocomplete#disable_auto_complete = 1
"inoremap <expr><TAB>  pumvisible() ? "\<Down>" : "\<C-x>\<C-u>"

" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags

" Enable heavy omni completion.
if !exists('g:neocomplete#sources#omni#input_patterns')
  let g:neocomplete#sources#omni#input_patterns = {}
endif
"let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
"let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
"let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'

" For perlomni.vim setting.
" https://github.com/c9s/perlomni.vim
let g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::'

set background=dark
colorscheme hybrid
let g:airline_theme='simple'

.gvimrc

syntax enable
set background=dark
colorscheme hybrid

set guifont=SF\ Mono\ for\ Powerline\ 10
set guifontwide=Noto\ Sans\ Mono\ CJK\ JP\ Bold\ 10

.tmux.conf

set -g prefix C-a
unbind C-b

set-option -g mouse on
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
set-option -g default-terminal screen-256color

set-window-option -g mode-keys vi
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'r' rectangle-toggle
bind-key -t vi-copy 'y' copy-pipe "xsel -bi"
bind-key -t vi-copy 'Enter' copy-pipe "xsel -bi"
bind-key 'p' run "tmux set-buffer -- \"$(xsel -bo)\"; tmux paste-buffer"

bind \ split-window -h
bind - split-window -v

run-shell "powerline-daemon -q"
source "/home/hirotoshi/.local/lib/python2.7/site-packages/powerline/bindings/tmux/powerline.conf"

.zshrc

sleep 0.3 && transset -a 0.8 > /dev/null
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH=$PATH:~/.local/bin
export PATH=$PATH:~/bin

# Path to your oh-my-zsh installation.
export ZSH=/home/hirotoshi/.oh-my-zsh
export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=lcd'

# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
# ZSH_THEME="rkj"

ZSH_THEME="powerline"
POWERLINE_HIDE_HOST_NAME="true"
POWERLINE_HIDE_GIT_PROMPT_STATUS="true"
POWERLINE_SHOW_GIT_ON_RIGHT="true"
POWERLINE_PATH="short"

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)

source $ZSH/oh-my-zsh.sh

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

function is_exists() { type "$1" >/dev/null 2>&1; return $?; }
function is_osx() { [[ $OSTYPE == darwin* ]]; }
function is_screen_running() { [ ! -z "$STY" ]; }
function is_tmux_runnning() { [ ! -z "$TMUX" ]; }
function is_screen_or_tmux_running() { is_screen_running || is_tmux_runnning; }
function shell_has_started_interactively() { [ ! -z "$PS1" ]; }
function is_ssh_running() { [ ! -z "$SSH_CONECTION" ]; }

function tmux_automatically_attach_session()
{
    if is_screen_or_tmux_running; then
        ! is_exists 'tmux' && return 1

        if is_tmux_runnning; then
            # echo "${fg_bold[red]} _____ __  __ _   ___  __ ${reset_color}"
            # echo "${fg_bold[red]}|_   _|  \/  | | | \ \/ / ${reset_color}"
            # echo "${fg_bold[red]}  | | | |\/| | | | |\  /  ${reset_color}"
            # echo "${fg_bold[red]}  | | | |  | | |_| |/  \  ${reset_color}"
            # echo "${fg_bold[red]}  |_| |_|  |_|\___//_/\_\ ${reset_color}"
        elif is_screen_running; then
            # echo "This is on screen."
        fi
    else
        if shell_has_started_interactively && ! is_ssh_running; then
            if ! is_exists 'tmux'; then
                echo 'Error: tmux command not found' 2>&1
                return 1
            fi

            if tmux has-session >/dev/null 2>&1 && tmux list-sessions | grep -qE '.*]$'; then
                # detached session exists
                tmux list-sessions
                echo -n "Tmux: attach? (y/N/num) "
                read
                if [[ "$REPLY" =~ ^[Yy]$ ]] || [[ "$REPLY" == '' ]]; then
                    tmux attach-session
                    if [ $? -eq 0 ]; then
                        echo "$(tmux -V) attached session"
                        return 0
                    fi
                elif [[ "$REPLY" =~ ^[0-9]+$ ]]; then
                    tmux attach -t "$REPLY"
                    if [ $? -eq 0 ]; then
                        echo "$(tmux -V) attached session"
                        return 0
                    fi
                fi
            fi

            if is_osx && is_exists 'reattach-to-user-namespace'; then
                # on OS X force tmux's default command
                # to spawn a shell in the user's namespace
                tmux_config=$(cat $HOME/.tmux.conf <(echo 'set-option -g default-command "reattach-to-user-namespace -l $SHELL"'))
                tmux -f <(echo "$tmux_config") new-session && echo "$(tmux -V) created new session supported OS X"
            else
                tmux new-session && echo "tmux created new session"
            fi
        fi
    fi
}
tmux_automatically_attach_session

PATH="/home/hirotoshi/perl5/bin${PATH:+:${PATH}}"; export PATH;
PERL5LIB="/home/hirotoshi/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/home/hirotoshi/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/home/hirotoshi/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/home/hirotoshi/perl5"; export PERL_MM_OPT;

compton.conf

# Shadow
shadow = true;
# no-dnd-shadow = true;
# no-dock-shadow = true;
clear-shadow = true;
shadow-radius = 4;
shadow-offset-x = -5;
shadow-offset-y = -5;
shadow-opacity = 0.7;
# shadow-red = 0.0;
# shadow-green = 0.0;
# shadow-blue = 0.0;
shadow-exclude = [
    "name *= 'Notification'",
    "name *= 'Firefox'",
    "name *= 'mozc_renderer'",
    "name *= 'xmobar'",
    "class_g = 'Conky'",
    "class_g ?= 'Notify-osd'",
    "class_g = 'Cairo-clock'",
    "_GTK_FRAME_EXTENTS@:c"
];
# shadow-exclude = "n:e:Notification";
# shadow-exclude-reg = "x10+0+0";
# xinerama-shadow-crop = true;

# Opacity
menu-opacity = 0.95;
#inactive-opacity = 0.9;
#active-opacity = 0.9;
# frame-opacity = 0.9;
# inactive-opacity-override = false;
alpha-step = 0.06;
# inactive-dim = 0.2;
# inactive-dim-fixed = true;
blur-background = false;
#blur-background-frame = true;
#blur-kern = "5x5box"
# blur-kern = "5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1"
# blur-background-fixed = true;
#blur-background-exclude = [
#    "window_type = 'dock'",
#    "window_type = 'desktop'",
#    "_GTK_FRAME_EXTENTS@:c"
#];
opacity-rule = [
    "90:class_g = 'Thunar'",
    "90:name *= 'Chromium'",
    "90:name *= 'GVIM'",
#    "99:class_g = 'mplayer2'",
    "90:class_g = 'Firefox'",
#    "99:class_g = 'Plugin-container'"
    "70:name *= 'ibus-ui-gtk3'",
    "85:name *= 'xmobar'"
];

# Fading
fading = true;
fade-delta = 3;
fade-in-step = 0.04;
fade-out-step = 0.03;
# no-fading-openclose = true;
# no-fading-destroyed-argb = true;
fade-exclude = [ ];

# Other
# backend glx or xrender
backend = "glx";
# mark-wmwin-focused = true;
# mark-ovredir-focused = true;
# use-ewmh-active-win = true;
detect-rounded-corners = true;
# detect-client-opacity = true;
refresh-rate = 0;
# vsync = "none";
# dbe = false;
paint-on-overlay = true;
# sw-opti = true;
# unredir-if-possible = true;
# unredir-if-possible-delay = 5000;
# unredir-if-possible-exclude = [ ];
# focus-exclude = [ "class_g = 'Cairo-clock'" ];
# detect-transient = true;
# detect-client-leader = true;
# invert-color-include = [ ];
# resize-damage = 1;

# GLX backend
glx-no-stencil = true;
# glx-copy-from-front = false;
# glx-use-copysubbuffermesa = true;
glx-no-rebind-pixmap = true;
# glx-swap-method = "undefined";
# glx-use-gpushader4 = true;
# xrender-sync = true;
# xrender-sync-fence = true;

# Window type settings
wintypes:
{
  tooltip = { fade = true; shadow = true; opacity = 0.9; focus = true; };
  dock = { shadow = false; };
};

f:id:kh2n:20171121210919p:plain

f:id:kh2n:20171121210924p:plain

gvim,tmux,zshの設定 macOS編

これで設定は最後。設定で頭をあまり使いたくないので…。macOSで使っている設定ファイルです。Linuxの方は少しいじれば出来ますので。zshrcに関してはあまり整理してません。どうせその都度作り直すので。元設定ファイルを参考にしながら作り直してます。

.vimrc

syntax on

set nobackup
set encoding=utf-8
set fileencoding=utf-8
set number
set title
set showcmd
set ruler
set showmatch
set matchtime=3
set laststatus=2
set expandtab
set shiftwidth=2
set tabstop=2
set softtabstop=0
set list
set listchars=tab:>.,trail:_,eol:,extends:>,precedes:<,nbsp:%
set showtabline=2
set clipboard+=unnamed
set clipboard+=autoselect
set backspace=indent,eol,start

nnoremap u g-
nnoremap <C-r> g+

function! ZenkakuSpace()
    highlight ZenkakuSpace cterm=reverse ctermfg=Blue gui=reverse guifg=Blue
endfunction

if has('syntax')
    augroup ZenkakuSpace
        autocmd!
        autocmd ColorScheme       * call ZenkakuSpace()
        autocmd VimEnter,WinEnter * match ZenkakuSpace / /
    augroup END
    call ZenkakuSpace()
endif

function! s:clang_format()
  let now_line = line(".")
  exec ":%! clang-format"
  exec ":" . now_line
endfunction

if executable('clang-format')
  augroup cpp_clang_format
    autocmd!
    autocmd BufWrite,FileWritePre,FileAppendPre *.[ch]pp call s:clang_format()
    autocmd BufWrite,FileWritePre,FileAppendPre *.[ch] call s:clang_format()
    autocmd BufWrite,FileWritePre,FileAppendPre *.js call s:clang_format()
    autocmd BufWrite,FileWritePre,FileAppendPre *.java call s:clang_format()
  augroup END
endif

"dein Scripts-----------------------------
if &compatible
  set nocompatible               " Be iMproved
endif

" Required:
set runtimepath+=/Users/hirotoshi/.vim/bundles/repos/github.com/Shougo/dein.vim

" Required:
if dein#load_state('/Users/hirotoshi/.vim/bundles')
  call dein#begin('/Users/hirotoshi/.vim/bundles')

  " Let dein manage dein
  " Required:
  call dein#add('/Users/hirotoshi/.vim/bundles/repos/github.com/Shougo/dein.vim')

  " Add or remove your plugins here:
  call dein#add('Shougo/neosnippet.vim')
  call dein#add('Shougo/neosnippet-snippets')
  call dein#add('tomasr/molokai')
  call dein#add('w0ng/vim-hybrid')
  call dein#add('altercation/vim-colors-solarized')
  call dein#add('scrooloose/nerdtree')
  call dein#add('Shougo/unite.vim')
  call dein#add('Shougo/neomru.vim')
  call dein#add('Shougo/neocomplete.vim')
  call dein#add('vim-airline/vim-airline')
  call dein#add('vim-airline/vim-airline-themes')
  call dein#add('Shougo/vimproc.vim', { 'build' : 'make'})
  " You can specify revision/branch/tag.
  call dein#add('Shougo/vimshell', { 'rev': '3787e5' })
  " Required:
  call dein#end()
  call dein#save_state()
endif

" Required:
filetype plugin indent on
syntax enable

" If you want to install not installed plugins on startup.
"if dein#check_install()
"  call dein#install()
"endif

"End dein Scripts-------------------------

"Note: This option must be set in .vimrc(_vimrc).  NOT IN .gvimrc(_gvimrc)!
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplete#sources#syntax#min_keyword_length = 3

" Define dictionary.
let g:neocomplete#sources#dictionary#dictionaries = {
    \ 'default' : '',
    \ 'vimshell' : $HOME.'/.vimshell_hist',
    \ 'scheme' : $HOME.'/.gosh_completions'
        \ }

" Define keyword.
if !exists('g:neocomplete#keyword_patterns')
    let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'

" Plugin key-mappings.
inoremap <expr><C-g>     neocomplete#undo_completion()
inoremap <expr><C-l>     neocomplete#complete_common_string()

" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
  return (pumvisible() ? "\<C-y>" : "" ) . "\<CR>"
  " For no inserting <CR> key.
  "return pumvisible() ? "\<C-y>" : "\<CR>"
endfunction
" <TAB>: completion.
inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? "\<C-y>" : "\<Space>"

" AutoComplPop like behavior.
"let g:neocomplete#enable_auto_select = 1

" Shell like behavior(not recommended).
"set completeopt+=longest
"let g:neocomplete#enable_auto_select = 1
"let g:neocomplete#disable_auto_complete = 1
"inoremap <expr><TAB>  pumvisible() ? "\<Down>" : "\<C-x>\<C-u>"

" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags

" Enable heavy omni completion.
if !exists('g:neocomplete#sources#omni#input_patterns')
  let g:neocomplete#sources#omni#input_patterns = {}
endif
"let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
"let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
"let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'

" For perlomni.vim setting.
" https://github.com/c9s/perlomni.vim
let g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::'
set background=dark
colorscheme hybrid
let g:airline_theme='simple'

.gvimrc

syntax enable
set background=dark
colorscheme hybrid

set guifont=SF\ Mono\ for\ Powerline:h12
set guifontwide=Hiragino\ Kaku\ Gothic\ ProN\ W6:h12

autocmd GUIEnter * set transparency=3
autocmd FocusGained * set transparency=3
autocmd FocusLost * set transparency=10

.tmux.conf

set-window-option -g mouse on
set -g terminal-overrides 'xterm*:smcup@:rmcup@'
set -g default-terminal screen-256color

set -g prefix C-a
unbind C-b
set -g default-command "reattach-to-user-namespace -l ${SHELL}"
bind \ split-window -h
bind - split-window -v

run-shell "~/powerline/scripts/powerline-daemon -q"
source "~/powerline/powerline/bindings/tmux/powerline.conf"

.zshrc

[[ -d ~/.rbenv  ]] && \
  export PATH=${HOME}/.rbenv/bin:${PATH} && \
  eval "$(rbenv init -)"
alias vi=/usr/local/bin/vim
alias vim=/usr/local/bin/vim
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
alias emacs=/Applications/Emacs.app/Contents/MacOS/Emacs
# Path to your oh-my-zsh installation.
export ZSH=/Users/hirotoshi/.oh-my-zsh
export ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR=/usr/local/share/zsh-syntax-highlighting/highlighters
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/local/share/zsh-navigation-tools/zsh-navigation-tools.plugin.zsh
export PATH=$PATH:/usr/local/opt/go/libexec/bin
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
#
# ZSH_THEME="robbyrussell"
# ZSH_THEME="rkj"
ZSH_THEME="powerline"
# ZSH_THEME="powerlevel9k/powerlevel9k"
#
# powerline
#
POWERLINE_HIDE_HOST_NAME="true"
POWERLINE_HIDE_GIT_PROMPT_STATUS="true"
POWERLINE_SHOW_GIT_ON_RIGHT="true"
POWERLINE_PATH="short"
#
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)

source $ZSH/oh-my-zsh.sh

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"

fpath=(/usr/local/share/zsh-completions $fpath)

autoload -Uz colors
colors

LANG=ja_JP.UTF-8
LC_CTYPE=ja_JP.UTF-8
LANG=ja_JP.UTF-8
LC_ALL=ja_JP.UTF-8

PAGER=less

HISTSIZE=500000
SAVEHIST=500000

setopt hist_ignore_dups
setopt share_history
setopt extended_glob

set -g set-titles on
set -g set-titles-string '#W'

autoload -Uz compinit
compinit -u

zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*' ignore-parents parent pwd ..
zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin \
                   /usr/sbin /usr/bin /sbin /bin /usr/X11R6/bin
zstyle ':completion:*:processes' command 'ps x -o pid,s,args'

setopt print_eight_bit
setopt interactive_comments
setopt auto_cd
autoload zmv

export CLICOLOR=1
alias vi='vim'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias mkdir='mkdir -p'
alias ls='ls -G -F'

export PATH="$HOME/.rbenv/bin:$PATH"
export PATH="$HOME/.cabal/bin:$PATH"
export PATH="$HOME/Documents/markdown_test:$PATH"

if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
export NODE_PATH=/usr/local/lib/node_modules

# tmux settings

function is_exists() { type "$1" >/dev/null 2>&1; return $?; }
function is_osx() { [[ $OSTYPE == darwin* ]]; }
function is_screen_running() { [ ! -z "$STY" ]; }
function is_tmux_runnning() { [ ! -z "$TMUX" ]; }
function is_screen_or_tmux_running() { is_screen_running || is_tmux_runnning; }
function shell_has_started_interactively() { [ ! -z "$PS1" ]; }
function is_ssh_running() { [ ! -z "$SSH_CONECTION" ]; }

function tmux_automatically_attach_session()
{
    if is_screen_or_tmux_running; then
        ! is_exists 'tmux' && return 1

        if is_tmux_runnning; then
            # echo "${fg_bold[red]} _____ __  __ _   ___  __ ${reset_color}"
            # echo "${fg_bold[red]}|_   _|  \/  | | | \ \/ / ${reset_color}"
            # echo "${fg_bold[red]}  | | | |\/| | | | |\  /  ${reset_color}"
            # echo "${fg_bold[red]}  | | | |  | | |_| |/  \  ${reset_color}"
            # echo "${fg_bold[red]}  |_| |_|  |_|\___//_/\_\ ${reset_color}"
        elif is_screen_running; then
            # echo "This is on screen."
        fi
    else
        if shell_has_started_interactively && ! is_ssh_running; then
            if ! is_exists 'tmux'; then
                echo 'Error: tmux command not found' 2>&1
                return 1
            fi

            if tmux has-session >/dev/null 2>&1 && tmux list-sessions | grep -qE '.*]$'; then
                # detached session exists
                tmux list-sessions
                echo -n "Tmux: attach? (y/N/num) "
                read
                if [[ "$REPLY" =~ ^[Yy]$ ]] || [[ "$REPLY" == '' ]]; then
                    tmux attach-session
                    if [ $? -eq 0 ]; then
                        echo "$(tmux -V) attached session"
                        return 0
                    fi
                elif [[ "$REPLY" =~ ^[0-9]+$ ]]; then
                    tmux attach -t "$REPLY"
                    if [ $? -eq 0 ]; then
                        echo "$(tmux -V) attached session"
                        return 0
                    fi
                fi
            fi

            if is_osx && is_exists 'reattach-to-user-namespace'; then
                # on OS X force tmux's default command
                # to spawn a shell in the user's namespace
                tmux_config=$(cat $HOME/.tmux.conf <(echo 'set-option -g default-command "reattach-to-user-namespace -l $SHELL"'))
                tmux -f <(echo "$tmux_config") new-session && echo "$(tmux -V) created new session supported OS X"
            else
                tmux new-session && echo "tmux created new session"
            fi
        fi
    fi
}
tmux_automatically_attach_session

# source ~/powerline/powerline/bindings/zsh/powerline.zsh

f:id:kh2n:20171121181703p:plain

f:id:kh2n:20171121183946p:plain

f:id:kh2n:20171121181722p:plain

NodeJSの問題を解く

GVimの設定とtmuxの設定と、大体いじれたのでコーディング。GVimでファイルの新規作成を楽にするにはどうすれば良いんだろう?とりあえずUnite.vimを使ってインサートモードでファイル名を入力してますけど。パスを記憶してくれれば楽にできるんですけどね。履歴を保存してくれますけど新規作成を楽にするには…。

新・解きながら学ぶJava

新・解きながら学ぶJava

解きながら学ぶJava 入門編

解きながら学ぶJava 入門編

// q4-4
process.stdout.write("整数A : ");
var a = require("fs").readFileSync("/dev/stdin", "utf8");
process.stdout.write("整数B : ");
var b = require("fs").readFileSync("/dev/stdin", "utf8");
a = parseInt(a.replace("\n", ""));
b = parseInt(b.replace("\n", ""));
if (a > b) {
  var t = a;
  a = b;
  b = t;
}
for (var i = a; i <= b; i++) {
  process.stdout.write(i + ' ');
}
console.log();

// q4-5
console.log("カウントダウンします。");
var a;
do {
  process.stdout.write("正の整数値 : ");
  a = require("fs").readFileSync("/dev/stdin", "utf8");
  a = parseInt(a.replace("\n", ""));
} while (a <= 0);
while (a >= 0) {
  console.log(a);
  a--;
}
console.log("xの値は%dになりました。", a);

// q4-7
process.stdout.write("何個*を表示しますか : ");
var a = require("fs").readFileSync("/dev/stdin", "utf8");
a = parseInt(a.replace("\n", ""));
for (var i = 0; i < a; i++)
  process.stdout.write('*');
if (a >= 0)
  console.log();

GVimの使い方の研究とNodeJSで試しに問題を解く

環境が変わると途端に今までコーディングをしていた方法を忘れました。慣らすと思い出してきました。

それにしてもVim、めっちゃ便利ですね。GUIでもCUIでもどちらでも便利ですし。度々目にするShougoという方、凄い!何が便利かというのを説明するにはちょっと面倒くさくなってきたので、設定ファイルを晒してみます。分かる方は見て分かると思いますので。

.vimrc

syntax on

set nobackup
set encoding=utf-8
set fileencoding=utf-8
set number
set title
set showcmd
set ruler
set showmatch
set matchtime=3
set laststatus=2
set expandtab
set shiftwidth=2
set tabstop=2
set softtabstop=0
set list
set listchars=tab:>.,trail:_,eol:,extends:>,precedes:<,nbsp:%
set showtabline=2

nnoremap u g-
nnoremap <C-r> g+

function! ZenkakuSpace()
    highlight ZenkakuSpace cterm=reverse ctermfg=Blue gui=reverse guifg=Blue
endfunction

if has('syntax')
    augroup ZenkakuSpace
        autocmd!
        autocmd ColorScheme       * call ZenkakuSpace()
        autocmd VimEnter,WinEnter * match ZenkakuSpace / /
    augroup END
    call ZenkakuSpace()
endif

function! s:clang_format()
  let now_line = line(".")
  exec ":%! clang-format"
  exec ":" . now_line
endfunction

if executable('clang-format')
  augroup cpp_clang_format
    autocmd!
    autocmd BufWrite,FileWritePre,FileAppendPre *.[ch]pp call s:clang_format()
    autocmd BufWrite,FileWritePre,FileAppendPre *.[ch] call s:clang_format()
  augroup END
endif

"dein Scripts-----------------------------
if &compatible
  set nocompatible               " Be iMproved
endif

" Required:
set runtimepath+=/Users/hirotoshi/.vim/bundles/repos/github.com/Shougo/dein.vim

" Required:
if dein#load_state('/Users/hirotoshi/.vim/bundles')
  call dein#begin('/Users/hirotoshi/.vim/bundles')

  " Let dein manage dein
  " Required:
  call dein#add('/Users/hirotoshi/.vim/bundles/repos/github.com/Shougo/dein.vim')

  " Add or remove your plugins here:
  call dein#add('Shougo/neosnippet.vim')
  call dein#add('Shougo/neosnippet-snippets')
  call dein#add('tomasr/molokai')
  call dein#add('w0ng/vim-hybrid')
  call dein#add('altercation/vim-colors-solarized')
  call dein#add('scrooloose/nerdtree')
  call dein#add('Shougo/unite.vim')
  call dein#add('Shougo/vimproc.vim', {'build' : 'make'})
  " You can specify revision/branch/tag.
  call dein#add('Shougo/vimshell', { 'rev': '3787e5' })
  " Required:
  call dein#end()
  call dein#save_state()
endif

" Required:
filetype plugin indent on
syntax enable

" If you want to install not installed plugins on startup.
"if dein#check_install()
"  call dein#install()
"endif

"End dein Scripts-------------------------

set background=dark
colorscheme hybrid

.gvimrc

syntax enable
set background=dark
colorscheme hybrid

set guifont=SF\ Mono:h12
set guifontwide=Hiragino\ Kaku\ Gothic\ ProN\ W6:h12

autocmd GUIEnter * set transparency=3
autocmd FocusGained * set transparency=3
autocmd FocusLost * set transparency=10

f:id:kh2n:20171119231054p:plain

新・解きながら学ぶJava

新・解きながら学ぶJava

解きながら学ぶJava 入門編

解きながら学ぶJava 入門編

// q4-2
do {
  process.stdout.write("3桁の正の整数値 : ");
  var x = require("fs").readFileSync("/dev/stdin","utf8");
} while(x < 100 || x > 999);

console.log("%dと入力しましたね。", x);

// q4-3
console.log("数当てゲーム開始!!");
console.log("10~99の数を当ててください。");
var answer,no;
no = Math.floor(Math.random() * 90 + 10);
do {
  process.stdout.write("いくつかな : ");
  answer = require("fs").readFileSync("/dev/stdin","utf8");
  if(answer > no)
    console.log("もっと小さい数です。");
  else if(answer < no)
    console.log("もっと大きい数です。");
} while(answer != no);

console.log("正解です。");

今のところこんなんですけど、またカスタマイズして使い方を研究してみます。

Vimに改宗した

Emacsを使うのが辛くなってきたのでVim(GVim)に乗り換えました。設定ファイルも見直しました。例えば、noexpandtabを使ってましたが、不具合があるのでexpandtabに設定したりと。拡張機能はNeoBundleを使ってますが、packaddにした方が良いのかな。vimrcにNeoBundleの設定を記述すると、コマンドモードでは変なエラーを出してしまうので、gvimrcに書き直したりと。フォントはSF MonoとHiragino Kaku Gothic ProN,Noto Sansのようなものを使ってます。テーマは適当にslateに設定しました。後日、また良いテーマを探してみます。

追記 : packaddがマニュアルを見ても正しく使えないので(バグ?)、dein.vimを使うようにしました。NeoBundleより新しいみたいです。packaddを使ったパッケージマネージャminpacというのがあるようで、これも使えるかもしれませんね。

追記 : テーマをGitHubからdein.vim仕入れて適用させたら見違えました。後ソースフォーマッタとしてclang-formatを使いますけど、vimrcに設定を記述するだけで保存時に自動でコードを整形してくれます。便利!メインで使っていこうと思います。

C言語で問題を解く

// q3-3
#include <time.h>
#include <stdio.h>
#include <stdlib.h>

int human;
int comp;
int win_no;
int lose_no;
int draw_no;

char *hd[] = {"グー","チョキ","パー"};

void initialize(void) {
  win_no = 0;
  lose_no = 0;
  draw_no = 0;
  srandom(time(NULL));
  printf("じゃんけんゲーム開始!!\n");
}

void jyanken(void) {
  int i;
  do {
    comp = random() % 3;
  } while(comp == 1);
  do {
    printf("\n\aじゃんけんポン ...");
    for(i = 0; i < 3; i++)
      printf("  (%d)%s", i, hd[i]);
    printf(" : ");
    scanf("%d", &human);
  }while(human < 0 || human > 2);
}

void count_no(int result) {
  switch(result) {
    case 0: draw_no++; break;
    case 1: lose_no++; break;
    case 2: win_no++; break;
  }
}

void disp_result(int result) {
  switch(result) {
    case 0: puts("引き分けです。"); break;
    case 1: puts("あなたの負けです。"); break;
    case 2: puts("あなたの勝ちです。"); break;
  }
}

int confirm_retry(void) {
  int x;
  printf("もう一度しますか...(0)いいえ (1)はい : ");
  scanf("%d", &x);
  return x;
}

int main(void) {
  int judge;
  int retry;
  initialize();
  do {
    jyanken();
    printf("私は%sで、あなたは%sです。\n", hd[comp], hd[human]);
    judge = (human - comp + 3) % 3;
    count_no(judge);
    disp_result(judge);
    retry = confirm_retry();
  } while(retry == 1);
  printf("%d%d%d分けでした。\n", win_no, lose_no, draw_no);
  return 0;
}

// q3-4
#include <time.h>
#include <stdio.h>
#include <stdlib.h>

const int true = 1;
const int false = 0;

int human;
int comp;
int win_no;
int lose_no;
int draw_no;

char *hd[] = {"グー","チョキ","パー"};

void initialize(void) {
  win_no = 0;
  lose_no = 0;
  draw_no = 0;
  srandom(time(NULL));
  printf("じゃんけんゲーム開始!!\n");
}

void jyanken(void) {
  int i;
  static int flag = false;
  if(flag == false) {
    comp = 0;
    flag = true;
  } else
    comp = random() % 3;
  do {
    printf("\n\aじゃんけんポン ...");
    for(i = 0; i < 3; i++)
      printf("  (%d)%s", i, hd[i]);
    printf(" : ");
    scanf("%d", &human);
  }while(human < 0 || human > 2);
}

void count_no(int result) {
  switch(result) {
    case 0: draw_no++; break;
    case 1: lose_no++; break;
    case 2: win_no++; break;
  }
}

void disp_result(int result) {
  switch(result) {
    case 0: puts("引き分けです。"); break;
    case 1: puts("あなたの負けです。"); break;
    case 2: puts("あなたの勝ちです。"); break;
  }
}

int confirm_retry(void) {
  int x;
  printf("もう一度しますか...(0)いいえ (1)はい : ");
  scanf("%d", &x);
  return x;
}

int main(void) {
  int judge;
  int retry;
  initialize();
  do {
    jyanken();
    printf("私は%sで、あなたは%sです。\n", hd[comp], hd[human]);
    judge = (human - comp + 3) % 3;
    count_no(judge);
    disp_result(judge);
    retry = confirm_retry();
  } while(retry == 1);
  printf("%d%d%d分けでした。\n", win_no, lose_no, draw_no);
  return 0;
}

// q3-5
#include <time.h>
#include <stdio.h>
#include <stdlib.h>

int human;
int comp;
int win_no;
int lose_no;
int draw_no;

char *hd[] = {"グー","チョキ","パー"};

void initialize(void) {
  win_no = 0;
  lose_no = 0;
  draw_no = 0;
  srandom(time(NULL));
  printf("じゃんけんゲーム開始!!\n");
}

void jyanken(void) {
  int i;
  static int count = 1;
  if(count % 5 != 0)
    comp = rand() % 3;
  do {
    printf("\n\aじゃんけんポン ...");
    for(i = 0; i < 3; i++)
      printf("  (%d)%s", i, hd[i]);
    printf(" : ");
    scanf("%d", &human);
  }while(human < 0 || human > 2);
  if(count % 5 == 0) {
    switch(human) {
    case 0:
      comp = 2;
      break;
    case 1:
      comp = 0;
      break;
    case 2:
      comp = 1;
      break;
    }
  }
  count++;
}

void count_no(int result) {
  switch(result) {
    case 0: draw_no++; break;
    case 1: lose_no++; break;
    case 2: win_no++; break;
  }
}

void disp_result(int result) {
  switch(result) {
    case 0: puts("引き分けです。"); break;
    case 1: puts("あなたの負けです。"); break;
    case 2: puts("あなたの勝ちです。"); break;
  }
}

int confirm_retry(void) {
  int x;
  printf("もう一度しますか...(0)いいえ (1)はい : ");
  scanf("%d", &x);
  return x;
}

int main(void) {
  int judge;
  int retry;
  initialize();
  do {
    jyanken();
    printf("私は%sで、あなたは%sです。\n", hd[comp], hd[human]);
    judge = (human - comp + 3) % 3;
    count_no(judge);
    disp_result(judge);
    retry = confirm_retry();
  } while(retry == 1);
  printf("%d%d%d分けでした。\n", win_no, lose_no, draw_no);
  return 0;
}

// q3-5-2
#include <time.h>
#include <stdio.h>
#include <stdlib.h>

int human;
int comp;
int win_no;
int lose_no;
int draw_no;

char *hd[] = {"グー","チョキ","パー"};

void initialize(void) {
  win_no = 0;
  lose_no = 0;
  draw_no = 0;
  srandom(time(NULL));
  printf("じゃんけんゲーム開始!!\n");
}

void jyanken(void) {
  int i;
  static int count = 1;
  if(count % 5 != 0)
    comp = random() % 3;
  do {
    printf("\n\aじゃんけんポン ...");
    for(i = 0; i < 3; i++)
      printf(" (%d)%s", i, hd[i]);
    printf(" : ");
    scanf("%d", &human);
  } while(human < 0 || human > 2);
  if(count % 5 == 0) {
    switch(human) {
    case 0:
      comp = 2;
      break;
    case 1:
      comp = 0;
      break;
    case 2:
      comp = 1;
      break;
    }
  }
  count++;
}

void count_no(int result) {
  switch(result) {
    case 0: draw_no++; break;
    case 1: lose_no++; break;
    case 2: win_no++; break;
  }
}

void disp_result(int result) {
  switch(result) {
    case 0: puts("引き分けです。"); break;
    case 1: puts("あなたの負けです。"); break;
    case 2: puts("あなたの勝ちです。"); break;
  }
}

int main(void) {
  int judge;
  int n;
  printf("何回勝負しますか : ");
  scanf("%d", &n);
  initialize();
  do {
    jyanken();
    printf("私は%sで、あなたは%sです。\n", hd[comp], hd[human]);
    judge = (human - comp + 3) % 3;
    count_no(judge);
    disp_result(judge);
  } while(win_no < n && lose_no < n);
  printf(win_no == n ? "\n□あなたの勝ちです。\n" : "\n■私の勝ちです。\n");
  printf("%d%d%d分けでした。\n", win_no, lose_no, draw_no);
  return 0;
}

Javaで問題を解く

新・解きながら学ぶJava

新・解きながら学ぶJava

解きながら学ぶJava 入門編

解きながら学ぶJava 入門編

// q7-24
import java.util.Scanner;

class q7_24 {
    static int[] arrayRmvOf(int[] a, int idx) {
        int ti = 0;
        int[] result = new int[a.length - 1];
        for(int i = 0; i < a.length; i++) {
            if(i != idx)
                result[ti++] = a[i];
        }
        return result;
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.print("要素数 : ");
        int n = scan.nextInt();
        int[] x = new int[n];
        for(int i = 0; i < x.length; i++) {
            System.out.printf("x[%d] : ", i);
            x[i] = scan.nextInt();
        }
        System.out.print("削除する要素のインデックス : ");
        int idx = scan.nextInt();
        int[] y = arrayRmvOf(x, idx);
        for(int i = 0; i < y.length; i++)
            System.out.printf("y[%d] : %d\n", i, y[i]);
    }
}

// q7-25
import java.util.Scanner;

class q7_25 {
    static int[] arrayRmvOfN(int[] a, int idx, int n) {
        int ti = 0;
        int[] result = new int[a.length - n];
        for(int i = 0; i < idx; i++)
            result[ti++] = a[i];
        for(int i = idx + n; i < a.length; i++)
            result[ti++] = a[i];
        return result;
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.print("要素数 : ");
        int n = scan.nextInt();
        int[] x = new int[n];
        for(int i = 0; i < x.length; i++) {
            System.out.printf("x[%d] : ", i);
            x[i] = scan.nextInt();
        }
        System.out.print("削除する開始インデックス : ");
        int idx = scan.nextInt();
        System.out.print("削除する要素の個数 : ");
        int num = scan.nextInt();
        int[] y = arrayRmvOfN(x, idx, num);
        for(int i = 0; i < y.length; i++)
            System.out.printf("y[%d] : %d\n", i, y[i]);
    }
}