5

Is there a way to re-map Control-a in screen to Alt-a or something else, so I can use Control-A in Vim normally (increments the number under the cursor)?

alesplin
  • 218
  • 1
  • 6

4 Answers4

9

When in screen, just do "C-a a" instead of just "C-a"

ie Hit "Control-a" then type "a" again. The number under the cursor will increment!

Brad Parks
  • 674
  • 13
  • 19
3

From man screen:

-e xy
specifies the command character to be x and the character generating a literal command character to y (when typed after the command character). The default is "C-a" and `a', which can be specified as "-e^Aa". When creating a screen session, this option sets the default command character. In a multiuser session all users added will start off with this command character. But when attaching to an already running session, this option changes only the command character of the attaching user. This option is equivalent to either the commands "defescape" or "escape" respectively.

defescape xy
Set the default command characters. This is equivalent to the "escape" except that it is useful multiuser sessions only. In a multiuser session "escape" changes the command character of the calling user, where "defescape" changes the default command characters for users that will be added later.

escape xy
Set the command character to x and the character generating a literal command character (by triggering the "meta" command) to y (similar to the -e option). Each argument is either a single character, a two-character sequence of the form "^x" (meaning "C-x"), a backslash followed by an octal number (specifying the ASCII code of the character), or a backslash followed by a second character, such as "\^" or "\". The default is "^Aa".

Dennis Williamson
  • 60,515
  • 14
  • 113
  • 148
  • Thanks. Seriously don't know how I missed that. Or else way back when I first started using screen I just had no perceived use for modifying the command-character and forgot about it... – alesplin Sep 28 '10 at 22:17
1

Found a possible solution:

map something unrelated in Vim to like so: map <Leader>inc<CR> <C-a>

This is not a perfect solution, or maybe not even the "right" solution, but it works for now.

alesplin
  • 218
  • 1
  • 6
0

My problem was just symetrical to yours: I wanted to keep working the usual way with screen, using the usual Control-A, and also use the increment in vim.

I just added these two lines to my .vimrc file:

:nnoremap <A-a> <C-a>
:nnoremap <A-x> <C-x>

, so that I now use Alt-A and Alt-X in vim to increase and dicrease numbers.

Pierre
  • 101
  • 2