Vim langmap breaks plugin (bépo) - vim

I am using a bépo keymap (http://bepo.fr) and seeking the perfect vim mapping.
So far I used a long list of noremap, but for many binding (for exemple, the motion aw or Ctrl+r), the first keystroke is well remaped but not the others, I reckon it's the expected behaviour, but then this is not what I need.
Ideally I would have my keyboard totally remaped in a higher level (before the map commands) except when typing text (in insertion mode and when typing a substitution for exemple). What I'm looking for seems to be langmap, but I have problems using it.
I added this langmap to my .vimrc, It seems perfect but it broke some of my plugins. SuperTab now insert <Plug>SuperTabForward when pressing Tab in insertion mode, I have t<SNR>24_SelectCompletion(1) when pressing enter.
Does someone know how to fix this langmap issue or a better way to remap my keyboard?

This is a known bug, that has been discussed before. I have made a patch (see the thread starting here) and hopefully Bram will include this change soon.
Update 11/05/2014
This has been fixed by patch 7.4.502. Use the langnoremap option to fix this.

Related

Use Emac keys while in insert mode?

Using all of Vim, Xvim(for Xcode) and Ideavim(for IntelliJ), I'd like to be able to use the default keybindings while in insert mode rather than Vims. I've been using Xcode for quite some time now and have gotten quite good at typing with the standard Xcode bindings but Vim bindings are so much better while not in insert mode.
I know you can do .vimrc settings such as
:im <C-D> <esc>xa
to emulate these functions, but this still leaves problems with slightly different behaviors as well as losing functionality where these commands have multiple uses. IE ctrl+n is both down while typing and next while scrolling through autocompletions. Custom bindings in .vimrc removes the ability to scroll through autocompletions.
Using
:im <C-N> <NOP>
enables scrolling through autocompletions but still doesn't let it function as down.
Anybody know how to solve this?
If you really want to, you can put
nnoremap i :action VimPluginToggle<CR>
into your ~/.ideavimrc, then in Preferences => Keymap, find the Vim Emulator item and assign the shortcut ESC to it. This when instead of entering insert mode, you'll be disabling IdeaVim, and hitting ESC will re-enable it.
I tested this briefly and it does seem to work at least at a superficial level, although you lose the changing caret style as an indicator of which mode you're in. I'm not sure that's a good idea, however. Probably better to work within the system as designed and set up the bindings you want.

How do i comment/uncomment with macvim

How do you comment and uncomment out a code block with janus macvim
The janus documentation for nerdcommenter says that binding is
Janus binds command-/ (`<D-/>`) to toggle comments
What does that mean in keystrokes...my leader key is the comma
UPDATE
After reading the nerdcommenter doc it seems like that might not be what i need to comment...any ideas
It just means pressing keys ⌘/.
The Cmd key (or Apple key on old keyboards) is represented in MacVim as <D>.
That key can only be seen by MacVim in "GUI mode". This means that, like with a lot of crap in Janus and other distributions, you end up learning someone else's crappy non-portable mappings instead of your own cross-platform mappings.
The <D-key> notation means exactly the same thing as the usual Cmd+key so <D-/> is the same as Cmd+/: press the Cmd key, press the / key and release both at the same time. Like in TextMate.
NERDCommenter is a popular commenter plugin. Why the Janus maintainers chose it over other plugins is unknown but it works well.
Press the Command (⌘) and forward slash (/) keys simultaneously. You can prefix this with a modifier (e.g. number of lines) for more complicated effects.

enter button insert a new line instead of choosing an alternative

Recently when I tried to use the ctrl+n or ctrl+p to auto-complete, when there are multiple alternatives, tapping the enter button will insert a new line instead choose the alternative I want.
This did not happen before, maybe because I installed too many plugins and caused the conflicts. It would be horrible to check all these plugins' shot cuts and find out the source. So mapping the built-in auto-complete to some other keys could be a solution, but I don't know how to do that.
This is not a big problem but really made coding not "smooth". Anybody has met this situation before and how did you deal with it.
Short answer: You don't need to use <cr> to accept a match.
Snippet from the vim help :h popupmenu-keys
The behavior of the <Enter> key depends on the state you are in:
first state: Use the text as it is and insert a line break.
second state: Insert the currently selected match.
third state: Use the text as it is and insert a line break.
In other words: If you used the cursor keys to select another entry in the
list of matches then the <Enter> key inserts that match. If you typed
something else then <Enter> inserts a line break.
I would suggest you use <c-n> and <c-p> to switch to the correct mapping and then continue on with your typing. Typically this means I type a space or some other punctuation key and the menu closes. I never use <cr> to select a menu item. If however you really want to accept a match use <c-y>. Think "yes" to the selected menu item.
I just fixed a very similar problem caused by the vim-autoclose plugin by replacing it with the Auto-Pairs plugin. I doubt that yours is exactly the same culprit but it's actually not too bad hunting down the guilty party if you use pathogen for your plugins - just move half of your plugins from ~/.vim/bundle (or wherever they are) into a different folder, restart vim and test the autocompletion. If it works as expected, you know that one of the plugins you have moved out is responsible, so you can do the same again until you have narrowed it down.
Before that, you can also try running vim -u NONE which ignores your .vimrc file - it may be that you've snuck something in yourself and this is the fastest way to rule it out.
Good luck anyway. This took me about ten minutes and after probably a year of occasional annoyance I wish I had taken the time earlier.

Vim: Is it possible to bind a key to open search (i.e. put me in the command mode having entered a slash, but do not type anything)

While vim's way of doing things is generally good, I feel like there are aspects that really get in the way as somebody who is not completely committed to vim for text-editing.
This means that I am hitting Esc+/ and typing slashes into files in Sublime Text, and hitting Ctrl+F in vim, scrolling down a page.
Similar things happen with Ctrl+S and :w and custom mapping ; to : still doesn't make it as convenient and fail-safe as Ctrl+S. Not to mention in PuTTY, Ctrl+S does something rather upsetting (it suspends output from the terminal till Ctrl+Q is pressed). Basically, IMHO some things (like switching to a "find mode" and saving the file) are good to attach to a global left-hand home-row shortcut chord rather than requiring the user to mess about in a modal command line. It simply is too often used to subject the user to these mode changes. I suppose this isnt a legitimate complaint because the entirety of vim is constructed around the modal concept, and these functionalities are a result of that.
In any case I'd like to make it a bit easier on my brain because I've tried for a while now to keep it all intact and it's simply too much (I have more or less internalized the switching between Ctrl on a windows machine on a desktop keyboard and the use of the thumb for the Cmd on my Macbook, but this modal text editor business seems to be too much). It did not take too much deliberation for me to decide that global homerow key chords are simply more intuitive.
Mapping Ctrl+S to :w is trivial, so the question here is about the find mode. I want to bind Ctrl+F to put me in find mode, but repeating it should not type slashes into the find command. Can this be done? Is there perhaps a colon-command that when executed simply drops me into the current find-command-buffer-thing?
In your .vimrc add:
inoremap <C-f> <Esc>/
noremap <C-f> <Esc>/
In whatever mode you are in, this will put you in "find" mode (it actually just types a slash in the command line which you can use to search). With these bindings it will work for all modes, even if you are in insert mode.
do you want this?
nnoremap <c-f> /
if you like you can also try
nnoremap <c-f> q/
the 2nd mapping brings you to a search history window. you could choose previous search keywords/patterns. also available to type new pattern (by pressing i)
btw, there is no find mode
Mappings can be defined separately for the different modes in Vim, see :help map-modes. This automatically takes care of your proposed <C-f> mapping: Initially, you're in normal mode, then the search pattern is entered in command-line mode.
If you so far only occasionally use Vim, and find it too "different", several things may make the switch easier:
easy Vim (evim or vim -y) defaults to insert mode
on Windows, :behave mswin and the $VIMRUNTIME/mswin.vim script create some common Windows shortcuts
graphical GVIM has menu items like Edit > Find... and toolbars.
Some things like the flow-control freeze on <C-s> in terminals are unfortunate, mostly historical accidents; you can't blame Vim for those.
You don't need to map anything. / is expressive enough and is definitely not slower than <C-f>. Same for <C-s> which, despite a certain familiarity, is not much better than :w<CR>. You are learning a new tool, remember?
What you should focus your efforts on is getting confortable with Vim's modality. The simple fact that, for you, doing a search involves hitting <Esc> is a sign that you didn't get that part. Your other comments on using Vim shortcuts in ST and ST shortcut in Vim are not good signs either and the part where you complain about having to adjust to your Mac's Cmd is the icing on the cake, IMO.
It may sound brutal but, from your question, it seems like you are doing too much at the same time, without organization and for, probably, no good reasons.
Switching from Windows to Mac OS X and switching from ST2 to Vim at the same time is sure to be confusing and I suggest you slow down a little and make a choice before you loose your mind and waste more of your time.
Which leads me to this: Why do you use a Mac and why are you using Vim?
Windows is a fine OS. Sublime is a fine editor. Even if you switch to the Mac, Sublime works very well there. So Why Vim?
If you are tired by some Sublime limitations and want the awesome power of Vim, fine. But you must wrap your head around its modality and awkwardness and accept to change your habit.
If you don't approach Vim with more flexibility, you'll never get full benefits.
If you decided to use Vim because it is trendy, I'll respectfully suggest you to stop there and go back to Sublime. Vim is weird, Vim is different, Vim is huge, Vim is a rabbit hole… if you are not ready to work with it and insist on not accepting its core design, you won't get far so why bother? You can pretty much live all your professional carreer without ever touching Vim. There's no shame in that.
Remapping / to <C-f>, on the other hand…

Remapping a key to Escape in Vim (German keyboard)

Okay, so I've been trying out Vim (the standard console version; my OS is Linux Mint 13) and I'd like to get rid of having to use the Escape key to change modes. Preferably, I'd like to swap the Capslock and Escape keys, but as far as I've heard, that's not possible within Vim itself. Most "solutions" I've found involve changing the key on a global level (using xmodmap or whatever), but I don't really want that. If there's an easy way to swap Capslock and Escape only in Vim, please let me know.
Another common thing I've heard of is using "Ctrl-[" as an equivalent to Escape. However, because I'm using a German keyboard with a different layout, that's not an option. So, I thought I'd use noremap <C-ü> <Esc> in Vim (the "ü" key on a German keyboard is in the same place as the "[" key on US keyboards), but that didn't work, either. I'm assuming that's because "ü" isn't an ASCII character. Is there any way to get either of these options working?
UPDATE: Well, this is strange. After experimenting some more, it seems that "Ctrl-ü" does work after all. I'm not sure what happened – maybe I messed up some encoding-related settings while trying different things? If there is no good solution for remapping capslock, I guess I will stick with "Ctrl-ü".
So, yeah, eventually I decided to go with <C-ü> because it doesn't conflict with anything else and because it's the same as <C-[> on US keyboards.
However, because I'm getting tired of using the German keyboard layout for programming (for example, to get "{" you need to type "Alt Gr-7"), I'm switching my keyboard to US-International, which essentially has a similar effect as far as Vim is concerned. It also helps if you want to want to get into the habit of touch-typing; you actually can't look at the keyboard because the keys aren't labeled "correctly" ;-)
A lot of people use jk:
inoremap jk <Esc>
You can also simply do <C-c>.
Here is another alternative that may be useful to you! It involves changing the keyboard file related to VIM. I found this suggestion on this youtube video
$ cd /usr/share/X11/xkb/symbols/
sudo vim pc
to edit the capslock key to escape, change the capslock line to read as follows:
key <CAPS> { [ Escape ] };
:wq # to write and close the file
Log out and log back into the machine and it should be updated!

Resources