I recently started using git, and by default it would want to use vim. I always wanted to look a bit deeper in this editor, but was always thrown back, only using it if for some reason (such as in case of a near dead Linux system) it was unavoidable. Even now I soon ended up reconfiguring git to use mcedit instead (which I use for programming).
The problem was that OK, I gave the command :help to see how I could start. Then in the help system it suggests me to jump to the subject interesting me using CTRL-]. And here I am lost. I have a Hungarian keyboard, and simply couldn't find where it excepted to find ]. So I can just scroll around in a list of topics I can not enter.
This is just the beginning: In general how much such "weird" combinations I may except? And how I could fix those up? An other problem with the Hungarian language is that it has a bunch of extra vowels which have to be mapped on the same amount of keys like English with it's 26 letters (there are 9 extra letters, so 9 keys "lost"!). Would this hinder the use of vim for writing Hungarian text (where I would require these keys to produce the language-specific vowels)?
How this problem could be solved in a way that if I happen to get an English keyboard (for which layout I guess vim was originally designed), I wouldn't have to re-learn the positioning of the keys? (Since I have no English keyboard around I can't try what happens. As I tried neither of the two keys on the left of 'P' would suffice for the CTRL-] combination while as far as the layouts I checked the second should be it. Of course my system is configured for Hungarian layout)
The language truly is irrelevant, I guess everyone having non-English keyboards might face similar problems. So how you work yourself around these?
Look at /usr/share/vim/vim74/keymap/ directory (in debian/ubuntu it is a part of the vim-runtime package), you should see a bunch of keymap files for different locales. Chose the one you like. In the example I use russian-jcukenwin.vim.
Add to your .vimrc file →
set keymap=russian-jcukenwin
set iminsert=0
set imsearch=0
highlight lCursor guifg=NONE guibg=Cyan
Now you can switch layout with Ctrl-^ keys. Note: layout is switchable when in insert-mode.
As you can guess the first line is the name of the file I mentioned. The next two lines sets the iminsert and imsearch in order to start writing the very first time with latin layout. In fact Ctrl-^ toggles them between 1 and 0. And the last line draws the caret with cyan color when layout is changed.
You can remap all vim defaults bindings with the map function.
For further information, you can read this tutorial
simple solution
you can switch to English layout when using vim:
setxkbmap us
and switch back to hungarian keyboard (hu) afterwards.
xkb
To show you another way:
the xkeyboard layout for hu keyboard is located in /usr/share/X11/xkb/symbols/hu. Try to compare the layout with /usr/share/X11/xkb/symbols/us.
There are also layout variants for hu keyboard than just default.
See my post here
If you want to do something advanced, you could also apply the english keyboard to the CAPS LOCK modifier LEVEL
Related
When using vim in a non-English language environment, mistakes in mis-entering command often occur.
To prevent this, is there a way to view the current input source on the statusline?
For example, EN or JP.
like MS word bottom bar
Vim doesn't have that information so it can't expose it, which is not exactly a problem since your desktop environment already does.
If you really want to duplicate that information in your Vim status line, then you will have to find what external command to call, and then find a way to consume the information that doesn't slow Vim to a crawl because the status line is refreshed several times per second.
Now, your question is really two questions:
How to get the information?
How to show it in the statusline?
The answer to the first question depends on your desktop environment, which you didn't disclose. You will have to look around on your own, on more specialised forums.
The answer to the second question is irrelevant without an answer to the first one but you can look up :help 'statusline' and :help system() if you are curious.
Anyway, you already have the information in your desktop environment's menu bar/task bar/whatever, so why bother?
Vim has modes. In Normal mode where it is supposed to stay most of the time all commands consist of latin letters by default. Therefore, using OS level keyboard layout switch cannot be recommended. Instead, Vim has a feature called "keymap". Vim keymap is only active in Insert or Command-line mode never affecting the Normal mode.
So, Vim never cares what is your active keyboard layout on OS level and you won't expect an easy way showing it. On the other side, Vim keymap name is accessible either as b:keymap_name variable or %k format specifier for the statusline option. So it is pretty easy to add it.
I have a few keystrokes (like <M-[>) imap'd to executing some actions in my .vimrc, e.g.
imap <M-[> <C-o>:silent !audtool --playback-seek-relative -3<CR>
for seeking in audacious while typing (for transcripting recorded speech). I wanted to do the same for Czech keyboard layout, which happens to have ú (u-acute) in that position. So I tried the obvious
imap <M-ú> <C-o>:silent !audtool --playback-seek-relative -3<CR>
which does not work. What is the solution here? Tried :help key-notation and google without success. A solution only working in gvim (and not in terminal) is fine.
Vim has an ancient method to handle input – it is represented as a byte (character) queue, not as a keystroke sequence queue. I guess, the character <M-ú> (yes, it should be a char) just does not exist, like as <C-1> doesn’t. You can make sure of it by pressing <C-v><M-ú> in input mode – a plain ú or nothing would be typed. So there is no way to map <M-ú> to something either.
But! Hence Vim is not well to handle different external layouts than basic QWERTY by design, it provide an his own (internal) mechanism for supporting second layout.
If you do :set keymap=czech, you would be able to switch input language inside Vim by <C-6>, and forget about mapping mess – in mappings <M-[> (as well as z, 2, etc) would mean one key chord in both layouts.
BTW, this is actually an only way to adequately use Vim for a language which has a layout that is completely different than QWERTY (e. g. Cyrillic).
Vim newbie here.
I would like to be able to create tabs in Vim such that, for example, the tabs are at 4" left and 1.5" right for one type of section, 1.5"/1.5" for another, etc.
I know how to set tab stops, etc. but the trick here is I would like vim to recognize key combinations like shift-enter to go to one kind of formatting, plain enter to go to another kind, etc.
Is this even possible with vim?
TIA
I think you're confusing Vim with a word processor (like Word or Writer). There's no measurement in inches, no left / right margins, etc.
Vim's 'tabstop' option is a multiple of the width of a single space character that a <Tab> character (ASCII 0x09) expands to. This is fixed for the entire buffer (though you could use a set of :autocmds to change it in different parts of a buffer). Vim has no notion of paragraph text styles like a word processor, where you can define different styles. Vim only has a rather primitive :hardcopy command for printing.
If you need elaborate text formatting capabilities, Vim probably is the wrong tool, except if you choose to edit a source code document (like Latex, HTML, or Markdown), which is only compiled into a document (for those, like editing programming languages, it's actually well suited and powerful).
The vimtutor command (see :help vimtutor inside Vim) provides a good introduction to Vim's capabilities.
Check out these screenplay scripts. At least the first one contains custom tab widths as required in the traditional play formats. Perhaps they provide you the right idea on what's possible with Vim:
http://www.vim.org/scripts/script.php?script_id=2447 by Mike Zazaian
http://www.vim.org/scripts/script.php?script_id=1842 by Alex Lance
This question is the same as this one, only regarding the (lesser known) neo keyboard layout instead of dvorak.
I want to start programming and I understand that vi and vim are considered to be highly productive editors for coding if used wisely.
Now I'm using the neo keyboard layout and I wonder what keybindings for vim might be best suited for this layout.
I don't want to learn to use vim, find out my keybindings don't work well and then I have to readjust my habits.
So to all of you who use vim + neo: How do you remap vim's keybindings to best work with neo?
(More generally: What are the things I should keep in mind when changing vim keybindings?)
Generally, I wouldn't change the keybindings. The Vim commands work because by and large they're mnemonics. Just leave them alone and use them where they stand. I see that hjkl aren't so well laid out on that layout but you do seem to have cursor keys behind "Ebene 4" so if that's not too much trouble maybe that'd be ok. (I don't find myself using hjkl much anyway, I usually use other more direct jump movement commands.)
I'm a Dvorak layout user.
More generally, as a VIM user but not a Neo user, I would generally mimic the VIM key layout onto your keyboard. Pay attention to which keys in VIM are under the resting positions of each finger and translate that onto Neo.
Keeping a traditional layout that is overlaid onto new keyboard layout will keep common keys under your resting finger positions. It will also build muscle memory that can be transferred to QWERTY when you need to work on a non-Neo keyboard.
I am a VIM and Neo2 User myself.
Both quite a time now. And I can tell you: about 90% of the commands are even nicer to use (imho at least), than they where back on qwertz. Some '`' commands type weird, but you get used to it. But you may consider to change vim's LEADER-Key (i've moved it to 'j') tho.
I am giving Vim a serious try for coding my Python apps.
However, Vim is proving to be so flexible, I was thinking to use it as my main editor at work for writing lawyer/legal documents. The problem is that my mother tongue is not English but Greek. So, I have mapped Alt+Shift to change between English and Greek keyboard layouts.
The issue I am experiencing is that I have to press Alt+Shift each time I want to enter a Vim command (to return back to English). So it is Alt+Shift when I type my document, then Alt+Shift again to enter Vim commands. This defeats the purpose of using Vim, at least in terms of speed of use.
So my question is simple: Is there any way to avoid those frequent Alt+Shift keyboard layout changes just for entering Vim commands when writing in a non-Latin language (e.g., Greek)?
This problem can be solved with the help of the keymap option.
It allows to define an alternate keyboard mapping to use in modes
requiring text input.
To switch between the default and alternate keymaps while in Insert,
Replace, or Command-line mode (but not Normal mode), use
Ctrl+^ (Ctrl+6).
Changing the keymap affects text input only; keyboard behavior in
Normal mode stays the same regardless of the current keymap setting.
One can leave Insert mode writing in Greek and immediately use
Normal-mode keybindings without switching to a different keyboard
layout. If one then returns to Insert mode or, for example, starts
a search by typing /, Vim switches the keymap back to Greek
automatically.
The current keymap used in those text-entering modes is remembered
between switchings to other modes. The only exception from this
behaviour is made for Command-line mode which always starts with the
default keymap, since most of the time it is required to type an Ex
command (in ASCII). With the keymap option set, user is supposed
to work in Vim keeping system keyboard layout set to English while
switching Vim keymap with Ctrl+^ (instead of
the system-wide layout switch).
To enable, say, the UTF-8 Greek keymap permanently, add the following
line to your .vimrc file.
:set keymap=greek_utf-8
There are many predefined keymaps for a large set of languages, you
can browse them all in Vim itself using :e $VIMRUNTIME/keymap. Note
that usually there are several keymaps provided for one language which
differ only by character encoding, so that anybody could choose one
that suits their configuration.
I also recommend setting the options below to specify whether the
keymap should be enabled by default in Insert mode and when entering
a search pattern:
:set iminsert=0 imsearch=-1
See :help iminsert and :help imsearch for the detailed explanation.
There is also a special language mode that, if I am not mistaken,
was introduced in Vim earlier than keymap. It allows to achieve
the behaviour similar to the one provided by keymap through manually
specifying letter pairs that correspond to the keys on keyboard in
a long string to be saved in the langmap option. Personally—my
native language is not English, too—I prefer (and recommend) using
the keymap way instead.
In conclusion, I should emphasize that all of the above is equally
applicable to any other language Vim has (or can be configured to
have) a keymap for.
See also my answer to a similar question ‘Vim “annoyance”
with keyboard layouts’ that has been asked since I originally
gave this answer.