Vim doesn't support unicode? - vim

I'm trying to get the following into my .vimrc
" Use the same symbols as TextMate for tabstops and EOLs
set listchars=tab:▸\ ,eol:¬
Those lines are from here are worked perfectly in vim 7.2
I recently compiled and installed vim 7.3 and now those characters aren't understood by vim.
Also: Ctrl+V then U in insert doesn't let me insert any characters, it just seems to ignore that.
Any ideas?
This is what I see:
set listchars=tab:�~V�\ ,eol:¬

You need to compile vim with multi-byte support.
The easiest way to do this is to run
./configure --with-features=big
make
This will build vim with the correct support.
You can verify that it was compiled correctly with
:version
in vim or by running
vim --version
and looking for +multi_byte. If it says -multi_byte it will not work.

I have the following in my .vimrc
scriptencoding utf-8
set encoding=utf-8
and that in my .gvimrc
set listchars=trail:·,precedes:«,extends:»,eol:↲,tab:▸\
and works fine(notice there is a space after the ▸\ ).

I had the same issue with the vim that ships with OS X Lion although it was compiled with multi_byte.
The issue was the encoding used by vim. I added set encoding=utf-8 in my ~/.vimrc and the issue was solved.
Ref: Terminal Vim redraw issues in OS X Lion

Make sure you're using a compatible font. My problem was that inconsolata-g does not support the utf-8 characters in my document.
also, this was all I needed in my gvimrc:
set enc=utf-8
set fileencoding=utf-8
set fileencodings=ucs-bom,utf8,prc
set guifont=Monaco:h14
set guifontwide=NSimsun:h14

I had this issue while being in a screen session.
It's gone with setting the following in my .bashrc:
export LANG=en_US.UTF-8

Don't forget, if you're running vim in a terminal, make sure the terminal itself is using utf-8 as well.

When all else failed, telling vim to save with UTF-8 encoding seemed to work (for now at least):
:write ++enc=utf-8

Do you need a
scriptencoding utf-8
or whatever encoding your .vimrc is actually in?

The accepted answer didn't work for me. Working off of the downloaded source on a Mac running Lion, I went into the src directory and ran:
make clean
export CONF_OPT_MULTIBYTE='--enable-multibyte'
make reconfig
Running: ./vim --version to check for +muti_byte then:
make install
Via: http://vim.1045645.n5.nabble.com/compiling-vim7-1-huge-version-gets-build-with-normal-version-td1162314.html

Related

airline.vim does not work inside tmux

I am new to tmux and also not an expert on VIM, I tried to use tmux these days, but seems that airline disappeared when I used vim inside tmux. I would like to show you the screen shots and hopefully anyone can help me solve this problem.
airline in vim
airline inside tmux
You need to correctly set $TERM environment variable to make vim properly detect 256 colors support by doing the following before opening vim:
export TERM=screen-256color
While the accepted answer works, it is not cheap. Manually setting the value of the $TERM variable will usually be set correctly by itself.
It is usually a good a idea to force tmux to assume the terminal supports 256 colors.
In your ~/.bash_aliases, add:
tmux='tmux -2'
Answer based on the following posts:
What is the difference between screen-256 color and xterm-256color
tmux vim colorscheme background is not showing
Add the following line in your .tmux.conf
set -g default-terminal screen-256color
In my case, using ubuntu 20.04 inside windows with WSL2, the accepted answer (export TERM=screen-256color), just freeze the tmux pane.
The fix for me was add to ~/.vim/vimrc:
set t_Co=256

vimrc commands not applying with cygwin and cscope combination on windows 7

I have installed cygwin and cscope on my windows 7 machine. I created a .vimrc file in $HOME directory with the following settings:
syntax on
set hlsearch
set ic
When i ran cscope, selected a file and tried to find some text, it is not highlighting(it get highlighted when using vim/vi on individual file).
I added "alias vi=vim" too in my $HOME/.bashrc file.
Please help me resolving this and understanding why it is happening, as i think cscope should open files using vi/vim.
You can check with the :scriptnames command which ~/.vimrc configuration and plugin files are loaded.
I doubt that csope is going to use your alias. It's probably using the EDITOR or VISUAL environment variables. Make sure those are set to /usr/bin/vim and not /usr/bin/vi. On Cygwin, vi and vim are two different executables. vi is configured to be mostly vi-compatible, while vim has most of the vim features turned on.

Cannot set the default font of gvim in mint

i have tried to move my configuration of VIM in Mac to Linux Mint.
However, the default font of gvim cannot be set. I have already put set guifont=Monaco:h14 into my .vimrc and I have also downloaded the font into my system. I have checked out this question, the verbose command can be used to find the setting of gui_font. I used the verbose command and the result pointed to my .vimrc.
The most interesting part is that I can set the gui font by the same command: set guifont=Monaco:h14 in the running environment of gvim.
You are using the wrong format.
This format:
set guifont=Monaco:h14
is for Mac OS X while you should use:
set guifont=Monaco\ 14
on Linux.
Everything is explained very clearly in :help 'guifont'.
Hint #1: you can do :set guifont=* to open a GUI dialog, once you have chosen your font you can simply do :set guifont to see the correct string to use in your ~/.vimrc. Don't forget to escape spaces.
Hint #2: this other answer shows you how to make different platform-specific settings.

