Vim cursor shape depending on current mode - ssh

I currently use MacVim for a lot of my editor needs but occasionally I need to edit files remotely over SSH. In MacVim the shape of the cursor varies depending on your current mode, i.e.
command mode -> block cursor and insert mode -> vertical bar cursor,
which I find very helpful.
Is there a way to replicate this behavior in a .vimrc file, so that it can be used remotely?

Try :help termcap-cursor-shape. There are two options there you can set:
&t_SI - Shape when you enter insert mode.
&t_EI - Shape when you exit insert mode.
In order for this to work, the Vim you are using must have been compiled with +cursorshape feature.
I personally always use gvim, so this was never a problem :). Hope this helps.

Related

How to use the terminal tabs feature in mintty/MSYS2?

According to https://github.com/mintty/mintty/issues/944 since mintty 3.5.1 there should be a tab bar where you can open multiple tabs with terminals in parallel. For that reason I performed an installation of MSYS2 which includes mintty 3.5.1, as this seems to be the way how to use the mintty. (I verified this with invoking mintty with -V.)
However, I do not find no possibility for opening and/or managing tabs in the UI.
My requirement: I would very much like to have tabs for organizing terminals in parallel.
My question: What's going on here? Did I miss something? Do I need to execute the mintty/MSYS2 with some special commad line options? How can I enable tabs?
You could use --tabbar option when staring minnty. see here for more information.
It was difficult for me to figure out how to turn this feature on. The answer is sprinkled through the comments of this issue, but not in one place. Therefore I'm posting this to save time for others. Here's how you turn the feature on:
Add --tabbar=4 or --tabbar to the windows shortcut that opens mintty:
The 4 is documented here:
no geometry handling; terminal session windows are separate [default]
sync. position/size when switching/launching/closing a session
sync. also when window is moved or resized
sync. also when window is minimized
sync. also when window is started separately
If you'd like to create new tabs with ctrl-shift-t, close tabs with ctrl-shift-w, switch to previous tabs with ctrl-shift-tab, and switch to next tabs with ctrl-tab, add -o "KeyFunctions=t:new-window-cwd;w:close" as an option to that same line.
Personally, I'd like to have ctrl-t/w open and close tabs, respectively, but the only way I've figured how to do that is to add this option: -o CtrlExchangeShift=yes. The problem is, that changes all ctrl-shift commands to become ctrl commands. That means ctrl-r no longer searches bash history.
When you run the shortcut and create some tabs, mintty will look like this:

How do I disable auto-indent on Kakoune?

