To ignore linenumber's selection in Less inside Screen - gnu-screen

I would like to develop a selection-tool for Screen which ignores the leading spaces and numbers in selection.
Problems
What is the code which affects selection-tool C-a Esc in Screen?
To make an algorithm which ignores the linenumbers and the space at the beginning from the selection:
alt text http://files.getdropbox.com/u/175564/%20selection-less.png
The following Perl-regex seems to match the beginning of the line
{5}[1-9]{1-4} {8} # not tested
The selection tool apparently works by concatenating an increase in selection to the current selection. For instance, one line is selected. I select another one: a new line is added to the selection queue. The reverse is true also for a decrease in selection.
I want to put the Perl regex on when the selection obverses \n such that the ignorance of the line is considered.

I think you want to select columns. That'd be much easier than a regex.
From the screen manpage:
c or C to set the left or right margin respectively. If no
repeat count is given, both default to the current
cursor position.
Example: Try this on a rather full text screen: "C-a [
M 20 l SPACE c 10 l 5 j C SPACE".
This moves one to the middle line of the screen, moves
in 20 columns left, marks the beginning of the paste
buffer, sets the left column, moves 5 columns down, sets
the right column, and then marks the end of the paste
buffer. Now try:
"C-a [ M 20 l SPACE 10 l 5 j SPACE"
and notice the difference in the amount of text copied.
So, in your screenshot, press C-a [, move the cursor to the beginning of your text, press SPACE and then press c. Move to the end of your selection and then press SPACE again. Now you have the text you want.
Hope this wasn't too much info. You tagged it with beginner so I wasn't sure if you were a perl or screen beginner.

Related

Surround selection into array

I am aware about surrounding selection in quotes or braces
PhpStorm wrap/surround selection?
I need similar but surround selection into array
Assume I have text separated with newline or text separated with space
a
b
c
d
e
a b c d e
I need after selection get [a,b,c,d,e]
Please advice any IDE or method how to achieve this
A no-brainer solution
Make sure the following option is enabled:
For text separated with spaces:
Select the 'array-to-be', hit Ctrl+R and R again (to enter 'In selection' mode)
Type a space in the first field, , in the second
Click 'Replace all', hit Esc
With the text still selected, press [: the closing bracket will be added automatically
For multi-line text:
Select the 'array-to-be', hit Ctrl+R, enable 'Regex'
Type \n + in the first field, , in the second
Click 'Replace all', hit Esc
With the text still selected, press [: the closing bracket will be added automatically
The sequence of actions can be wrapped into a macro and assigned a single shortcut.
Vim + Surround plugin. Enter visual mode, select what you need and press S].
The first group could be created by:
:%s/\v(\w)(\n)*/\1,/g | exec "norm! I[\<Esc>A]"
It takes care of:
a
b
...
\v ........... very magic regex
() ........... regex group
(\w) ......... letters
(\n)* ........ zero or more line breaks
\1 ........... repeat content of the first regex group

Adding selected *sentences* for next occurrence

In IntelliJ IDEs, I can add any duplicate words by using the 'Add selected text for next occurrence' key shortcut. When multiple words are selected simultaneously, I can then change all of them at once using the IdeaVim plugin and ciw key presses.
However, I haven't been able to do this successfully for sentences. For example, if I select a group of text between double quotes: " hello there ", what ends up happening is that I will be able to select/highlight duplicate groups of hello there, but pressing any key results in me only updating the first selection of hello there and not the other selections.
I do realize that I can achieve the same effect simply by doing a find/replace through the entire page, but I like the convenience of adding an occurrence one at a time with just a press of a button. Any suggestions?
There are several ways to achieve the behavior you mentioned. However if you are looking for a method that have the visual effect similar to the Intellij, you may need to use the plugin for vim, such as vim-multiple-cursors.
Here are some vim's ways to do that:
Next Occurence + Redo Last Command:
/ to search for all occurence (/ hello there )
n to navigate to next occurence
v and arrow key/l to select region
Substitute region with s or delete text under region with x
n for next occurence and . (dot) to redo last command and repeat n + .
MACRO:
/ to search for all occurence (/ hello there )
qq to start recording macro to key q
Do step 2-4 from previous method
q to stop recording macro
# then q to apply the macro from key q
Note: If you want to repeat step 5 n times, simply append a number before # (ex. 5#q to apply macro 5 times. If there are only 4 occurence, then macro will only be applied 4 timers.)
Find and Replace:
:%s/ hello there /new value/g to globally replace " hello there " to "new value"
To replace the occurrence in certain place, use visual block v to select the block then :'<,'>s/ hello there /new value/g to replace only in selected area

Find and Replace/Insert 'CR', del Space wherever a user Clicks in a Word document

Short Version
In MS Word, is there a way to insert some text and remove some(simultaneously) at the point of blinking cursor or wherever a user clicks repeatedly.
This (Insertion/Deletion) can be achieved in the following ways:
Mouse click
(Ctrl, Alt or Shift) + Mouse click
Ctrl/Alt/Shift+Mouse click + (Any Key)
Long Version
I have text copied from various sources in different word files which I want to format in a particular style so as to match a given layout. Basically the text needs to be broken down into new lines/paragraphs at specific places which is given in the instructions. Instead of having to press 'Enter' and then remove/delete spaces at every line, I wish to do that with just one click per line using macro.
These files could be 500+ in number, so modifying all in one go using Macros is the preferred way.(Although I find it impossible when the point of insertion of 'Enter' can only be done manually on each file.) I have used Macros to achieve 90% of that however need one last step where a Macro can do the following:
Where ever the user clicks on the page, all space(regular, non-breaking space, white-space) until the next printed character is deleted.
An 'Enter' or Carriage-Return is inserted, so that the text moves to the next line.
Steps 1 and 2 are repeated at every click the user makes on the text.
Example Text
This is an example, of my text, which I need to split up, into different lines.
Expected Text
This is an example, of my text,
which I need to split up,
into different lines.
Notice that as 'Enter' is pressed at the end of these lines although they come in next line but usually a space character is there in front of those lines. Another approach is to click, delete the required spaces until the next character and then hit enter. I want either of these to be done automatically with just a mouse click or a minimum of key+mouse combo.
Something like Find ^w and Replace with ^p running at every place a user clicks, but with Macros.
Any help is appreciated.
This would be possible by defining a shortcut to your macro. So you would need to click at a position and use your shortcut to run the macro.
Eg. Add this to a module in your document
Option Explicit
Public Sub DeleteSpacesAndInsertEnter()
Application.ScreenUpdating = False
Selection.SetRange Selection.Start, Selection.Start + 1
If Asc(Selection.Text) = 32 Or Asc(Selection.Text) = 160 Then
Do While Asc(Selection.Text) = 32 Or Asc(Selection.Text) = 160
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeBackspace
Selection.SetRange Selection.Start, Selection.Start + 1
Loop
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeParagraph
End If
Application.ScreenUpdating = True
End Sub
and assign a shortcut to it.
It deletes all spaces & non breaking spaces right from the current cursor position and then inserts an enter.
Earlier, I thought of using Find and Replace at the place of cursor, Finding ^w and Replacing with ^p but this required me to Constantly lift the shortcut keys I assigned with my macro, otherwise it would just break the complete text at every word into paragraphs. Just pressing Ctrl and click would highlight the text between cursor and mouse click. All in all, I had to press (Ctrl+D), move the cursor to the new point using Click, AGAIN press Ctrl+D. Thus lifting 3 fingers for every change, making it impractical.
Pᴇʜ Macro helped
Ctrl+D+Click still doesn't work seamlessly. Works in 3 steps repeating.
Alt+D+Click worked almost flawlessly, with just one step repeating.
Applying this macro, even if I keep Alt+D(my shortcut) pressed all the time, simply clicking at the desired place does my job. Although Alt + Click anywhere in Word 2007 brings up a Research Window which updates as the text is clicked but in no way interferes with the job being done.
Thanks a lot everyone and especially P for all your help, really appreciate it.
Cheers

Finding the absolute position of a character in MS Word

Is it possible to find the position of a character in Microsoft Word?
By that I mean, let's say I want to create a macro to join up two full stops with a line. I can draw a line using x and y for the start and end points.
If I type a full stop character, is it possible to get the exact positioning of that character on the page? If so, it would then be possible to join two of these, but I would like to know if it is possible to get the X and Y positions for any character on the page.
This code will show the relative position of the current selection point. Just remember that a "page" in word is a moving target determined by the amount of text, margins, paper size, etc.
Sub getPosition()
Debug.Print Selection.Information(wdVerticalPositionRelativeToPage)
Debug.Print Selection.Information(wdHorizontalPositionRelativeToPage)
End Sub
¨

C Programming Format Adjustment

I am asking for some homework help. I am not asking for the answer,I just wanted to be pointed in the right direction.
I have a program in C which I am new to. I have to recreate a Unix tool using vi. Its job will be to read input and “neaten” it up. It reads in paragraphs of words and rearranges them such that they fit nicely onto a line of specified width, inserting line breaks as needed. A paragraph is separated from other paragraphs by one or more empty lines than changing the width with -w and changing to right alignment using -r.
Next would be to justify the text using -j so that every line with more than one word extends from the left to the right with max width. I need to apply integer division to calculate the total number of spaces that should have been seen by the time you finish a gap using Kevin Woods Si = i*S/G where S is the total number of spaces needed in the line, G is the number of gaps between words in the line and Si is the number of spaces that should have appeared by the end of the i'th gap. Lastly suppress line spacing from lines entered with more than a double line back into a double line.
The options should be cumulative—I can specify width, alignment, and skipping of blank lines together. The -r and -j flags should not be used together.
first step: metacode
main(arguments)
analyse arguments f.e. with getopt() for correctness and validity
read the original text
break the text into virtual paragraphs (identified by a double LineBreak)
for each paragraph
break it into lines of less than allowed (-w, default 80) characters
for each line that is not the last line of a paragraph
fill with spaces according to your algorithm and command line spezification
print out all lines
second step: coding
this is your task. Please come back, when you have code, that shows us, where you are stuck.