Words containing ß in Vim - vim

I am using gvim 7.3 on Windows to edit a German document; enc is utf8. There are words containing an "SZ", say großer. When my cursor is on g, and I press w, I expect the cursor to jump to the next word. Unfortunately vim seems to consider ß to be the border of the word and jumps to it. Anyway to tell vim it should consider ß a normal letter?
ä,ö,ü are not a problem, they are recognized correctly.

Word boundaries depend on the value of the iskeyword option. The default value on UNIX-y systems is #,48-57,_,192-255 which includes ß (#223 IIRC). Make sure you run Vim in "no compatible" mode to have the correct default value. Having a ~/.vimrc, even an empty one, should be enough.

Related

Ctrl+6 not an editor command in Vim (switch language in the .vimrc)

I want VIM to start with two keymappings by default (Greek and Latin) but the default to be latin for coding. I have managed to add Greek in the .vimrc with :set keymap=greek, however that leaves Greek as the default language. Within VIM, I can change into latin in insert mode with Ctrl+6 but I want that to happen automatically when vim is fired up so latin will be the default keymap. The problem is Ctrl+6 (or Ctrl+^) is not an editor command but a key binding and as a result I cannot put it in the .vimrc. Any ideas on how to go around this issue?
tl;dr I want Greek keymap to be loaded automatically in vim but not be the default keymap.
This is not exactly the solution you're asking for, but a close one that works for me.
I have two imap commands in my .vimrc to switch between my French and English keyboards:
imap ^f <ESC>:set keymap=canfr<CR>a
imap ^^ <ESC>:set keymap=<CR>a
In insert mode, if I enter ^f it switches to French, and if I enter ^^ it switches back to the default.
You can also add the same in command mode:
map ^f :set keymap=canfr<CR>
map ^^ :set keymap=<CR>
In your case, you would have to replace my :set keymap command by what you need to activate your respective keyboards, and maybe also replace my ^f and ^^ by your preferred char, Ctrl-6 (not sure how to code it, I leave that to you) and a second character of your choice to pick which keyboard.
PS: to create the ctrl-6 rule, I would hit Ctrl-V followed by Ctrl-6 on my keyboard. On one of the too many machines I use, the result looks like this, where I added e for English, and f for French, but it will most likely be different on yours:
map <ESC>[54;5ue :set keymap=<CR>
map <ESC>[54;5uf :set keymap=canfr<CR>
imap <ESC>[54;5ue <ESC>:set keymap=<CR>a
imap <ESC>[54;5uf <ESC>:set keymap=canfr<CR>a
I've also replaced the literal escape character that technique produced, which visually looked liked ^[ but was actually just one character, by <ESC>, so this can be cut-and-pastable.
PPS: what Ctrl-6 will look like when you hit Ctrl-V Ctrl-6 is highly system dependent. What I showed above was from a ubuntu session in a cygwin-mintty terminal from a Windows machine. In gvim for Windows, it's a single character that displays as ^^, in vi inside Git Bash, it's a single character that displays as ^?. The encoding of Ctrl-N varies wildly, for reasons I don't fully understand.
PPPS: for all this to work for you, you'll probably have to remove your existing key binding for Ctrl-6.
I don't remember where I got this from, but I get the behaviour you want with this:
set keymap=greek_utf-8
set iminsert=0
set imsearch=-1
Latin is the default and you switch between Greek and Latin with ctrl+6 in insert mode.

vim insert mode autocompletion by ctrl-p does not work after dot

In vim insert mode, if there is a word insert, and if I typed ins, then type ctrl-p, vim will auto complete the word to insert.
I remember in my last PC if I type data.ins then type ctrl-p, vim will auto complete the word to data.insert, but since I bought a new PC, vim does not auto complete data.ins, how to fix this?
By the way if I type b on t of the word data.insert, vim will jump back to d, instead of i, I need to jump to i
I suspect that the dot character somehow got to be a part of the iskeyword option. To verify this, you can look at the output of :set iskeyword? (note the final questionmark).
To fix this temporarily, you can do :set iskeyword-=.. To fix this permanently, find out where iskeyword is changed in your .vimrc.
The option iskeyword determines what characters Vim considers to be part of a "word". With a dot inside it, string like data.insert will be considered a single word, meaning you jump over them with a single w/b/e/... motion. Ctrl-p autocompletion looks whether the substring typed until now is part of a "word" in the rest of the document. Since you hadn't typed data.insert before, it doesn't find anything starting with data.ins. When you remove the dot from iskeyword, it will only look if something started with ins (like insert).
After you removed the dot, if you find yourself occasionally wanting to jump over the entire dotted name, you can use Vim's concept of WORDs (see :h WORD). You jump over WORDs using W/B/E/...

How does one copy an arbitrary block of text in Sublime Text 3's Vintage mode?

I'm using Vintage mode (i.e. vi-style interface) in Sublime Text 3.
I'm trying to copy an arbitrary block of text. In regular Vim, the way I do this is:
Position the cursor at one end of the block.
Set a vi mark at that position, e.g. with mx ("set mark x here").
Position the cursor at the other end of the block.
Yank all text between the current position and mark x into the vi clipboard with y`x.
However, when I do this, it only seems to yank the current line into the clipboard, as if I had typed yy instead of y`x.
`x by itself works as normal (i.e. moves the cursor to mark x). But y`x does not.
As a result I find myself frequently using shift-arrow keys to highlight arbitrary text, which is OK, but is a mental shift I'd like to avoid.
Ideas?
Sublime's Vintage mode simply doesn't support it, unfortunately.
If you'd like a better Vim support, try the Vintageous package. It indeed supports the y`x you are looking for (just tried it).

Hide invisible unicode character

I don't know why but vim shows invisible unicode characters with space. Just enter this in vim and you'll see.
:tabe
:call setline(1, "\u2063hello")
There is a space after "hello". How can I hide this space? Or is there a way how I can mark text in vim with something invisible? For instance, there is a text in file
foo foo and I want to highlight first "foo". At this moment I mark first "foo" with "\u2063" character \u2063foo foo.
⁣hello
What you see depends on the terminal you're running Vim in. In GVIM (where Vim itself does the rendering), there indeed is an empty display cell at the beginning of the line. As Vim uses fixed, cell-based character addressing, this is expected. The U+2063 character is an invisible separator, but it still takes up one display cell.
Now, the terminal (I'm using Gnome Terminal) renders this character in a different way: It doesn't output anything. So Vim assumes the first cell has been occupied, and the h' of hello will be output at the second cell, but the terminal keeps the drawing cursor at the first cell, and all subsequent characters are rendered wrong. You can see the mismatch by moving around and using the ga command inside Vim.
Similar effects can be experienced with some combining characters, and other "funny" Unicode characters. I'm not sure whether the problem is with the terminal, Vim, or a mismatch in the interpretation of the terminal database.

How do I paste non-ASCII characters into vim?

My terminal emulator is configured for Unicode character encoding and my .vimrc contains the line
set encoding=utf-8
but when I try pasting the word "café" into vim, it comes out as "café".
I can make an "é" in vim by typing Ctrl-vu followed by the 4-character code point (00e9) but I'd like the ability to paste it in.
The solution was to uncheck the "Escape non-ASCII input" checkbox in the Advanced tab of the Terminal.app settings.
Instead of copying the character from the clipboard and pasting it into the text editor, you can add it to the file using vim's digraph feature.
So, with default settings, using your example, you could enter insert mode, then hit Control-k, and type e'. The result will be é.
You can see the list of defined digraphs by running
:digraphs
and general help by running
:help digraph
which also explains how to customize your mappings.
If you are truly set on pasting the characters in, Shift-Insert has always worked for me.
How to type a non ASCII code into vi
You'll have to know what your encoding is to enter the proper codes, I assume you left VI at the default.
In VI, go into insert mode, while in insert mode, press
Ctrl-v 172
That should insert the Logical Not (sideways and inverted L) character defined here:
http://www.htmlhelp.com/reference/charset/iso160-191.html
From where are you trying to paste it? If it is opera, then since opera-10.5* paste is broken in both directions. Before pasting anything you need to use xclip -o|xclip -i workaround (add -sel clip for clipboard).
What command do you use?

Resources