I installed both plugins using Pathogen, but they don't work together as it should be. That is, if I use TAB, I get SuperTab's completion (autocomplete what I have previously written) whereas if I use CTRL + SPACE I get Jedi's completion (everything from libs: classes, modules, etc).
In theory, if both plugins are installed SuperTab should handle Jedi seamlessly, but that's not my case. I found this report of some people experiencing the same behavior, while others saying it works for them. There is no solution provided though.
The plugins I'm using don't override each other:
ls ~/.vim/bundle/
auto-pairs nerdtree syntastic vim-trailing-whitespace
jedi-vim supertab vim-airline
So what else may be causing this behavior?
vimrc:
set nu
set ts=4
set sw=4
set mouse=a
set showmatch
set expandtab
set background=dark
syntax on
filetype plugin indent on
execute pathogen#infect()
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
Found the root of the problem. SuperTab wasn't working in OmniCompletion mode.
let g:SuperTabContextDefaultCompletionType = "<c-x><c-o>"
Related
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!
Here is my ~/.vimrc file. My indentation works for vim, but does not work for MacVim. Every time I open MacVim and try scripting in python I have to click Edit --> File Settings --> Shiftwidth --> 2
What corrections do I need to make to my ~/.vimrc file? I even considered making an exact replica of my ~/.vimrc file and called it ~/.mvimrc.
1 set nocompatible
2
3 execute pathogen#infect()
4 syntax on
5 filetype plugin indent on
6 set noai ai
7 set nosi si
8 set nosta sta
9 set shiftwidth=2
10 set softtabstop=2
11 set ts=2
12 set expandtab
13 set number
14
15 set statusline+=%#warningmsg#
16 set statusline+=%{SyntasticStatuslineFlag()}
17 set statusline+=%*
18
19 let g:syntastic_always_populate_loc_list = 1
20 let g:syntastic_auto_loc_list = 1
21 let g:syntastic_check_on_open = 1
22 let g:syntastic_check_on_wq = 0
23
"~/.vimrc" [readonly] 31L, 589C
In the past, the Python ftplugin only took care of "generic" stuff but a semi-recent update added indentation settings in an effort to enforce PEP8 compliance:
" As suggested by PEP8.
setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8
A clean way to override those settings would be to add the lines below to ~/.vim/after/ftplugin/python.vim:
setlocal shiftwidth=2
setlocal softtabstop=2
A few comments about your vimrc:
set nocompatible generally useless, remove this line
set noai ai needlessly complex and ambiguous, use set autoindent
set nosi si smartindent is useless, remove this line
set nosta sta needlessly complex and ambiguous, use set smarttab
set ts=2 useless, 'tabstop' should be left at its default value
Do your plugins and other settings load in macvim, or is it having issues detecting your .vimrc completely? If it's completely not finding it, you might want to check this question and see if you can fix it. If it's only happening to python, is it possible you have a plugin that is changing shiftwidth? If so you may want to look into using after to do it.
If your vimrc is loading, you might want to try doing this to set the shiftwidth to 2 for python files only...
You can use Autocommand to detect that you are editing a .py filetype and change shiftwidth.
autocmd Filetype py setl shiftwidth=2
Above that line, you may need to put this:
filetype on
Put both these in your vimrc to make it work.
Pretty self explanatory, but just to spell out what it does, when it detects a .py file, it sets the shift width to 2. Setl is shorthand for setlocal (to the buffer).
I have just started using Vim on a Linux distribution -- Elementary OS. In Vim, CTRL-V appears to be mapped to paste instead of taking me to block visual mode. How do I reverse this? I'm pretty sure I didn't configure vim to behave this way and from what I've read so far this should only happen in MS Windows.
Edit: Contents of .vimrc
" 1. Pathogen (plugins autoloader)
execute pathogen#infect()
syntax on
filetype plugin indent on
" 2. Documentor
au BufRead,BufNewFile *.php inoremap <buffer> <C-P> :call PhpDoc()<CR>
au BufRead,BufNewFile *.php nnoremap <buffer> <C-P> :call PhpDoc()<CR>
au BufRead,BufNewFile *.php vnoremap <buffer> <C-P> :call PhpDocRange()<CR>
let g:pdv_cfg_Package = 'FPP Labs Package'
let g:pdv_cfg_Author = 'Gboyega Dada <gboyega#fpplabs.com>'
let g:pdv_cfg_ClassTags = ["package","author","version"]
" 3. Syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" 4. Tab stops
set tabstop=4
set shiftwidth=4
set expandtab
This is not really a vim Issue.
Elementary OS uses their own terminal called Pantheon Terminal, which uses CTRL+C/CTRL+V for copying/pasting. This prevents the shortcut from being passed on to vim.
You should change the terminal to some other application, or change this behavior in the terminal settings.
Here's some blog with more info that I just found:
http://lmelinux.net/2014/12/06/ctrlc-will-copy-text-clipboard-elementarys-terminal/
The part that is interesting for you is:
Elementary developers are also aware that some people will not be happy with this change that’s why there will be a new gsettings key at org.pantheon.terminal.natural-copy-paste where one can disable this behavior.
I installed YouCompleteMe using vundle.
Then installed all plugins and installed YCM using
./install.sh --clang-completer
This is how my vimrc looks:
syntax on
set expandtab
set cindent
set tabstop=4
retab
set shiftwidth=4
set hlsearch
set paste
set ic
set number
colorscheme molokai
set t_Co=256
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-repeat'
Plugin 'kien/ctrlp.vim'
Plugin 'sjl/gundo.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'scrooloose/syntastic'
Plugin 'Valloric/ListToggle'
call vundle#end() " required
filetype plugin indent on
"options for syntastic"
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_python_checkers=['pep8', 'pylint', 'python']
let g:syntastic_enable_signs=1
let g:syntastic_auto_loc_list=1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 1
let g:syntastic_error_symbol = "X"
let g:syntastic_style_error_symbol = ">"
let g:syntastic_warning_symbol = "!"
let g:syntastic_style_warning_symbol = ">"
let g:syntastic_echo_current_error=1
let g:syntastic_enable_balloons = 1
let g:syntastic_auto_jump=1
"Gundo options"
nnoremap <F5> :GundoToggle<CR>
"CtrlP options"
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
"Powerline stuff"
python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup
set laststatus=2
YCM works but I can't switch between the suggestions using TAB, only using Down and Up arrows and accepting with Enter.
Why is happening this? Is another program using the TAB key?
thanks a lot for the help
By configuring set paste, you're effectively disabling all mappings and abbreviations.
You only need that set when you actually paste text in terminal Vim! It's best to bind this to a key. As mappings cannot be used when the option is set, Vim provides a special option for this:
:set pastetoggle=<F10>
Further commentary
As the ~/.vimrc is sourced at the beginning of Vim startup (when files passed to it haven't yet been loaded), the retab is ineffective; just drop it. If you really want automatic reindenting for opened files, you'd have to employ an :autocmd BufRead * retab for that, but I'd advise against that.
The problem was due to the "set paste" line in my .vimrc
so, I removed it, and when I want to paste large blocks of code in vim, I just write :set paste to enable it or :set nopaste to disable it. This toggle can be also mapped to f10 or any key.
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.