I'm having an issue with vim startup. Whenever I run
vim somefile, it starts as though I pressed
c just after startup. So, if I then try to immediately jump to the end of the file with
G, it instead changes to the end of the file, i.e. all the lines from the startup line to the end of the file are gone and I'm in insert mode. I'm using terminal vim rather than MacVim, and my shell is zsh in case that's relevant. I'm using the base 16 tomorrow 256-color scheme in both my shell and in vim—dark for the shell and the light incarnation for vim. I'm using the Janus configuration with pretty minimal customization.
Here are the things I've tried to find the problem:
- Comment out everything from my
.vimrc.afterfile except colorscheme and font declarations. No change.
- Disable my base16 color scheme commands in iTerm2 and vim. Thought maybe the 256 color shell script was causing an issue, but no dice.
- Removed the one custom plugin I have in Janus (Emmet). No difference.
- Changed colorscheme to a non-base16 scheme. No difference.
The only real difference I've been able to find is between iTerm2 and Terminal.app. In Terminal.app, the change command seems to be limited to a single line no matter what motion command I type immediately after startup. So, if I type
G after opening a file, it does not remove all the lines below. It just deletes the line it is on and enters insert mode.
Another couple pieces of evidence: 1) If I open a directory with
vim path/to/directory, I get slightly different behavior from Terminal.app and iTerm2. In iTerm2, there's no apparent issue. In Terminal.app, I get
E481: No range allowed message at the bottom of the window. 2) If I use MacVim, the behavior is not present as far as I can tell. This makes me think it's something to do with my shell environment. Both Terminal.app and iTerm2 have their terminal reporting set to xterm-256color.
So, that's the situation. Below are the contents of my relevant vim files. While a solution to the issue will be helpful, I'm more interested in learning to fish here. Part of my frustration with vim in the past was that it would sometimes do things I didn't understand. Sometimes through typos or fat fingering commands or something, but nevertheless, I didn't know what I did to cause the bizarre behavior so that I could avoid it in the future. I'm in that same boat here. I don't want to know just how to fix it but what was going wrong and some sort of methodology for tracking down the problem that I could maybe apply to future issues. Thanks in advance!
set nocompatible let mapleader="," set splitbelow set splitright call janus#disable_plugin('nerdtree') if has("gui_running") let g:loaded_netrw = 1 " Disable netrw let g:loaded_netrwPlugin = 1 " Disable netrw endif
"" "" Janus setup "" " Define paths "let g:janus_path = escape(fnamemodify(resolve(expand("<sfile>:p" . "janus" . "janus")), ":h"), ' ') "let g:janus_vim_path = escape(fnamemodify(resolve(expand("<sfile>:p" . "janus" . "janus" . "vim")), ":h"), ' ')" let g:home_path = expand("~") let g:vim_path = g:home_path . "/.dotfiles/vim" let g:janus_path = g:vim_path . "/janus/janus" let g:janus_vim_path = g:janus_path . "/vim" let g:janus_custom_path = g:vim_path . "customization" if filereadable(g:janus_vim_path . '/core/before/plugin/janus.vim') " Source janus's core exe 'source ' . g:janus_vim_path . '/core/before/plugin/janus.vim' " You should note that groups will be processed by Pathogen in reverse " order they were added. call janus#add_group("tools") call janus#add_group("langs") call janus#add_group("colors") "" "" Customisations "" if filereadable(expand("~/.vimrc.before")) source ~/.vimrc.before endif " Disable plugins prior to loading pathogen exe 'source ' . g:janus_vim_path . '/core/plugins.vim' "" "" Pathogen setup "" " Load all groups, custom dir, and janus core call janus#load_pathogen() " .vimrc.after is loaded after the plugins have loaded endif
let base16colorspace=256 " Access colors present in 256 colorspace set background=light colorscheme base16-tomorrow set guifont=Panic\ Sans:h13 "set tabstop=4 "set shiftwidth=4 "set softtabstop=4 "set expandtab "let g:user_emmet_install_global = 0 "autocmd FileType html,css,eruby,eruby-rails EmmetInstall " window nmap <leader>sw<left> :topleft vnew<CR> nmap <leader>sw<right> :botright vnew<CR> nmap <leader>sw<up> :topleft new<CR> nmap <leader>sw<down> :botright new<CR> " buffer nmap <leader>s<left> :leftabove vnew<CR> nmap <leader>s<right> :rightbelow vnew<CR> nmap <leader>s<up> :leftabove new<CR> nmap <leader>s<down> :rightbelow new<CR> " clear search highlight nnoremap <esc> :noh<return><esc> " exit insert mode when beginning text movements :imap jj <Esc> :imap jk <Esc> :imap kk <Esc> :imap kj <Esc> set clipboard=unnamed "Helpful stuff from Steve Losh set list set listchars=tab:▸\ ,eol:¬ "Change the invisible character display characters. set wrap set textwidth=79 set formatoptions=qrn1 set colorcolumn=85 nnoremap / /\v vnoremap / /\v set ignorecase set smartcase set gdefault set incsearch set showmatch set hlsearch "nnoremap <leader><space> :noh<cr> nnoremap <tab> % vnoremap <tab> % set encoding=utf-8 set scrolloff=3 set autoindent set showmode set showcmd set hidden set wildmenu set wildmode=list:longest set visualbell set cursorline set ttyfast set ruler set backspace=indent,eol,start set laststatus=2 set relativenumber set undofile nnoremap <up> <nop> nnoremap <down> <nop> nnoremap <left> <nop> nnoremap <right> <nop> inoremap <up> <nop> inoremap <down> <nop> inoremap <left> <nop> inoremap <right> <nop> nnoremap j gj nnoremap k gk inoremap <F1> <ESC> nnoremap <F1> <ESC> vnoremap <F1> <ESC> " Save on focus lost au FocusLost * :wa
" Override existing colorscheme with version found in " ~/.janus/<colorscheme>/colors/<colorscheme>.vim if exists("g:colors_name") let color_override = expand('~/.janus/' . g:colors_name . '/colors/' . g:colors_name . '.vim') if filereadable(color_override) exe 'source ' . color_override endif endif set background=light colorscheme base16-tomorrow set guifont=Panic\ Sans:h13