multiline insert (Shift-I) no longer works in vim - vim

I used to be able to use ctrl-v and Shift-I to do multi line insert. I think it MIGHT have been caused by installing gvim? I have spent hours trying to fix this. I have tried running without plugins and removing .vimrc
my .vimrc
execute pathogen#infect()
syntax on
filetype plugin indent on
set nocompatible
set tabstop=2 "Set size of tab to 2 spaces
set shiftwidth=2
set expandtab "Turns tab into spaces
set autoindent "Automatically indents to the same indent next line
set smarttab "return on a tabbed line returns to that tabbed position
set number
set showcmd "shows last command typed
set wildmenu "Autocomplete menu that pops up at bottom
set showmatch
""SEARCH""
set incsearch "search as characters are entered
set hlsearch "highlights all words
""PASTE MODE""""""""""""""""""""""""""""
nnoremap <F2> :set invpaste paste?<CR>
set pastetoggle=<F2>
set showmode
""SET COLORS"""""
colo solarized
set background=dark
augroup filetypedetect
au BufRead,BufNewFile *.hbs setfiletype html
" associate *.hbs with html filetype
augroup END
Global vimrc
runtime! debian.vim
if has("syntax")
syntax on
endif
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif

Related

Vim - Random "syntax=" text appearing in editor

Here's what I'm talking about.
On line 2 there is this highlighted block of "syntax=" text. It doesn't belong there and and will appear (seemingly) randomly. If I sweep over it in visual mode it goes away. I suspect that it's something to do with syntastic but I could easily be wrong since I'm only an intermediate when it comes to vim.
Here are the plugins I'm using,
YouCompleteMe
emmet-vim
html5.vim
nerdcommenter
python-mode
syntastic
tmp
vim-airline
vim-colors-solarized
vim-gitgutter
vim-javascript-syntax
vim-jinja
vim-js-indent
and here's my vimrc
execute pathogen#infect()
execute pathogen#helptags()
syntax on
" set [normal],rc open up the vimrc in a new buffer
let mapleader = ","
nmap <leader>rc :tabedit $MYVIMRC <CR>
" Stock Configurations
set laststatus=2
set nu
set t_Co=256
set autoread
set background=dark
set shiftwidth=4
set tabstop=4
set autoindent
set noswapfile
set nocompatible
set nowrap
set syntax
colorscheme solarized
" Autoclose YouCompleteMe Documentation Preivew after inserting
let g:ycm_autoclose_preview_window_after_insertion = 1
" Set the powerline fonts
let g:airline_powerline_fonts = 1
Also! Feel free to critique and make suggestions about my plugins and vimrc. I haven't spent a lot of time tuning things so any input would be rad!

vimrc - Syntax highlighting not working

so this is what my .vimrc contains, why is my syntax highlighting not working?
set nocompatible " must be the first line
filetype plugin indent on
syntax on
set laststatus=2
set statusline=%<%f\%h%m%r%=%-20.(line=%l\ \ col=%c%V\ \ totlin=%L%)\ \ \%h%m%r%=%-40(bytval=0x%B,%n%Y%)\%P
set nu
set shortmess=I
set nowrap
set tabstop=2
set backspace=indent,eol,start
set shiftwidth=2
set shiftround
set ignorecase
set smarttab
set hlsearch
set incsearch
set undolevels=1000
set pastetoggle=<F2>
set t_Co=256
colorscheme monokai
let g:user_emmet_leader_key = '<c-y>'
execute pathogen#infect()
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
autocmd vimenter * NERDTree
My color theme works, but the colors are not showing up properly as syntax highlighting.
Any suggestions?
First, check the output of:
:setlocal syntax?
The correct output (for php files) is:
syntax=php
You can check the php syntax code doing a:
:syntax list
You must see all syntax code with the command above. If you don't get the syntax=php value or don't see any syntax code on :syntax list, probably you don't have a php.vim file in your ~/.vim/ftplugin folder. When you set filetype plugin on and open an php file, what Vim does is to look in your ftplugin folder for a php.vim file and execute it.
php.vim is a system file, and it comes with the default installation. Try to do a :scriptname to see all scripts that are opening with vim. If you can't see a php.vim file, a solution could be install StanAngeloff/php.vim plugin.
If, and only if, you have a php.vim file and see its syntax with :syntax list, then something external is affecting Vim's syntax highlight, and it's probably your terminal.

