1

I want to make a separator in code with (for example) 50 '#' chars like that:

##################################################

In vim or emacs it can be done by "repeat input" feature.

Do you know any way to repeat a character n-times in Eclipse? (would be great without plugins)

AvrDragon
  • 7,139
  • 4
  • 27
  • 42

2 Answers2

1

The options would include installing a VIM plugin for eclipse as answered in this question : What vim plugins are available for Eclipse?

OR,

A very simple AHK script would do this beautifully :

The code I just tested that would do this is :

#Persistent
#SingleInstance force
SetTitleMatchMode 2

Hotkey, IfWinActive,ahk_class SWT_Window0 
    Hotkey,#r,repeatchar
    Hotkey,!+^r,repeatchar
return

repeatchar:
    sendinput ^c ;copy the selected character
    sendinput {%clipboard% 50}
return

This script would repeat the selected string 50 times in Eclipse on pressing Windows + R or Alt + Ctrl + Shift + R.

I have shared the script as well as an executable for it here. The executable was created by compiling the script. If you are uncomfortable executing it, you can download the portable version of AHK from here. With the portable version, you will have to manually associate the .ahk files to Open with AutoHotkey.exe.

Here is a (not-so-great) screen-cast showing this in action.

Community
  • 1
  • 1
Ashutosh Jindal
  • 18,501
  • 4
  • 62
  • 91
1

You asked for an alternative without any plugin. Input the # character at some place and select it. Now hit Ctrl-F to open Find/Replace, select the "Regular Expressions" option and use $0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0 as replacement string. It will replace the search term by 50 times itself. As the dialog remembers all entries, you can easily reuse that pattern the next time.

Bananeweizen
  • 21,797
  • 8
  • 68
  • 88