Map leader not working for the c.vim plugin - vim

I am trying to include the c.vim plugin into my Vim.
Somehow it doesn't recognize, that I changed the mapleader to , and still uses \
I figure, that the problem is hidden somewhere in my .vimrc, so I'll attach it.
Any help will be really appreciated!
"####################################################
" Basic Settings
"####################################################
"Set the Mapleader
let mapleader=","
"Setzt den Localleader
let localleader="-"
"Aktiviert Plugins
filetype plugin on
source ~/.vim/ftplugin/c.vim
"Neue Dateien werden beim erstellen gespeichert
autocmd BufNewFile * :write
"####################################################
" Various Settings
"####################################################
" Complete options (disable preview scratch window)
"set completeopt = menu, menuone, longest
" Limit popup menu height
"set pumheight = 15
" SuperTab option for context aware completion
let g:SuperTabDefaultCompletionType = "context"
" Disable auto popup, use <Tab> to autocomplete
let g:clang_complete_auto = 0
" Show clang errors in the quickfix window
let g:clang_complete_copen = 1
"Automatic VIMRC update when VIMRC is written
au! BufWritePost .vimrc source %
"####################################################
" Basic Maps
"#####################################################
"interpreting ii as <ESC>
inoremap ii <ESC>
"cnoremap jj <c-c>
",v opens .vimrc in a new window
noremap <leader>v :e $MYVIMRC<CR><C-W>
"Y yanks to the end of the line
nnoremap Y y$
"shorcut for copying line to clipboard
nnoremap <leader>y "*y
nnoremap <leader>p "*p
"word around the cursor is capitalized
inoremap <c-u> <ESC>BvWU<ESC>Ea
"H moves the cursor to the begining of the line, L to the end
nnoremap H 0
nnoremap L $
"LustyJuggler is activated with ,b
nnoremap <silent> <leader>b :LustyJuggler<CR>
"mark a word in visual mode
vnoremap <leader>a <ESC>bve
"#################################################
" C++ - Settings
"#################################################
"#################################################
" Various Settings
"################################################
"Spellcheking in German
set spelllang=de
set spellfile=~/.vim/spell.de.utf-8.add
nnoremap <leader>s :setlocal spell! spelllang=de
"Change the directory to the one of the current file
autocmd BufEnter * lcd %:p:h

According to the help for c.vim
The proper way to change the mapleader for this plugin is to set g:C_MapLeader
This is copied from c.vim's help. (:h csupport-usage-vim)
Changing the default map leader '\'
-----------------------------------
The map leader can be changed by the user by setting a global variable in the
file .vimrc
let g:C_MapLeader = ','
The map leader is now a comma. The 'line end comment' command is now defined
as ',cl'. This setting will be used as a so called local leader and influences
only files with filetype 'c' and 'cpp'.
Also you should not need source ~/.vim/ftplugin/c.vim in your vimrc. This should be done for you.

Related

vim's fuzzyfinder plugin opens file with name of the whole directory