colorscheme set in .vimrc is not being applied

I have installed zenburn colorscheme to ~/.vim/colors and am trying to enable it by default in the .vimrc file.
I have added colorscheme zenburn to my .vimrc file but the colorscheme is not enabled after vim starts.
If I manually do :colorscheme zenburn it sets the colorscheme.
If I enable a colorscheme that comes with vi ( for eg desert ) in vimrc, its being enabled at vim startup.
This is my vimrc
filetype plugin on
filetype indent on
set nocompatible
set history=500
syntax on
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set number
set autoindent
set cindent
set showmatch
set matchtime=5
set ruler
set laststatus=2
set hlsearch
set incsearch
set cursorline
set scrolloff=5
"set nowrap
set foldenable
set foldmarker={,}
set foldmethod=marker
set foldlevel=100
"set mouse=a
"set mouse=r
colorscheme zenburn
What should I do to get zenburn colorscheme enabled at startup ?
In my case when colorscheme was the only command in .vimrc it did not work. I had to add syntax on command at the end to make it work.
$ cat ~/.vimrc
colorscheme zenburn
syntax on
Try to load .vimrc file again after vim is started with :source ~/.vimrc
Did the colorscheme changes?
Also if you use graphical vim, there is second file that can override your settings ~/.gvimrc
I had a similar issue, try putting the command for colorscheme at the bottom of .vimrc
I had the same problem, and I found the following solution: in your .cshrc file (or equivalent in your .bashrc file), add the following line:
alias vi 'vim "+colorscheme my_scheme"'
Pay attention to the quotes and double quotes.
try
set colorscheme zenburn
# or
set color zenburn

Vim cursor wrapping with .vimrc

I can't seem to get cursor wrapping to work in vim 7.3. I've tried suggestions found elsewhere, including the following, which have no effect:
:set whichwrap+=<,>
:set whichwrap+=>,l
:set whichwrap+=<,h
Any suggestions? I've included my .vimrc in case there is a conflict...
syntax on
":set whichwrap+=<,h
set whichwrap+=<,>,[,]
colorscheme koehler
noremap <tab> i
inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
nnoremap ; :
nnoremap : ;
set more " use more prompt
set autoread " watch for file changes
set number " line numbers
set noautowrite " don't automagically write on :next
set lazyredraw " don't redraw when don't have to
set showmode
set showcmd
set nocompatible " vim, not vi
set autoindent smartindent " auto/smart indent
set smarttab " tab and backspace are smart
set tabstop=4 " 6 spaces
set shiftwidth=2
set scrolloff=5 " keep at least 5 lines above/below
set sidescrolloff=5 " keep at least 5 lines left/right
set history=200
set backspace=indent,eol,start
set linebreak
set cmdheight=2 " command line two lines high
set undolevels=1000 " 1000 undos
set updatecount=100 " switch every 100 chars
set complete=.,w,b,u,U,t,i,d " do lots of scanning on tab completion
set noerrorbells " No error bells please
set visualbell t_vb= " and don't make faces
filetype on " Enable filetype detection
filetype indent on " Enable filetype-specific indenting
filetype plugin on " Enable filetype-specific plugins
set wildmode=longest:full
set wildmenu " menu has tab completion
set laststatus=2
set incsearch " incremental search
set ignorecase " search ignoring case
set hlsearch " highlight the search
set showmatch " show matching bracket
set diffopt=filler,iwhite " ignore all whitespace and sync
if v:version >= 700
" Enable spell check for text files
autocmd BufNewFile,BufRead *.txt setlocal spell spelllang=en
endif
" mappings
" toggle list mode
nmap <LocalLeader>tl :set list!<cr>
" toggle paste mode
nmap <LocalLeader>pp :set paste!<cr>
The following line in your .vimrc is a conflict. Commenting out that line will probably fix the issue.
set nocompatible " vim, not vi
And for automatic wrap, I suggest you use this one and use more of h and l than the left & right arrow keys:
set whichwrap+=<,>,h,l,[,]
The issue is putting set nocompatible in the middle of your vimrc (I made the same mistake).
Actually nocompatible is set when a vimrc is detected, but set nocompatible has a side effect of resetting all options to default.
From :help nocompatible:
This is a special kind of option, because when it's set or reset, other options are also changed as a side effect.
NOTE: Setting or resetting this option can have a lot of unexpected
effects: Mappings are interpreted in another way, undo behaves
differently, etc. If you set this option in your vimrc file, you
should probably put it at the very start.

