Pasting copied text to vim encoding issue - vim

I copy some russian text from browser to vim then in insert mode pasting it via CTRL-R + * and getting a whole bunch of unreadable characters. I tried to set some fileencoding encoding and termencoding to utf-8 but that did not work.
My OS is Ubuntu 12.04
I use standard bash terminal
The problem appears only in non-gui vim version.
these are my .vimrc settings:
set termencoding=utf-8
set encoding=utf-8
set fileencoding=utf-8

Related

Vim. Can't yank non-eng chars to system clipboard

When I yank russian characters, say тест, to system clipboard ("+y) and then paste it in a shell or a browser I get this —Ç–µ—Å—Ç. How to fix this?
Vim
:set encoding?
encoding=utf-8
:set fileencoding
fileencoding=utf-8
Shell
echo $LC_CTYPE
UTF-8
I had the same issue and fixed it by adding lang en_US.UTF-8 to my ~/.config/nvim/init.vim (using Neovim). You could try adding that to your ~/.vimrc.
Source: https://github.com/neovim/neovim/issues/5683#issuecomment-420833679
Setting correct locale for a shell with these lines added to .zshenv solves the issue.
set -a
LC_CTYPE=en_US.UTF-8
LC_ALL=en_US.UTF-8
set +a

Why does gvim start every new line with TAB?

I'm using gvim under Windows (version 7.3.46)
Everytime when I press o to start a new line, gvim starts the line with a TAB character.
When I set :se expandtab the TAB is changed into 8 spaces.
I tried everything to disable the starting TAB without success:
set noautoindent
set nosmartindent
set nocindent
I'm also using vim under Linux and didn't have such a problem.
THX

vimrc nnoremap no effect after startup with utf-8. vimrc reload fixes

I have set the following at the beginning of my _vimrc on Windows 8
scriptencoding utf-8
set encoding=utf-8
Further down the file are the following mappings
nnoremap § ~
nnoremap ö :
My problem is that the mappings are having no effect after startup of gvim. If I reload the file by opening it and forcing a write such that my
:au! BufWritePost $MYVIMRC source $MYVIMRC
kicks in, the mappings work. They also work if I manually enter the commands while running gvim.
Running set fileencoding reports fileencoding=utf-8 for my _vimrc.
The version of vim I'm using is 7.4.094/2.7/3.3/2.0.0 from https://bitbucket.org/Haroogan/vim-for-windows.
The mappings work in MacVim on my Mac without modification. Any ideas?
Update 1
The output of :nmap is displayed as
n § * ~
n <f6> * :
Using redir to capture the output of :nmap and pasting it into a new utf-8 buffer, the § is displayed as a greyed out <a7>. When copy pasting this back here, the § is once again a §.
Update 2
I installed gvim74.exe from vim.org and used the same _vimrc. Nothing changes. My other keymappings work as usual by not ö or §. I've tried both gvim.exe and vim.exe, both the official version 7.4 from vim.org and version 7.4.094/2.7/3.3/2.0.0 from https://bitbucket.org/Haroogan/vim-for-windows.
Update 3
If I remove the encoding settings
scriptencoding utf-8
set encoding=utf-8
from my _vimrc, the keybindings work as expected.
I solved the above problem by simply changing the order of the encoding settings to
set encoding=utf-8
scriptencoding utf-8
Another solution was to wrap the keymappings with calls to scriptencoding, like this
scriptencoding
nnoremap § ~
nnoremap ö :
scriptencoding utf-8
I am assuming this changes how text is converted to utf-8, but I'm no vim expert. Please enlighten me exactly why this works! xD

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 doesn't support unicode?

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

Resources