I am using the vim editor and I have some trouble with the FuzzyFinder I get from here.
So I have a project called
~/project/
In the project, there is a
project/src/
and
project/build/
and a project/tags file. I created the tags file with
cd project
ctags -R --extra=+f
so to use the fuzzyfinder, I open some source file of the project:
$ vim project/src/app/src/main.cpp
and from there I try to do a fuzzyfind
:FufTaggedFile
to find my_class.cpp somewhere in my project folder. It is found by fuzzyfinder in src/myLibrary/src/my_class.cpp but when I hit enter it opens a file named
src/myLibrary/src/my_class.cpp
into the directory
~/project/src/app/src/
but doesn't open the file I would like him to open which is :
~/project/myLibrary/src/my_class.cpp
Do you know what can go wrong here?
edit
My ~/.vimrc
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()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" YouCompletMe for autocompletion
Plugin 'https://github.com/Valloric/YouCompleteMe'
"Conque-GDB
Plugin 'vim-scripts/Conque-GDB'
"FuzzyFinder
Plugin 'vim-scripts/FuzzyFinder'
"AutoTag
Plugin 'https://github.com/craigemery/vim-autotag'
"vim airline
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
"solarized color theme
"Plugin 'git://github.com/altercation/solarized.git'
"Bundle 'altercation/vim-colors-solarized'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
"options for ConqueGdb
"vem we close ConqueGdb, it also closes the split
let g:ConqueTerm_CloseOnEnd = 1
"set the line number"
set number
"hilight the word we search for with the / command
set hlsearch
"set relative numbering
set relativenumber
"set the tags file
set tags=./tags;
"set tags=tags;
"remappings
"save with ctrl+s
noremap <silent> <C-S> :update<CR>
vnoremap <silent> <C-S> <C-C>:update<CR>
inoremap <silent> <C-S> <C-O>:update<CR>
"dont allow the arrows for mooving
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
"automatic bracket seeting
inoremap ( ()<Esc>i
"inoremap { {<cr>}<c-o>O
inoremap [ []<Esc>i
inoremap < <><Esc>i
syntax on
"FuzzyFinder remappings
noremap ,f :FufFileWithCurrentBufferDir<CR>
noremap ,b :FufBuffer<CR>
noremap ,t :FufTaggedFile<CR>
"go out of a parenthesis with ctrl+a
inoremap <C-e> <C-o>A
"no swap files
set noswapfile
"set term=screen-256color-bce
"set t_Co=256
"set solarized theme in vim
set background=dark
colorscheme solarized
"set solarized theme for vim-airline
let g:airline_theme='solarized'
"Enable the list of buffers
let g:airline#extensions#tabline#enabled = 1
" Show just the filename
let g:airline#extensions#tabline#fnamemod = ':t'
"automatically change the current directory
"set autochdir
"set noautochdir
~/project/src/app/src/myLibrary/src/my_class.cpp is probably opened because it's closer to your current location.
Maybe you have autochdir on or there's an option that tells your plugin how to behave in such a circumstance? You should read its documentation to be sure.

How to handle my vim local variable(omnifunc, ...), it is not set as i wrote in vimrc

I use omnicomplete in VIM and my vimrc is like below.
snipping...
" Autocompletion
set completeopt=longest,noselect,menuone
set omnifunc=syntaxcomplete#Complete
autocmd FileType py set omnifunc=python3complete#Complete
But, when I restart vim. omnifunc doesn't work as i set, even value is different from my vimrc settings
I thought my restoring option was problem. However, block below settings.
" Save and load former states
"autocmd BufWinLeave ?* mkview
"autocmd BufWinEnter ?* silent loadview
It still doesn't work...
How can I resolve it?
Appreciate all your help.
EDIT on 2017.11.08 > Here is my full .vimrc file
syntax on
set nocp " no compatibility with VI
set nu " line number
set cursorline " highlight current cursorline
set ruler " display cursor position information at status line
set ic " case insensitive search
set smartcase " don't use ic when there is Capital letter
set hlsearch " hilight search
set incsearch " show search matches as type
set mouse=a " enalbe cursor move with mouse
set ts=4 " size of \t character (tab stop)
set sw=4 " tab size, when use <<, >>
set sts=4 " how many spaces, when type tab (soft tab stop)
set ls=2 " last window's status line option
set expandtab smarttab
set autowrite " Automatically :write before running commands
set autoread " Auto read when a file is changed on disk
set autoindent
set smartindent
set cindent
set vb noeb " visual bell instead of beep
set tm=500 ttm=0 " to leave insert mode without delay
set encoding=utf8
" Autocompletion
set completeopt=longest,noselect,menuone
set omnifunc=syntaxcomplete#Complete
autocmd FileType py set omnifunc=python3complete#Complete
" Cursor shape
let &t_SI = "\e[5 q" " Start Insert mode
let &t_EI = "\e[0 q" " End Insert mode
" Key mapping
nnoremap <F2> :!ctags -R -I --languages=C,C++ --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
nnoremap <F3> :NERDTreeToggle<CR>
nnoremap <F4> :TlistToggle<CR>
nnoremap <F5> <C-w>=
nnoremap Y y$
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
inoremap <C-b> <C-Left>
inoremap <C-f> <C-Right>
inoremap <C-a> <Esc>I
inoremap <C-e> <End>
inoremap <C-#> <C-x><C-o>
autocmd FileType c,h,cpp,hpp inoremap {<ENTER> {}<Left><ENTER><ENTER><UP><TAB>
" Save and load former states
autocmd BufWinLeave ?* mkview
autocmd BufWinEnter ?* silent loadview
" C/C++ header
function! s:header()
let name = "__".toupper(substitute(expand("%:t"), "\\.", "_", "g"))."__"
exe "norm! i#ifndef ". name "\n#define ". name "\n\n\n\n#endif\t//". name "\ekk"
endfunction
autocmd BufNewFile *.{h,hpp} call <SID>header()
" Python header
function! s:py_init()
exe "norm! i\n\n\ndef main():\npass\n\n\eIif __name__ == \"__main__\":\n\tmain()\n\egg"
endfunction
autocmd BufNewFile *.py call <SID>py_init()
" Plugin settings using Vundle
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'tpope/vim-fugitive'
Plugin 'scrooloose/nerdtree'
Plugin 'taglist-plus'
Plugin 'nanotech/jellybeans.vim'
call vundle#end()
filetype plugin indent on
" airline settings
set laststatus=2
let g:airline#extensions#tabline#enabled=1 " turn on buffer list
let g:airline_theme='murmur'
let g:airline_powerline_fonts=1
let g:airline#extensions#branch#enabled=1
" NERDTree settings
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let g:NERDTreeDirArrowExpandable='+'
let g:NERDTreeDirArrowCollapsible='~'
" taglist settings
let Tlist_Use_Right_Window=1
" Color settings with bundle theme (type help highlight in order to see color list)
if has("gui_running")
colo industry " industry, torte, koehler
else
colo slate " slate, koehler, ron, elflord, pablo
endif
colo jellybeans
highlight linenr ctermfg=brown ctermbg=NONE
highlight cursorlinenr ctermfg=green ctermbg=NONE
highlight cursorline cterm=underline
You can find out where an option was last set via
:verbose set omnifunc?
It looks like your problem is caused by a wrong filetype in your :autocmd. Though Python files usually have a *.py extension, the filetype in Vim is named python. So, this should work:
autocmd FileType python set omnifunc=python3complete#Complete
Additional critique
I would recommend putting the settings and mappings into ~/.vim/after/ftplugin/python.vim instead of defining lots of :autocmd FileType python; it's cleaner and scales better; requires that you have :filetype plugin on, though.
By using :set, the value of 'omnifunc' will be inherited by other buffers that are opened from a Python one (e.g. via :new). Usually, this is not what you want. Use :setlocal omnifunc=... instead.

Lagging response from homerow movement keys in visual mode

When I use the hjkl movement keys (hnei for me, as I've mapped these keys to work with the colemak layout) in normal mode, they move perfectly fine without any noticeable delay. However, in visual mode, the key corresponding to moving right ("i" for me), causes a really annoying lag. I have a feeling that one of the plugins I installed may have mapped a command to be a combination of "i" and another key, but I can't find it anywhere. Why is this lag happening? More specifically, am I missing something in my vimrc or plugins that may be conflicting with my movement mappings?
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Plugin 'gmarik/vundle'
Plugin 'scrooloose/nerdtree'
Plugin 'tpope/vim-surround'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'kchmck/vim-coffee-script'
Plugin 'tpope/vim-repeat'
Plugin 'kien/ctrlp.vim'
Plugin 'tomtom/tcomment_vim'
Plugin 'bling/vim-airline'
Plugin 'godlygeek/tabular'
Plugin 'tomasr/molokai'
Plugin 'ervandew/supertab'
Plugin 'kien/rainbow_parentheses.vim'
Plugin 'docunext/closetag.vim'
Plugin 'mattn/emmet-vim'
" HNEI arrows. Swap 'gn'/'ge' and 'n'/'e'.
noremap n gj|noremap e gk|noremap i l|noremap gn j|noremap ge k
nnoremap <silent> jj :noh<CR>
let g:mapleader=","
noremap <space> i
" Last search.
nnoremap k n
nnoremap K N
" BOL/EOL/Join Lines.
noremap l ^|noremap L $|noremap <C-l> J
" _r_ = inneR text objects.
onoremap r i
" Switch tabs.
nnoremap <C-i> <C-PageDown>|nnoremap <C-h> <C-PageUp>
" SwiS1S1tch panes.
noremap H <C-w>h|noremap I <C-w>l|noremap N <C-w>j|noremap E <C-w>k
" Scroll up/down.
noremap = <C-y>|noremap - <C-e>
nnoremap ; :
nnoremap : ;
inoremap jj <Esc>
noremap U <C-r>
nnoremap + <C-a>|nnoremap - <C-x>
noremap ' `|noremap ` '
vnoremap s S
nnoremap <CR> o<Esc>
noremap _ <c-_><c-_>
vnoremap <Leader>a :Tabularize /:<CR>
" Vim Display.
set t_Co=256
set shortmess+=I
set display+=lastline
set showtabline=1
set backspace=2
set textwidth=0
" Text Display.
syntax on
set number
set guicursor+=a:blinkon0
set hlsearch
set wrap
set lbr
set showbreak=···\
" Two-space tabs.
set expandtab
set smarttab
" Editing.
set autoindent
set whichwrap+=<,>,h,l,b,s,[,]
set splitbelow|set splitright
" Searching and matching.
set incsearch
set ignorecase|set smartcase
set gdefault
set showmatch
" System.
filetype plugin indent on
set mouse=a
set t_RV=1
set history=1000
set wildmenu
set wildmode=longest,full
au BufEnter * set ignorecase
set nohidden
set laststatus=2
let g:EasyMotion_do_mapping = 0
nmap f <Plug>(easymotion-s)
let g:EasyMotion_smartcase = 1
nnoremap <silent> <Leader><Leader> :NERDTreeTabsToggle<CR>
:verbose vmap i
will tell you all visual mode mappings starting with i (and where it got defined, so you can identify the plugin). As most "inner" text objects start with i and are also available in visual mode, this conflict is indeed likely.

IndentLine vim plugin not working

Hey so I'm having trouble getting IndentLine working and I can't seem to figure out what's wrong...I added both the entire directory to my bundle (because I use Pathogen) and the indentLine.vim script to my .vim folder directly with no luck. I'm on Vim 7.3, and here's my .vimrc
syntax on
set number
set mouse=a
set ruler
set smartindent
set shiftwidth=2
set softtabstop=2
set expandtab
set colorcolumn=100
set foldmethod=indent
set nofoldenable
set tags=./tags;
set background=light
set mouse=niv
set clipboard=unnamed
let g:tagbar_left = 0
let g:tagbar_autoshowtag = 0
"autocmd VimEnter * nested :call tagbar#autoopen(1)
autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
autocmd WinEnter * call s:CloseIfOnlyNerdTreeLeft()
" Close all open buffers on entering a window if the only
" buffer that's left is the NERDTree buffer
function! s:CloseIfOnlyNerdTreeLeft()
if exists("t:NERDTreeBufName")
if bufwinnr(t:NERDTreeBufName) != -1
if winnr("$") == 1
q
endif
endif
endif
endfunction
execute pathogen#infect()
nmap <F8> :TagbarToggle<CR>
noremap i l
noremap n h
noremap e j
noremap u k
noremap k n
noremap f s
noremap l {
noremap m }
noremap r m
noremap t u
noremap s i
inoremap <C-v> <C-r>"
inoremap <Esc> <Esc>:w<CR>
nmap ^[> :vertical res +1^M
nmap ^[< :vertical res -1^M
nmap ^[+ :res +1^M
nmap ^[- :res -1^M
let g:indentLine_char = '│'
let g:indentLine_color_term = 000
Any help would be greatly appreciated!
Edit: here's the link to the script on github https://github.com/Yggdroot/indentLine
First you should check if the problem is in your configurations. You could comment all lines on your .vimrc and check if the plugin works; then remove all files from your ~/.vim except the IndentLine plugin.
In case the plugin works, you can insert parts of your configuration until it stops working again, so you can understand what is broking it.
If you are unable to make the plugin work you should follow romainl advice and report to the plugin's author.
Edit:
From the plugin readme:
This plugin is used for displaying thin vertical lines at each indentation
level for code indented with spaces. For code indented with tabs I think there
is no need to support it, because you can use :set list lcs=tab:\|\ (here is a
space).
If you are using tabs for indent then the plugin will not work, so you will have to issue :set expandtab or leave that line uncommented on your .vimrc.
Try performing the following steps:
with a fresh new installation of Vim/gVim, create an empty file on your home and name it .vimrc
extract the downloaded plugin to home directory and renamed it to .vim
open gVim, issue :set et
enter the following text: ifentertabifentertabtabreturn
If the plugin works, you should end with something like this:
if
if
| return
, where the | is not typed, but inserted by the plugin.

Vim Question: Sparkup doesn't work for files opened from a running Vim session

If I were to open a file with Vim from the command prompt (eg: vim ~/.vimrc), the Sparkup text generation seems to work perfectly fine. For example if I insert:
html:xs
and then push control + e, sparkup generates a nice HTML strict boilerplate. However if I then split to another file from the running Vim session, Sparkup stops working in the newly opened file. It's totally possible that other plugins lose their functionality as well. Here is my .vimrc file:
set nocompatible " use vim defaults
set number " show line numbers
set tags=tags;$HOME/.vim/tags/ "recursively searches directory for 'tags' file
set expandtab " tabs are converted to spac
set tabstop=4 " numbers of spaces of tab character
set shiftwidth=4 " numbers of spaces to (auto)indent
set showcmd " display incomplete commands
set incsearch " do incremental searching
set ruler " show the cursor position all the time
set numberwidth=4 " line numbering takes up 5 spaces
set ignorecase " ignore case when searching
set nowrap " stop lines from wrapping
set incsearch " show search matches as you type
call pathogen#helptags()
call pathogen#runtime_append_all_bundles()
filetype on " enables filetype detection
filetype plugin on " enables filetype specific plugins
filetype plugin indent on " Loads pyflake-vim's ftplugin files automatically when a Python buffer is opened
syntax on " syntax highlighing
colorscheme default
nmap <silent> <c-y> :NERDTreeToggle<CR>
nmap <silent> <c-o> :OpenBookmark
" TagList Plugin Configuration
let Tlist_Ctags_Cmd='/usr/bin/ctags' " point taglist to ctags
let Tlist_GainFocus_On_ToggleOpen = 1 " Focus on the taglist when its toggled
let Tlist_Close_On_Select = 1 " Close when something's selected
let Tlist_Use_Right_Window = 1 " Project uses the left window
let Tlist_File_Fold_Auto_Close = 1 " Close folds for inactive files
" Omnicompletion functions
set ofu=syntaxcomplete#complete
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
au FileType py set expandtab
map <F2> :previous<CR> " map F2 to open previous buffer
map <F3> :next<CR> " map F3 to open next buffer
map <F5> :TlistToggle<CR> " map F5 to toggle the Tag Listing
map <silent><C-Left> <C-T> " taglist - map Ctrl-LeftArrow to jump to the method/property under your cursor
map <silent><C-Right> <C-]> " taglist - map Ctrl-RhitArrow to jump back to your source code
" Easy window navigation
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" When vimrc is edited, reload it
autocmd! bufwritepost vimrc source ~/.vim_runtime/vimrc
highlight SpellBad term=reverse ctermbg=Gray ctermfg=Red
And here are some other plugins I have inside ~/.vim/bundles:
IndexedSearch nerdtree snipmate.vim vim-css-color vim-git vim-rails vim-ruby-debugger vim-supertab vim-tcomment
gist pyflakes-vim textile.vim vim-cucumber vim-haml vim-repeat vim-shoulda vim-surround vim-vividchalk
jquery pysmell vim-align vim-fugitive vim-markdown vim-ruby vim-sparkup vim-taglist
Can it be that this plugin is bound to a given FileType and that when you change window the FileType is not the same?
If it doesn't work, try adding your plugin to ftplugins.

Resources