In a previous post here - vim buffer Trying char-by-char conversion - I was running into a problem when opening up certain files and vim wasn't able to detect the encodings in that file and this was resolved by the solution provided by Ingo.
But after I installed vim's NERDTree plugin, I am running into the same problem again.
It appears that buffer opened by NERDTree mapping map <F2> :NERDTreeToggle<CR> does not obey the :set encoding=utf-8 directive.
I have to manually run :set encoding=utf-8 again in order for the Trying char~by-char conversion... problem to be resolved.
Also, my nerdtree directory shows up with a weird ? instead of the | symbol. Like this:-
What am I doing wrong?
I have temporarily solved this problem by mapping
map <F2> :NERDTreeToggle<CR>:set encoding=utf-8<CR>
instead of the original plain
map <F2> :NERDTreeToggle<CR>
However this solution is not good enough as the Trying char~by-char conversion warning still pops up whenever I browse open a specific directory in the NERDTree buffer.
So, I would like to hear if anyone has a better solution! Thanks!
The nerdtree ? character problem was solved by this post - vim - nerdtree suddenly broke
You shouldn't need to do anything: NERDTree doesn't manipulate encoding and encoding is a global option that you set once and for all in your ~/.vimrc. Go back to an almost empty ~/.vimrc and build from that (with encoding and other options).
Related
I have a very weird problem which did not exist in my environment before but now happened. When editing files, I'm used to doing this way:
gvim . #open current directory browsing
scroll up/down to select file, enter then edit.
ctrl-6 #back to previous directory
However one day I found the step3 was failed, it said "No alternate file".
My .vimrc file only contains:
colorscheme darkblue
set number
set autoindent
set nowrap
set ignorecase
set cursorline
I tried to clean all content in .cshrc but the same.
Can anyone tell me what's wrong with my gvim ?
Thanks in advance.
This looks to be a change in behavior introduced in Vim 7.4. The netrw view is no longer stored as an alternate file. See this discussion.
The Vim maintainers seemed split on what the correct behavior should be, but Bram himself offered up this advice with a mapping:
I do realize that editing the directory of the current file is
something I often do, but I never bothered to set up a mapping for
it. Typing ":e %:h" is not too difficult, but CTRL-O to jump back to
the netrw %directory view was easier.
I now added a mapping:
map ,d :e %:h<CR>
Let's see if I can get used to that.
Another related discussion can be found here.
You are likely using netrw to edit a directory. This is the equivalent of :Explore. Sadly netrw has a bad habit of not maintaining the alternative buffer, #. You maybe able to upgrade netrw or use :Rexplore (:Rex for short) to resume exploring.
Another option is to just use :e with wildcards and tab completion to explore files. Use <c-d> to list out completions as well.
My GVim distribution on a Windows 8.1 machine has both vimwiki and Vim-Latex-Suite installed through Vundle.
It bothers me that the following display (on the left) will occur when I do the following:
Open a *.wiki file (thereby enter the filetype vimwiki once);
In the same GVim session, open another *.tex file.
Notice that almost all those math symbols are no longer readable on the left. The quoted code-segment was displayed correctly (on the right) when opened by itself, through a new Gvim.exe session.
For this specific case, my guess is that, Vim is incapable of:
Correctly identify and display all math symbols (e.g. subscripts are displayed as a square);
Correctly displaying math symbols in full-width. (By default, half-width is default and this is why those \phi or \int are hiding all its right part.)
The goal for this post is not to "display math symbols in Vim" correctly. It is too wild and LyX can handle it pretty well. Instead, I would like to know:
How can I stop Vimwiki from interfering the display of *.tex
documents?
Any suggestion? Thank you in advance :)
Original answer from #Sato Katsura
This is the conceal feature. It works better in gVim, provided that you use a font that has all the relevant symbols. You can disable it with:
set conceallevel=0
Further details for Vimwiki
Vimwiki has specified g:vimwiki_conceallevel=2 by default according to line 2100 of the help file. Unfortunately, this "default value" was set globally for all buffers.
Specific solution:
For ~\vimfiles\ftplugin\tex.vim, add the following to the end:
setlocal conceallevel=0
For ~\vimfiles\ftplugin\vimwiki.vim, add the following to the end:
setlocal conceallevel=2
I've had the same problem what made me research until reach this mapping:
nnoremap <Leader>c :let &cole=(&cole == 2) ? 0 : 2 <bar> echo 'conceallevel ' . &cole <CR>
It toggles between conceallevel=0 to conceallevel=2
When I start vim with one of these plugins:
TagBar
Session
I see sometimes garbage characters in the buffer when I open vim.
Here are these characters:
;2R^[[>1;2802;0c
By uninstalling these two plugins, I don't see these garbage characters anymore.
If I type dd, it does not even delete these characters. Vim says the buffer is empty.
Putting this command at the end of my .vimrc is a workaround for this problem:
autocmd VimEnter * redraw!
With this, these characters are deleted immediately.
How can I fix this problem?
Vim asks the terminal for its version, what you're seeing is the response (cp. :help v:termresponse). It only appears printed in the terminal; that's why you can't "edit" it and it appears after a redraw.
Why Vim doesn't properly receive it, I don't know. Switching the terminal program might help. You could also try to suppress the query via :set t_RV= in your ~/.vimrc.
Thanks Ingo! I only get this on the mac, so for me it's
if has('mac')
:set t_RV=
endif
I switched to neovim and I've never seen this issue anymore.
I have two buffers in my vim session, and I set syntax on in my vimrc , I used minibufexpl to manage bufs.
I used :q to quit the current buf, but the other buf would auto set the syntax off, I have to use :set syntax=on to open the syntax highlight manually. Could someone give me a solution that not set the syntax off automatic after one buf quit? Thanks!! (I tried :bd to quit the buf instead of :q, sometimes it stay the syntax on but sometimes no).
If you're using minibufexpl.vim, add the following to your .vimrc:
let g:miniBufExplForceSyntaxEnable = 1
It appears to be caused by a bug in vim. For the details, refer to the release notes for minibufexpl version 6.3.1
Note that this will work for :bd but not :q
This might be much too late, but I was experiencing the exact same problem and found that adding the line
set hidden
to my .vimrc solves this problem. This makes vim hide buffers rather than closing them when you enter ":q" It also seems to keep my syntax highlighting enabled between files when I navigate with minibufexplorer.
Hope this helps.
You can use syntax enable or syntax on in your vimrc. For more info use :h syntax.
Ok then check that your syntax files are correct, it should looke like this
au BufNewFile,BufRead *.cpp set syntax=cpp11 <-- it's the line I have for cpp files.
Hope this help.
May be you should add this line to gvimrc:
autocmd BufDelete * syntax on
A plugin is misbehaving.
After closing the buffer (and losing syntax highlighting), investigate, by e.g.
:verbose set syntax?
This will show something like
syntax=cpp
Last set from C:\Program Files\Vim\vim73\syntax\syntax.vim
You might also be able to see what goes wrong my doing
:debug quit
If all else fails, try eliminating sources of errors by disabling plugins one-by-one (or removing all, and enabling one-by-one). At some point the problem will appear/disappear and you have found the guilty party.
I always have this problem. When a windows seems too small to view code, i will type :only the maximum this window and hide other windows. But when the editing is finished i quit want to restore the previous status of windows. Exactly the same before i maximum one window. It there any plugin to do this job? Or it's build-in in vim?
EDIT: I found a plugin called ZoomWin can actually do this job. But 0 can't been map to :ZoomWin in my vim. Still don't know why. The help file says i can use 0 to call Zoomvim just after i installing this plugin.
You could probably write a script using mkview and loadview if you wanted to keep this all in one tab, however, this is the exact thing that vim's tabs were made for. I suggest using the following mapping to map \0 to open the current buffer in a new tab. To close the tab just do :q as you would normally do and you'll go back to your previous tab which contains the window layout you want.
:nnoremap <leader>0 :tabedit %<cr>
Note that this mapping uses <leader> so if you've changed your mapleader then the sequence will not be \0.