vim: smartindent (or cindent) is activated but does not work

Vim is not autoindenting the C source files I am working on, although it claims both the autoindent and cindent options are enabled when I type the
:set
command.
Nothing is happening when I type in some code. For instance writing
int main()
{
return 0;
}
the "return 0;" statement stays on the left.
However if I type the "=G" command, my file gets indented.
Here is my config:
ubuntu 13.04
vim 7.3.547 + vim-scripts
vimrc is splitted into /etc/vim/vimrc and ~/.vimrc. The concatanated content is as follow:
runtime! debian.vim
if has("syntax")
syntax on
endif
set background=dark
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
if has("autocmd")
filetype plugin indent on
endif
set showcmd
set showmatch
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
""""""" now this is ~/.vimrc """""
set runtimepath+=,/usr/share/vim-scripts
set autoindent
set noexpandtab
" create ~<file> when saving modifications to <file>
set backup
" preserve source's format when pasting
set paste
" disable mouse usage
set mouse=
" colors
set t_Co=256
colorscheme mustang
set hlsearch
set number
set cursorline
if has("statusline")
hi User1 ctermbg=red cterm=bold,reverse
hi User2 ctermbg=darkblue cterm=bold,reverse
hi User3 ctermbg=darkred cterm=bold,reverse
hi User4 ctermbg=brown cterm=bold,reverse
set laststatus=2
set statusline=%h%f\ %y\ %1*%r%*%1*%m%*%=[col:%2*%c%*]\ [line:%3*%.6l%*/%4*%.6L%*\ -\ %p%%]
endif
set spellsuggest=5
match Error /\s\+$/
Do you have any idea ?
Thank you very much for your help.
Pierre
You should have read :help paste before adding set paste to your ~/.vimrc:
When the 'paste' option is switched on (also when it was already on):
... skipped ...
- 'autoindent' is reset
... skipped ...
These options keep their value, but their effect is disabled:
... skipped ...
- 'cindent'
'paste' is very toxic and should never be added to one's ~/.vimrc. See :help pastetoggle and/or use p instead.
Some information:
autoindent does nothing more than copy the indentation from the previous line, when starting a new line. It can be useful for structured text files, or when you want to control most of the indentation manually, without Vim interfering.
autoindent does not interfere with other indentation settings, and some file type based indentation scripts even enable it automatically.
smartindent automatically inserts one extra level of indentation in some cases, and works for C-like files. cindent is more customizable, but also more strict when it comes to syntax.
smartindent and cindent might interfere with file type based indentation, and should never be used in conjunction with it.
When it comes to C and C++, file type based indentations automatically sets cindent, and for that reason, there is no need to set cindent manually for such files. In these cases, the cinwords, cinkeys and cinoptions options still apply.
Generally, smartindent or cindent should only be set manually if you're not satisfied with how file type based indentation works.
If you plan on using file type based indentation, don't set smartindent or cindent. You may still set autoindent, since it doesn't interfere.

Resources