I use NerdTree Plugin and have set cursorcolumn in my vimrc file, but I don't want a column highlight in the NerdTreePlugin window, How can I do that?
Also, I do not want signs column show in the nerdtree window, how can I do that?
Much more common question, how to set or disable a specific option for a specific plugin window, e.g. NerdTree or Tagbar?
If you want cursorcolumn in all buffers except for a few, use an autocmd in your vimrc to disable it for specific buffers, using setlocal.
For instance:
autocmd FileType nerdtree setlocal nocursorcolumn
Related
I would like to set up VIM for Cobol development and wanted to have the lines form column 7 to 11 marked so as to indicate the code areas. However, when I added this line of code in my vimrc file it colorized the NERDTree too.
set colorcolumn=7,11,73,80
autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
How can I make the NERDTree columns not colorized and keep colorization only on the working file?
With the following line in your vimrc:
set colorcolumn=7,11,73,80
you define a global value for a window-local option which is reused for every new window. It is set for the 1st window, which passes it on to the 2nd window, etc.
Since that specific value for that specific option only is to be applied to Cobol buffers, you are supposed to use Vim's built-in filetype plugin support:
Make sure you have either of those lines in your vimrc:
filetype plugin on
filetype plugin indent on
filetype indent plugin on
See :help :filetype.
Create after/ftplugin/cobol.vim under your Vim runtime. On a typical Unix system, it should look like this:
$HOME/.vim/after/ftplugin/cobol.vim
And add the line below:
setlocal colorcolumn=7,11,73,80
We use :help :setlocal to make sure that the option won't be passed on to other windows.
This is my .vimrc:
set tabstop=2 softtabstop=0 shiftwidth=2 smarttab
set number
map <F5> :tabp<CR>
map <F6> :tabn<CR>
map <F7> :e %<.cpp<CR>
map <F8> :e %<.h<CR>
map <C-F7> :e %<.vs<CR>
map <C-F8> :e %<.fs<CR>
map <F9> :w<CR>:!./m<CR>
map <F10> :w<CR>:!./%<CR>
let &path.="/home/dirk/projects/dirk/common,/home/dirk/projects/dirk/sp33d,./proj/tmp,./shaders,"
au BufRead *.fs set ft=
au BufRead *.vs set ft=
" Show tabs in light color
hi GroupTabs ctermfg=lightgray
match GroupTabs /\t/
set listchars=tab:>-
set list
My post is about the "Show tabs in light color" part. When I open a file with vim, it does this graying out of the tabs correctly.
However, I like to use multiple tabs, so when I open extra files with the :tabe command or with the -p parameter when starting vim, the graying out of the tabs only works on the first tab, not on other tabs.
I tried opening the files on the other tabs alone and then it works.
Is there something about tabs I don't know? Is there a way to make the graying work on the other tabs as well?
The files I usually work on are cpp, h, py, lua, html, css, ..., they all have this issue, so I guess it has nothing to do with file type specific syntax highlighting?
Any help is appreciated.
Is there something about tabs I don't know?
At least two things:
they are not "tabs" but "tab pages",
your problem is not related to tab pages.
Is there a way to make the graying work on the other tabs as well?
The very first sentence of :help :match is:
Define a pattern to highlight in the current window.
which means that your :match command only impacts the current window and won't have any effect on other windows. Since :tabedit and friends create new windows there's no reason whatsoever to expect your :match to work there too.
For custom matches to work across windows, you need to use :help matchadd() in an autocommand:
augroup CustomMatches
autocmd!
autocmd winEnter,BufEnter * call clearmatches() | call matchadd('GroupTabs', '\t', 100)
augroup END
But…
Vim already has an highlight group for those leading tabs:
hi SpecialKey ctermfg=lightgray
so there's no need for any of that in the first place.
The question is really simple, when i run TagbarToggle i want the cursorline option to be True in that window (if it is in the "main" window).
something like:
if &cursorline
call set_cursorline_in_tagbar()
endif
Of course i could just set it manually every time, but that's just not the Vim way.
It looks like TagBar sets its own FileType: tagbar, this could be used in an autocmd:
autocmd FileType tagbar setlocal cursorline
Another option would be to set a custom highlighting for TagBar's own syntax groups that fits your need, as shown in the documentation.
I managed to fix it, for some reason TagBar sets nocursorline in the initWindow() function
I simply replaced it with cul. And now everything is working as it should.
But why would he set nocursorline?
I noticed that with different colorschemes VIM is underlining/highlighting some words. Why is this and how to turn it off ?
with another colorscheme
I'm using spf13-vim configuration and connecting remotely with Putty.
VIM is correctly assuming this file to be a python file (:set filetype returns "python")
It seems like your Vim is doing spell-checking for you. You can turn this off by adding
set nospell
in your .vimrc file. To turn it back on in a file, you can do:
:setlocal spell spelllang=en_us
for spell-checking with American English. :setlocal changes settings for current buffer, while :set makes the changes for all currently open buffers. You can read more about how spell-checking with Vim works here.
It may be useful for you to automatically enable spell checking for certain files. For example, to enable spell checking in .tex files, you can add the following to your .vimrc:
" Enable spell checking when opening .tex files
autocmd!
au BufNewFile,BufRead *.tex setlocal spell spelllang=en_us
" Or if you have filetype detection enabled:
" au FileType tex setlocal spell spelllang=en_us
Note that autocmd! clears the previously defined au commands and is needed only once.
Most filetypes (like python) in Vim come with a syntax that defines highlight groups (see them via :highlight). A colorscheme then provides combinations of foreground / background color and/or formatting like bold and italic, for terminals, color terminals, and/or GVIM.
Choose a colorscheme that you find visually appealing; some come with Vim, many more can be found on the Internet, most at http://www.vim.org/.
If you're just annoyed by one or two minor things in a particular colorscheme, you can modify the items via the :highlight command. To disable a highlighting, use, e.g.
:highlight clear Statement
or (when the group is linked to another group, effectively inheriting its appearance)
:highlight link Statement NONE
(These must be issued after the :colorscheme command that sets your preference.)
I have came across two kinds of highlight that I don't like.
1.indent highlight and tab arrow reminder, you can solve it by adding
let g:indent_guides_enable_on_vim_startup = 0
set nolist
to ~/.vimrc.local
2.highlight the usual words, like Chinese words and wrong spell words, you can solve it by adding
set nospell
to ~/.vimrc.local
I would like to have a higher number in my linespace setting for markdown files for easier reading. I thought I'd do in my .vimrc:
au FileType markdown setlocal linespace=4
But no luck. The locality of the setting is ignored and linespace is applied to all buffers (even Python and Javascript files).
I'm using Pope's markdown.vim plugin to provide the markdown filetype.
Ideas?
Actually linespace is a global option (see :h linespace). Your auto command
is working, but even though it's using :setlocal, the option can't be applied to
a specific buffer or window; acting as if you had used :set.
Update
If you want to change the linespace option based on your current buffer, basically
all you need to do is changing your current auto-command from
au FileType markdown setlocal linespace=4
To
au BufEnter *.markdown setlocal linespace=4
The difference is that now the command will be auto called when you enter a buffer
that has a file name ending with .markdown (change this pattern to match your
usual mardown extension).
To reset the option, add the following auto-command as well to your .vimrc:
au BufLeave *.markdown setlocal linespace=2
It will set the linespace option to 2 (or whatever value you want) once you leave
a buffer containing a markdown file.