Can't use 'mark a' or 'mark A' in vim - vim

I like to use vim (on ms windows), I guess everybody have a favorite editor and this is mine.
On one particular PC I run into problems conserning the mark[a-zA-Z] command.
It does not work for the letters a and A but it does for b-z and B-Z and I would like to know why.
If I use the command :marks I can see that ma and mA do set an entry. But 'a and 'A have no effect. The same for the backtick versions.
If I do the same with labels b or B it works.
I checked my _vimrc but there is no line doing something to a or A.
What can block the labels a and A?
How can I find out what is causing this problem?
Any sugestion is welcome.
Additional information: 5-mar-2016, 23:59
I have no _gvimrc file and use the `standard' _vimrc file, never took the time to dig deep into the vim configurations. So it is still pretty vanilla. I like it this way, there are too many PC's I have to work with and synchronising _vimrc files is not what I'm looking for. :-)
This is in my _vimrc file.
:source C:\Program Files (x86)\Vim\_vimrc
let g:xml_syntax_folding=1
:filetype on
:filetype plugin on
:set foldmethod=marker
:set foldmarker={,}
autocmd FileType xml source C:\Users\andre\vimfiles\ftplugin\xml.vim
autocmd FileType python source C:\Users\andre\vimfiles\ftplugin\py.vim
autocmd FileType cs source C:\Users\andre\vimfiles\ftplugin\cs.vim
I have tried the suggestions made by cbaumhardt and that does not make any difference, running vim -Nu NONE -U NONE.
Additional information: 6-mar-2016, 20:23LT
The keyboard setting was interfering with the input. (US-international)
Changing the keyboard setting to US solved the problem.

The operating system can intercept the key presses before vim sees it. So if you use an international keyboard layout, 'a might produce a with an accent. Vim will not see 'a which is why the mark doesn't work.
One solution is to map the character with the accent to 'a or change the keyboard layout.
nnoremap <a with accent> 'a

Related

Can not switch to previous page in gvim

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.

LaTeX code was abbreviatedly displaied by Vimwiki in Vim

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

GVim Highlight multiple words plugin ans saving these Highligts

I like the Highlight multiple words plugin in my GVim but when i quit and re-open this editor all highlights disappears.
plugin description is here
:Hsave and :Hrestore do the job but the global variable contain the word highlighted ans disparead when i close GVim.
I've used :let g: to check
:set viminfo^=! is inside viminfo
I've seen mksession and source in your answers
So, what's not right ?
Thanks.
For troubleshooting, try to manually define a persistent variable, e.g.:
:let g:TEST_VAR = 'abc'
With :set viminfo+=!, the value should persist after a Vim restart:
:echo g:TEST_VAR
abc
If this works, the plugin's persistence should, too. If not, check the contents of the viminfo file and any modifications of 'viminfo'.
Note that my Mark plugin is an alternative, and also has marks persistence. It relies on the same persistent variable mechanism.
Thx to have decrypted my english :)
I'v trying this :
:echo has('viminfo')
show 1
:set viminfo?
show viminfo='100,<50,s10,h
:set history?
show history=20
My work is :
\m
(many times...)
On the word "Fabrice" i press 1 on keypad, it become red for foreground.
:Hsave CHIN
:Hclear
:Hrestore CHIN
(it's right)
:let g:
This is store :
HI_SAVE_CHIN hl1^I\<Fabrice\>^I-1^I101
and:
:let g:TEST_VAR = 'HI_SAVE_'
(or HI_SAVE_CHIN ?)
:set viminfo+=!
:echo g:TEST_VAR
It shows :
HI_SAVE_
In .viminfo :
Variables globales:
!HI_SAVE_CHIN STR hl1 \<Fabrice\> -1 101
!TEST_VAR STR HI_SAVE_
I'have doubt about HI_SAVE_ or HI_SAVE_CHIN.
These lines stays in .vimfo when GVim is open but i can't :Hrestore CHIN (Chin or chin), let g: nothing.
And it be deleted when i quit.
I's hard job ! i will try your plugin, maybe it's more easy for me !
I may not have respect the rules of this site but I have found the solution to my problem so I am writing this to all. It may be an incompatibility with unnecessary files (I do not believe it) can be settings, nocompatility mainly but I have disabled all in vimrc and I put :set viminfo+=! because he did not want to get into viminfo. Thanks for your elegant plugin Ingo and your help.

How to disable 'vi compatible' mode for Vim in Cygwin on Windows 8?

I am using Cygwin 1.7.22 (32-bit) on Windows 8 (64-bit). Within Cygwin, I am using Vim 7.3.1152, which is the default version.
Behavior that seem like bugs:
When I press I to enter insert mode, it does not say -- INSERT -- in the bottom left. In fact, it doesn't say anything. It does behave correctly, though.
When I delete letters using Backspace in insert mode, the letters do not disappear but the cursor does move to the left.
When I use the arrow keys in insert mode, it enters the letters A, B, C, and D, rather than moving the cursor. The arrow keys work normally outside of insert mode.
How do I make Vim behave as I expect?
Create a ~/.vimrc file with the following contents to put vim in nocompatible mode (actually the mere presence of the file is sufficient.)
set nocompatible
The behavior you are seeing is how vi used to behave. These are not bugs.
Take a look at :h nocompatible
In vim compatible mode tries to emulate vi as closely as possible.
--insert-- is not part of vi so it not shown in compatible mode.
I believe vi did a lazy redraw of the screen and didn't update until you exited back to normal mode. Also backspace is only usable also only works on stuff that was entered in the current insert mode. Overall its not very user friendly.
The arrow keys are sent to vim as escape sequences (escape followed by a coupled of letters). Let ^[ be escape. ^[OA is up on my computer its probably something similar on yours. vim sees this as an escape (goes back to normal mode), and O (add a line above the current) and A which is the A you see entered onto your screen. This just means that vim in compatible mode does not interpret the escape characters properly. Most likely because vi did not interpret them (nor was it designed to use them).
set nocompatible fixes problems 1 and 3.
I think set backspace=indent,eol,start should fix problem 2.
This was asked months ago, but I am answering for future reference for anyone else who encounters this problem.
I was just bitten by this issue. All advice listed in this post, and in other posts on this forum (not to mention posts on other forums) does not work, at least for some of us. I finally figured out the real issue.
vim on cygwin, for whatever reason (at least this was the case for me) does not use the .vimrc you put in your directory. Let's say you copy the example one to your working directory, or copy some .vimrc from online. Or maybe you create a new one from scratch, and put all the settings the good people here and elsewhere recommend (set backspace = blahblah, set nocompatible, set this, set that). It doesn't work. Why? Because for whatever reason (at least in my case) vim isn't looking at the .vimrc you just created.
The solution is to FORCE vim to use a particular .vimrc, by passing in -u on the command line like so:
vim -u [/INSERT/PATH/TO/.vimrc]
For the love of all that is holy, DO NOT type square brackets or the words "/INSERT/PATH/TO/.vimrc" verbatim. Use your brain please.
Anyway, this solved my problems and I was able to use the default example .vimrc and get proper delete and backspace behavior while in insert mode, not to mention other goodies.
You might want to alias the vim command in your .bashrc like this:
alias vim='vim -u [/INSERT/PATH/TO/.vimrc]'
Regarding A,B,C,D for arrow keys in Vim, adding:
:set term=cons25
to ~/.vimrc worked like a charm.
source: http://vim.wikia.com/wiki/Fix_arrow_keys_that_display_A_B_C_D_on_remote_shell
Following different answers in this topic I found a simple solution.
$ vi --version | head
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Mar 30 2020 21:54:08)
Included patches: 1-486
Modified by <cygwin#cygwin.com>
Compiled by <cygwin#cygwin.com>
$ vi --version | grep 'user vimrc'
user vimrc file: "$HOME/.virc"
2nd user vimrc file: "~/.vim/vimrc"
So I just created ~/.virc (not vimrc) and it works! The content of the file:
set nocompatible
Probably, if you already have this file you will add the above string in it. Or, as people say above, if you have an empty ~/.virc, nocompatible mode must be already in use (I didn't check it).
Apart of the question, line numbers (that I find very useful) may be shown in vi by adding:
set number

How do I avoid cumulative filetype commands in vim?

Let's say I load up a python file in vim. A quick check of :scriptnames shows that my ~/.vim/ftplugin/python/python.vim file loads as expected. One of the commands in this file highlights all characters that are past the 80th column. Now lets say I open a C++ file in another buffer (therefore running ~/.vim/ftplugin/cpp/cpp.vim). Although the new commands are executed, the settings in python.vim still apply; therefore characters are highlighted past the 80th column in my C++ file.
Is there anyway to make filetype commands not cumulative like this? I have filetype plugin indent on in my .vimrc.
The problem is that both 'colorcolumn' and :match (you didn't specify whether you use the new setting or the older highlight approach) are local to the window, but ftplugins should only set buffer-local settings.
Why are these settings window-local? That allows you to have the same buffer displayed in two windows, one with, and one without the highlighting.
What can you do to prevent this?
a) Don't set this in the ftplugin, and instead use mappings to toggle the colorcolumn on/off.
b) Put :setlocal nocolorcolumn into all ftplugin scripts (e.g. in ~/.vim/after/ftplugin/*.vim) for all filetypes that you're using. This will only work unless you switch between different filetypes in the same window.
c) The correct (but most complex) way to solve this is through a couple of :autocmds on BufWinEnter, BufWinLeave, and WinLeave events.

Resources