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.
Related
I tried most of the suggestions in those three questions:
Get rid of Vim's highlight after searching text
How to get rid of search highlight in Vim
Vim clear last search highlighting
It's mainly the :noh, and it works when I type it manually. I just want it happen on BufWrite, so I tried multiple ways, none of which worked:
function! RemoveHighLight()
:noh
endfunction
autocmd BufWrite * :call RemoveHighLight()
autocmd BufWrite * :noh
autocmd BufWrite * :execute "normal! :noh\<cr>"
Debuging echoms and adebug\<esc> in the function and in the third autocmd show that they execute successfully, just the :noh has no effect.
(Also tried :let #/ = "" which worked but it clears the search pattern, which is not I'm looking for. I just want to get rid of the highlight til pressing n or similar)
Using BufWritePost doesn't have effect, either.
It is a workaround but you can set nohlsearch by autocmd. Then you can add a mapping to set it back by n and N.
au BufWrite * set nohlsearch
nnoremap <silent> n n:set hlsearch<CR>
nnoremap <silent> N N:set hlsearch<CR>
Or maybe better, check if it is already set
au BufWrite * set nohlsearch
nnoremap <silent> n n:call ToggleHlBack()<CR>
nnoremap <silent> N N:call ToggleHlBack()<CR>
function! ToggleHlBack()
if &hlsearch == 'nohlsearch'
set hlsearch
endif
endfunction
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.
Is there a way to switch between two .vimrc settings with a command?
Say I have in my vimrc:
* Settings 1
setlocal formatoptions=1
setlocal noexpandtab
map j gj
map k gk
* Settings 2
setlocal formatoptions=2
map h gj
map l gk
And I want to be able to change between Settings 1 and 2, say by typing :S1 or :S2
The reason for this is that I want to have settings that I use while coding and another set while writing.
What's the best way to accomplish this?
You can create the :S1 and :S2 commands using :h :command. Type these commands to functions and make sure the settings cancel each other out. For instance...
command! S1 call Settings1()
command! S2 call Settings2()
fun! Settings1()
setlocal formatoptions=1
setlocal noexpandtab
silent! unmap <buffer> h
silent! unmap <buffer> l
nnoremap j gj
nnoremap k gk
endfun
fun! Settings2()
setlocal formatoptions=2
setlocal expandtab
silent! unmap <buffer> j
silent! unmap <buffer> k
nnoremap h gj
nnoremap l gk
endfun
If you don't want to make the settings cancel out, the simplest solution may be to restart vim with a different configuration file. You could also use set option! to toggle options and the mapclear commands to clear mappings. However, you'll have to get specific for options like formatoptions that can't be toggled. You could reset these to the default with set option&.
You can however reset all options to the default with :set all&. Using this you could, for instance, have Settings1() call :set all& and source $MYVIMRC. Then Settings2() could also call them and then set various options. For example...
" tons of settings
command! S1 call Settings1()
command! S2 call Settings2()
fun! Settings1()
set all&
mapclear
source $MYVIMRC
endfun
fun! Settings2()
set all&
mapclear
setlocal formatoptions=2
setlocal expandtab
nnoremap h gj
nnoremap l gk
endfun
I'm running MacVim with MiniBufExplorer amongst some other plugins. What I have noticed is that occasionally when I edit a file and try to write it (:w), I get the message
--No lines in buffer--
If I then enter :w again the file writes successfully. It seems to sprout up randomly but once it starts happening it continues to happen with every file in the buffer until I close/restart MacVim.
EDIT:
Plugins currently used:
Pathogen
Ack
Command-T
MiniBufExpl
Nerdtree
Pep8
Pydoc
Ropevim
Supertab
Tagbar
Current .vimrc
filetype off
call pathogen#infect()
call pathogen#helptags()
set foldmethod=indent
set foldlevel=99
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
syntax on
filetype on
filetype plugin indent on
au FileType python set omnifunc=pythoncomplete#Complete
let g:SuperTabDefaultCompletionType = "context"
set completeopt=menuone,longest,preview
map <leader>n :NERDTreeToggle<CR>
map <leader>j :RopeGotoDefinition<CR>
map <leader>r :RopeRename<CR>
map <leader>o :TagbarToggle<CR>
nmap <leader>a <Esc>:Ack!
autocmd BufEnter *.py set ai sw=4 ts=4 sta et fo=croql
colorscheme desert
map J 15j
map K 15k
set noswapfile
set nobackup
set nowritebackup
For me the problem was caused by minibufexplorer. The fix has been included in v6.5.0 of fholgado, consisting of inserting the silent keyword below in minibufexpl.vim
" Delete all lines in buffer.
silent 1,$d _
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.