I don't like text editors that perform auto-indentation in my code, because of various reasons, but Kakoune seems to be hardcoded to do that? Is it possible to disable it?
I couldn't find any defined "hooks" for indent, just for autocomplete.
Just run :set global disabled_hooks .*-indent in your Kakoune window or put
set global disabled_hooks .*-indent
in your kakrc.
Found the answer at https://github.com/mawww/kakoune/wiki/How-To#disable-auto-indentation, although it wasn't immediately clear what "disabled_hooks option" meant.
It's not strictly an answer to your question, but I sometimes need to paste text into kakoune over an SSH session from Windows. In vim, I could do :set paste/:set nopaste.
In kakoune, I found I can enter insert mode with disabled hooks (see "Disabling Hooks" in https://discuss.kakoune.com/t/hooks/544) by typing in a \ first, e.g. \i. Then I paste the text without indentation fuss and can leave insert mode again. Neat!

How to display current mode IdeaVIM is in?

I would like to see which Vim mode I am currently in while using IdeaVIM in PyCharm, or any other JetBrains IDE.
It happens that I select a single character with the mouse (e.g. accidental double-click on a single letter) and the cursor then doesn't distinguish properly between normal mode and visual mode, which makes for awkward situations after hitting a few keys.
Is there a way to display the current mode at all times in the status bar or somewhere else that I have missed?
Put set showmode into your ~/.ideavimrc or vote for https://youtrack.jetbrains.com/issue/VIM-943.

Changing Vim Cursor in MobaXTerm

I recently updated from MobaXterm 7.7 to MobaXterm 8.1 on my Windows machine for my SSH and X11 needs.
Since doing that, my Vim cursors have stopped changing when I enter different modes (i.e. insert mode) -- the cursor is now always a block cursor. Additionally, I noticed that if I change the default Terminal Cursor setting in MobaXterm, the console cursor remains a block cursor regardless (a possible bug?).
In the past, I added the following lines into my .vimrc file to address cursor shapes, but since updating to MobaXterm 8.1, this no longer works.
let &t_ti.="\e[1 q"
let &t_SI.="\e[3 q"
let &t_EI.="\e[1 q"
let &t_te.="\e[0 q"
I'm curious what is causing this.
After doing some research, I found the following line in MobaXterm 8.0 changelog:
Improvement: The embedded terminal is now based on a plain PuTTY engine
If I recall correctly, you have limited ability to change cursors within the PuTTY environment. Does this mean I can no longer change my Vim cursors while using MobaXterm? Alternatively, is there some .vimrc command I don't know about? Is this all just a bug or is it intended?
Thanks!
None of PuTTY's cursor-related control sequences end with "q". It sounds as if MobaXterm's developers do not want to bother with applying their patch.
Checking current PuTTY source (0.65), it has (as expected) "limited" ability to change the cursor's appearance. It handles these escape sequences when the SCO/ANSI feature is enabled:
\e[=2c (block cursor)
\e[=1c (normal cursor)
\e[0c (hidden cursor)
\e[=x;yC (draws cursor from scan lines x to y)
Also, the cursor can be changed to/from a block cursor (for normal "VT220" mode) using \e[?34h and \e[?34l.
colors customize – > cursor type

Disable use of MacVim keyboard shortcuts

Is there any way to disable keyboard shortcuts in MacVim? I mean the shortcuts like Cmd + s for example, I want to convince myself to use things like :w, but I can't do so if I can save the file using Cmd + s, you get me?
But I of course, still want to use the GUI, so is there any way to disable these, without stoping using the MacVim GUI?
Thanks for your help. BTW I made a Google search and wasn't able to find an answer.
EDIT:
Following #ChrisJohnsen's suggestion, I have already tried the following with no success:
if has('gui_running')
macmenu File.Save key=<nop>
macmenu File.Save\ As\.\.\. key=<nop>
endif
EDIT 2:
I moved the error I'm getting over to this other question: When I try to run vim in command line I get Python errors
There is no simple way to disable all of the pre-defined Mac-style keyboard shortcuts, but you can definitely change/disable any of them. The important command is :macmenu (see :help :macmenu); it lets you set the Mac-specific properties of any Vim menu item (mostly Mac-specific keyboard shortcuts and Mac-specific actions (e.g. open/save dialog boxes, window manipulations, etc.)).
macmenu File.Save key=<nop>
macmenu File.Save\ All key=<nop>
macmenu File.Save\ As\.\.\. key=<nop>
The thing is that :macmenu commands are only effective if they are in your .gvimrc file.
If you do :e $VIMRUNTIME/menu.vim and search for macm, you will find the list of pre-defined shortcuts and actions. Copy the desired lines to you .gvimrc and replace key=<whatever> with key=<nop>. You can also wrap them in if has("gui_macvim") / endif if you need your .gvimrc to work on multiple platforms.
MacVim has only one "advantage" over plain Vim: it supports native Mac OS X shortcuts. If you don't want those shortcuts you might as well simply use plain Vim.
FWIW, when I switched from TextMate I, too, found after a while that these native shortcuts were an obstacle on my way to learning Vim. My solution was to focus my efforts on plain Vim. After a week in the terminal you should be able to completely disregard those shortcuts.
I'd advise you to take a little pause and think about doing things in a more appropriate order:
In the terminal, do $ vimtutor as many times as needed.
In the terminal again, use $ vim for simple tasks first then more complex tasks. There's a predictable productivity hit at the beginning but it will last only a few days/weeks.
Once you have reached your previous level of productivity, you can start to fly Vim full-time. At that point, using MacVim or GVim or plain $ vim should make no difference whatsoever.
Bonus points for not relying too much on plugins, other people's vimrcs or "distributions" like janus or spf13…