vim "syntax on" does not work

Here is my .vimrc
1 syntax on
2 set ts=4
3 set number
4 set smartindent
5 set shiftwidth=4
However, I tried to edit HelloWorld.java and HelloWorld.c. Both have pure regular black font. No any highlighting!
I also tried :syntax on after the vim is open, but no luck.
\>vim -version
VIM - Vi IMproved 7.3 (2010 Aug 15)
\>cat /etc/*-release
openSUSE 11.4 (x86_64)
VERSION = 11.4
CODENAME = Celadon
When you edit the file, are you using
vim filename
This can matter. In some server configurations, if you do vi filename you get vim, but it's a very stripped down version of vim that is very much like the original vi (which does not, among other things, do syntax coloring). On a system configured in this way, if you instead type vim filename, you get the full featured vim.
I just worked through this with a person who was on a server that had the vim-minimal package installed as well as another vim package. I suspect (but did not verify that) the vim-minimal package installed its executable as /bin/vi.
The difference was very clear when you looked at the actual files (i.e. ls -l /bin/vi vs ls -l /usr/bin/vim)--one was about ten times the size. Both of them were actually vim, same version number and everything, but the /bin/vi one was compiled with very few features enabled.
To make it even more confusing:
vi existing.pl
opened the .pl file, gave no syntax coloring
vi [enter]
gave the vim splash screen, and from there
:e existing.pl
opened the file with syntax coloring on.
A comment from Jan Wilamowski suggests checking by doing:
vi --version
If that shows that the syntax feature was not compiled in, try
vim --version
and see if it is compiled in there.
You'll need to install the vim-data package on openSUSE for vim syntax colouring to work.
Sounds strange, I know that this is not pulled in by default with the vim package but AFAIK it's for people who want to create tiny base installs.
Package vim-data contains the runtime files.
Also make sure your remote environment has an appropriate TERM variable set TERM=screen-256color, TERM=xterm, TERM=xterm-256color should all work just fine with ssh and ssh with screen/tmux.
If all above have been done and you see some underlines and bold instead of actual colors... this might work for you:
export TERM=xterm-color
in your .vimrc, I don't see filetype setting. you could try to add:
filetype plugin indent on
to your vimrc.
if you don't have set nocp, add this line too.
if you read :h filetype
:filetype on
Each time a new or existing file is edited, Vim will try to recognize the type
of the file and set the 'filetype' option. This will trigger the FileType
event, which can be used to set the syntax highlighting, set options, etc.
For some strange reason on MacOS, 'syntax on' must be the first line in your .vimrc file. The line appears to be ignored if placed elsewhere in the file.
One item not mentioned is :set syntax=<type>, e.g. :set syntax=markdown.
This has been successful in instances where other techniques above were not.

Linux vi arrow keys broken in insert mode

My arrow keys don't work in vi in insert mode at home, they just each insert a newline and a capital letter, like 'A'. Is there a way to fix that?
I presume you're using vim as this is tagged as Linux. Try:
:set nocompatible
(You may want to configure your .vimrc with this by adding this command to it. Create a new .vimrc file if not already present in your home directory, run echo $HOME to check home directory path.)
Ubuntu ships default with vim-tiny, which doesn't have all the bells and whistles that vim has.
Do a quick sudo apt-get install vim to get all the juicy features that everyone's talking about.
:set term=builtin_ansi
fixed it for me. You can either paste that into vim while in escape mode, (bleep mode) or add it to the end of ~/.vimrc without the leading ":"
vi does not support arrow keys in insert mode. Use vim. Although your vi may just be a link to vim, it may be configured to behave like the "original" vi and thus disables the arrow keys. Just invoke vim directly.
Yet another variation: this problem appeared for me after some .vimrc changes. A concerted search eventually revealed that my clever re-mapping of ESC in normal mode was not a good idea. Removing it solved the problem:
" this is NOT something you want in .vimrc:
" In normal mode, hitting Esc turns off search highlights:
nmap <ESC> :nohl<CR> " Do NOT add this to .vimrc
The only thing that worked for me was ":set term=ansi"
I had same issue with arrow keys, but when I used did that set nocp or nocompatible then my backspace didn't work correctly
for some reason when I installed vim with
sudo apt-get install vim, vi didn't had any issues with arrows or backspace anymore
In WSL integrated terminal on VS Code, update the package and install the full package of vim worked for me.
sudo apt-get update
sudo apt-get install vim
However, to make the arrow key works when I use conemu I have to add :set term=builtin_ansi on ~/.vimrc
echo ':set term=builtin_ansi' >> ~/.vimrc
I just had an issue with arrow keys after switching over to use git in .vim.
I have installed this repo - https://github.com/sunaku/.vim
and after digging around for an hour, I found that AutoClose plugin
(which didn't like anyway) broke the arrow keys.
The plugin docs suggest that one should set set ttimeoutlen=100, but
that didn't work for me! (using urxvt+screen or urxvt, and even xterm)
So I removed the plugin at the end.
You might also want to try 'noesckeys'
I had the same issue while using vim inside Windows 8.1 with Cygwin.
Solution worked for me is, just run the following command in your Cygwin terminal:
cp vimrc_example.vim ~/.vimrc
In the command line write this:
EXINIT="set nocompatible"; export EXINIT

Resources