With the world shrinking to become one global village, with the leading MNCs of the world exalting the need for Virtual Teams and with heavy emphasis on dividing a problem into sub-problems, each to be handled in parallel, Real-time Collaboration has become simply inevitable. As such, there is a surge in demand for solutions which can help in real-time collaboration rather than the traditional method of granting access to only one user at a time for doing his work and then passing the floor to the next user. It does not come as a surprise that Google is already creating the Waves in the field of Real-time Collaboration.
In the past, the emphasis was on Non-real time collaborative systems like Microsoft Sharepoint, SunForum etc. Although these applications allowed multi users to work on a single document concurrently but being non-real time, only one user could hold the lock to edit the document at a time and the other users were held waiting. This defies the actual concept of "collaboration" which has to be mutual i.e. interaction between all parties involved. Many researchers from across the globe have been working to address this issue. For instance, CoWord and CoPowerPoint are the recent innovations which serve as a solution to the problem raised above. The collaboration technique used here does not modify the original application, but rather exploits the Microsoft APIs to build collaboration on top of Microsoft Word and PowerPoint. A similar approach would be used by the author to extend functionalities to CoVIM - a multi-user collaborative version of single user text editor called VIM.
The main purpose of this project is to fully convert a single-user text editor called VIM into a multi-user collaborative application called CoVIM. Being an on-going project carried forward from previous FYP student, the focus of the author's project is to incorporate various new features in CoVIM application. The scope of the project is as follows:
CoVim is an on-going project aimed to overcome its limitations with continuous research and future developments. At present, the complexity of Vi script and limitation of time has given rise to following limitations:
In terms of the Resources utilization, the Project is not very expensive. Both the hardware and the software required for the completion of Project are easily available. The software is charity-ware and easily downloadable.
The Report has been divided into several chapters:
For long, the world has realized the need for real-time collaborating techniques to turn single user applications into multi user applications. This chapter would accredit the prior work that has been done in this area and the highlight the concepts that would be applied in the implementation of CoVim.
Sun et al (2006) recognises the previous work that has been done in this field and has classified them on the basis of their approach to create multi-user applications out of single-user applications. According to this classification, following approaches exist:
The generic-application sharing approach has been modelled after a chalkboard used during meetings. Following are the three fundamentals of this approach:
However, these basic fundamentals are a hindrance to the collaborative work that requires free and concurrent interactions. Moreover, a centralized architecture also leads to poor responsiveness and inefficient network usage.
This approach attempts to replace the centralized architecture with a Replicated architecture wherein there are multiple instances of the shared application in the system. However, Technical challenges associated with replication like consistency maintenance of the state and view of the shared application, management of external resources (e.g., files, clocks, and network connections) and support for spontaneous interactions (e.g., accommodating late-comers) remain an open challenge to solve under the constraints of generic application sharing environments.
Flexible JAMM (Java Applets Made Multiuser) spearheaded this approach. The implementation is based on an object-oriented replicated architecture where certain single-user interface objects are dynamically replaced by multi-user extensions to allow for simultaneous editing. This approach brought about a paradigm shift in seeking generic solutions at the operating system level to exploring solutions at the application interface library level. Although this approach allows for concurrent work, relaxed WYSIWIS, flexible control, however it requires the application platform to have capabilities like process migration, runtime object replacement, and dynamic binding, which are not provided in many systems. Moreover, the coordination policies are embedded in the substituted collaboration-aware runtime environment of the single-user application, which according to Furuta and Stotts and Li etc is a major source of inflexibility.
This is an innovative approach to Leveraging single-user applications for supporting multi-user collaboration. Sun et al. (2006) explains that this approach has the potential to significantly increase the availability and improve the usability of collaborative applications. The underlying fundamental of TA approach is to convert existing and new single-user applications into collaborative ones, without changing the source code of the original application. The cornerstone of the TA approach is the operational transformation (OT) technique and the method of adapting the single-user application programming interface to the data and operation models of OT. The aim is to not only retain the functionalities and "look-and-feel" of the single-user counterparts of the shared application, but also provide advanced multi-user collaboration capabilities for supporting multiple interaction paradigms, ranging from concurrent and free interaction to sequential and synchronized interaction, and for supporting detailed workspace awareness, including multi-user telepointers and radar views. The TA approach and generic collaboration engine software component developed from this work are potentially applicable and reusable in adapting a wide range of single-user applications. Using this technique, CoWord, CoMaya, CoPowerpoint have already been developed and this project report would extend the TA approach to develop CoVim. The fundamentals underlying this approach are as follows:
As a result of the above mentioned design considerations, Sun et al (2006) describes that collaborative applications based on the TA approach are able to achieve fast local response, concurrent work, relaxed WYSIWIS viewsharing and detailed workspace awareness - the up-to-the-moment understanding of other users' interactions with a shared workspace in order to coordinate users' activities.
Operational transformation(OT) is a technology for supporting a range of collaboration functionalities in advancedgroupwaresystems. OT was originally invented for consistency maintenance andconcurrency controlin collaborative editing of plain text documents. Two decades of research has extended its capabilities and expanded its applications to include group undo, locking, conflict resolution, operation notification and compression, group-awareness, HTML/XML and tree-structured document editing, collaborative office productivity tools, application-sharing, and collaborative computer-aided media design tools. Recently, OT has been adopted as a core technique behind the collaboration features inGoogle Wave, which is taking OT to a new range of web-based applications.
Collaborative systems using OT typically adopt a replicated architecture for the storage of shared documents to ensure good responsiveness in high latency environments, such as the Internet. The shared documents are replicated at the local storage of each collaborating site, so editing operations can be performed at local sites immediately and then propagated to remote sites. Remote editing operations arriving at a local site are typically transformed and then executed. The transformation ensures that application-dependent consistency criteria are achieved across all sites. The lock-free, non-blocking property of OT makes the local response time not sensitive to networking latencies. As a result, OT is particularly suitable for implementing collaboration features such as group editing in the Web/Internet context.
The basic idea of OT is to transform (or adjust) the parameters of an editing operation according to the effects of previously executed concurrent operations so that the transformed operation can achieve the correct effect and maintain document consistency. It can be illustrated by the following example:
There exist two underlying models in each OT system:
VIM is a text-editor which does not only have all commands from the Unix program called Vi, but many new powerful commands as well (Appendix). So much so that it's name was changed from being "Vi IMitation" initially to "Vi IMproved". (Duperval, 1998)
Since VIM is an editor and not a word-processor, the focus was always on entering the text effectively and not typesetting it. As such today, VIM is one of the most powerful text-editors around and one of the favourites of many programmers and users of Unix-like OS's.
A brief history:
VIM is a portable cross-platform editor. It runs on most UNIX flavors as well as Widows, MacOS, DOS, VMS etc. Many several fronts to VIM exist like console, Motif, KDE, Windows GUI, Gtk+ etc.
All commands can be given to VIM with the keyboard. This has the advantage that one can keep his fingers on the keyboard and his eyes on the screen. For those who want it, there is mouse support and a GUI version with scrollbars and menus. Although Vim supports UTF-8 and has partial support for BIDI, it is not recommended for Hebrew editing.
There are a lot of fans of the 20-year-old vim editor. And no, they are not dinosaurs who don't want to catch up with the times - the community of vim users just keeps growing. There are definite reasons why the vi/vim editing model is just superior to any other out there. And one doesn't need to be a UNIX whiz to use it, either: vim is available for free for almost any platform out there; and there are plug-ins to get the functionality inside all major IDEs. Let's see what makes it so popular:
VIM can be used in various modes. It has got 6 fundamental modes and 6 derived modes (italicised in table below), thereby enabling the flexibility of moving across in 12 modes.
Mode How to use this Mode?Insert Insert mode can be reached in several ways, but some of the most common ones are<a>(append after cursor),<i>(insert before cursor),<A>(append at end of line),<I>(insert at beginning of line),<C>(change to end of line), and<s>(substitute characters). This mode is, in simple terms, used for inserting new text in the buffer.
Normal Also known as the Command mode, whatever the user types in this mode are some kinds of commands. This is the default mode in Vim. It is mainly used for navigation and manipulation of text by the use of simple commands. For e.g., typing "dd" in this mode will delete a line in this mode, typing ":" will take the user to Commandline mode, etc. If the user is in any mode, he can always return to Normal mode by pressing <Esc>.
Visual Visual mode is the visual representation of the Normal mode wherein the text on which any command is to be executed will be highlighted simultaneously so that the user could see for himself what text he is going to alter. In a nutshell, the mode is frequently used for navigation and manipulation of text selections. Details in Section 6.5.
Select Similar to visual mode, but Select mode has a more MS-Windows like behavior. This means that if the user types a single character it replaces the selection. Of course he loses all the one key operation on selection like<U>to make a selection uppercase. The user normally starts selecting a text to enter select mode or uses "gH" command to enter this mode. Details in Section 6.5
Command-line Behaves similarly to a command prompt where user is given one line to input his command after which it would be interpreted as a command, search or filter. At the end of the command, user goes back to the Normal Mode. For e.g., /word will find the text 'word' in the document and highlight all instances. Then :s/old/new is used to substitute new text for all occurrences of old text.
Ex-mode Similar to the command-line mode but optimized for batch processing i.e. user can enter multiple commands continuously until they leave the mode. The user can enter the mode by pressing Q in Normal Mode and exit by typing :visual. The user uses this mode to update (save) his changes to file or quit from the application.
Operator-pending Similar to Normal mode, it is used for accepting motion to determine the text which will be operated on. For e.g., w means that a word will be operated upon. $ means that the text from current position to end of line will be operated upon. Operators are d for deletion, > for indenting. So d$ will delete the text from cursor till end of line. Thus, the user uses this mode when he has a range of text to be operated upon and that range can be determined by a motion command. Details in Section 6.3
Replace Similar to the Insert mode but typing a new character overwrites the existing ones. The user enters this mode by pressing Insert key or typing R command in Normal mode. Replace Mode should be used when a majority of text is to be overwritten with a new text. For minor text replacements, user can always use r command in Normal mode. Details in Section 5.1
Virtual Replace Similar to Replace mode, but instead of file characters you are replacing screen real estate.
Insert Normal Entered when CTRL-O given in Insert mode; this is like Normal mode, but after executing one command Vim returns to Insert mode. The mode is used when the user mainly wants to work in the Insert Mode but wants to use a few Normal mode commands off and on. For eg, type <Ctrl-O>x to delete the current character and go back to typing in Insert Mode.
Insert Visual Entered when starting a Visual selection from Insert mode, it ends in Insert Mode once the visual selection is completed. The mode is used when the user wants to use visual mode for a short while and quickly return back to the Insert mode for creating text.
Insert Select Entered when starting Select mode from Insert mode, it ends in Insert mode. The user uses this mode when he wants to create text, select it to manipulate it and then go back to creating new text in the buffer. To enter this mode, just select the text using mouse while in Insert Mode.
The figure on the left describes the architecture of the technique used to model CoVim:
The CA is the most vital component for real-time collaboration.
It serves 2 specific purposes:
Following are the various modules of CA:
Data Addressing is regarded as the way how the textual information is referenced, and how it is being viewed by the user in an editing session. In Vim, every new file or existing file loaded into memory for editing is termed as a buffer. The buffer maintains information such as cursor positions, marks and text information. Although characters in a plain text document may be represented in a sequential manner, information in these buffers, including position of cursors and characters, however, is referenced by two parameters: line and column. Every buffer starts with line one and every line starts with column one. But CoVim still uses linear addressing space to access the buffer information. This has been possible because of line2byte method in Vi-script (i.e. Vim API) which converts information in a line into its bytes equivalent. And it is known that every character 1 byte, so byte equivalent of a line is actually number of characters present in the line. Similarly, byte2line method returns the line number of the character given the byte is known. And using little maths, the column of that character can also be found. This is needed because to correctly replay the effect, the linear position would have to be translated back to two parameters, line and column, so that the character can be correctly inserted at the correct position.
With the linear addressing scheme created, CoVim could implement the basic OT data model for address adaptation. In this approach, the user's point of view of the document would remain the same, where they would still visualize and refer characters' position with line and column. However, in the API's point of view, the modified addressing scheme had allowed characters to be accessed by their position references in the new linear addressing space. The relationship between the characters in the user interface and their position references in the linear addressing space is illustrated below:
To further aid the explanation and comprehension of CoVim's implementation, this section describes how messages are being exchanged between the SA and CA.
Vim has provided an Object Linking and Embedding (OLE) interface which enables Vim to act as an OLE automation server, accessible from any OLE client. By making use of the interface, OLE clients would be able to execute OLE methods, which include sending keys (SendKeys) to and evaluating (Eval) script functions defined in Vim.
Vim script has a built-in method called libcall which is used to call functions in external libraries. Vimcom.dll serves as the external library and also acts as an intermediary between the SA i.e. Vim and CA. Messages were passed from Vim into the function as arguments which were then forwarded to the CA via Inter-Process Communication methods. The method used in this case was SendMessage, which help guarantees the message is received before returning the libcall function. This is to ensure that no messages were lost which could cause inconsistency problem and disrupt the collaboration process.
The task of intercepting and processing the events at the local side is done by LOH. In CoVim, Vim script is used for interception of events such as key inputs. In CoVim, an array of all possible keys is created. This array is mapped and unmapped whenever the user enters/exits the Insert Mode. Similarly, all these keys behave as commands in Normal/Visual/Operator pending modes. So, they are mapped to methods which simulate the designated command on the remote sides. For e.g., r is mapped to the Replace method in Normal Mode which simulates r on the remote sides of the shared application Vim using libcall method as mentioned in Section 4.4.2
Adapted Operations (AO) play a very important role in the implementation of CA for the following reasons:
As seen from the figure xxx, the POs available in GCE are Insert, Delete and Update. But being a text editor, all the operations in Vim can be manipulated in terms of Insert and Delete solely. This is because the text is never italicised or underlined or changed in font or colour, so Update is redundant. Thus, AOs only for Insert and Delete are needed in Vim.
It is necessary that the LOH and ROH modules in CA are able to run concurrently as two processes but they should be mutually exclusive as well i.e. at one time only one of them should be active. This is done to enforce the atomicity of local and remote operations. For instance, during an atomic local operation, from the point where the local interaction is intercepted, till the time where the interaction is replayed locally, any remote operations received should not be allowed to process. But because of different communication paths taken for sending and receiving of messages, it is quite possible that the remote operation gets processed by CA before the local operation is played. For example, local operation O(L) = Insert[1,"x"] and O(R) = Insert[1,"y"]. Now since O(L) is generated before O(R) is received, the local side should contain "xy". But if O(R) is replayed before O(L), then the local side text would be read as "yx". However, on the remote side, the text should look like "xy". This would lead to inconsistency of the documents at two sides. So to avoid this trouble, it is possible to force the local operation to be played first. This has been done by implementing a lock in the Vim script. Now the local operation would first try to acquire this lock. Upon successful acquisition only, the function (operation) would perform its task; else it would return ignoring the input. Now when the remote operation comes to the local side, it would not be able to acquire the lock if it has been taken by the local operation. Once the local operation is replayed, it would give out the lock to remote operation to replay its effect.
To facilitate the various sites to collaborate, it is necessary to appropriately propagate and receive AOs.:
It is important to see the format of serialized AO:
siteid, adaptedoperation, numofprimitiveoperations {,type, pos, length, data}, type, pos, length, data
where:
siteid: id of site where AO is generated
adaptedoperation = string called "AO"
numofprimitiveoperations = number of POs in which this AO is to be translated into
type = type of PO i.e. Insert or Delete
pos = position where the PO takes place
length = length of data modified
data = text to be inserted/deleted
, (comma) acts as the delimiter.
For example, following are valid serialized AOs:
g:CAAddress[bufnr("%")].',AO,2,Delete,'.ipos.','.strlen(keys).','.keys.',Insert,'.ipos.',1,'.a:key
g:CAAddress[bufnr("%")].',AO,1,Delete,'.ipos.','.strlen(keys).','.keys
The user can enter Replace mode with the "R" command in normal mode. The "Insert" key on keyboard toggles the mode between Insert and Replace.
In Replace mode, every new character typed overwrites the original character written in the buffer. If there is no character to delete (at the end of the line), the typed character is appended (as in Insert mode). Thus the number of characters in a line stays the same until the end of the line is reached. If a <NL> is typed, a line break is inserted and no character is deleted. Even <Del> behaves the same way as in Insert Mode i.e. deletes the character next to the cursor. The only exception being the use of <BS> i.e. Backspace. Backspacing in Replace Mode actually deletes the changes. The characters that were replaced are restored. If the user had typed past the existing text, the characters added would be deleted. This is effectively a character-at-a-time undo.
Effectively, writing in Replace Mode is combination of 2 primitive operations: Deletion and Insertion.
The user can exit Replace Mode by pressing <Esc> to enter Normal Mode.
Alternately, VIM provides 'r' command in Normal Mode for quick replace of a character. It saves the user the trouble of shifting mode to replace the characters.
The syntax of replace command is given as below:
<Esc><count>r<x>
Where:
<Esc> is to enter the Normal Mode
<Count> is the number of characters to be replaced
<x> is the new character to overwrite the existing ones
Let's see how it works:
Assume the following text is written in a file and the cursor is on R of replace:
"I am going to test Replace command here"
Case 1: x is any key but Enter
Now if the user presses <Esc>3rt
Buffer: "I am going to test tttlace command"
Case 2: x is Enter key
Assume now he presses 2r<Enter>
Buffer: "I am going to test tt ace command here"
Where n means NewLine and r means carriage return
So, it is observed that even though both 't' and 'l' character have been replaced since count=2 but only one has been inputted.
Summary:
If x=Enter, Only 1 newline replaces the <count> number of characters
Else, <count> number of x replaces <count> number of characters
Note: x cannot b Del or BS. It has to be a printable character.
After execution of this command, the user stays in Normal Mode. Thus, for minor replaces, it is convenient to use 'r' command than changing the mode to Replace. Anyhow the author has covered both the implementations in his project.
Refer to Appendix B for Codes.
Once the code has been written, it is essential to test it for all possible imaginable inputs a user can enter. Even while the code was being written, the author had been running various Unit tests to ensure that the changes he is making to the code are yielding the expected results. In totality, the author has come up with following test cases to stress-test the replace functionality. What comprises of an exhaustive Test case package?
Remember that the syntax for 'r' is r. Let's now focus on test cases for 'r' replace command. Assume all commands to be independent of any previous command. Assume the text written in the test file is:
"I am going to test Replace command."
Now, let's see what comprises of an exhaustive test case package for Replace Mode:
Note: <replaceobstructlist> : {Left, Right, Up, Down, PgUp, PgDown, Home, End, Esc}
Let's now analyse few test cases for Replace Mode. Assume empty file. Also, assume all the operations mentioned in Test case are done in succession. The underlined shows the cursor position
The following testing strategies have been followed by the author in order to stress-test the CoVim system:
Now let's look at the various test cases on Mode by Mode basis.
The Insert Mode of Vim is like a common text editor mode e.g Notepad. Thus checking for Insert Mode is basically checking if entering all keys on local side propagates them to remote side as well.
Let's see what makes an exhaustive set of test case in Insert Mode:
Unfortunately, meta-keys have not been handled till the time of printing of this report and that's the reason for discrepancy between actual and expected result:
In a scenario, where the operation only takes place on the Local side and does not propagate on to the remote side, one can use the following command to force sync all the instances of the application:
:CoVim sync
But, this command induces an extra NewLine character on the remote side which leads to error propagation because of Inconsistency in 2 instances of the shared application. Look at the following example:
On the Local side (see left), we just have one string of text, while on the remote side (see right), after execution of the sync command, we have text string plus a newline. Now this newline is not understood by the local side. So if the user types something in the newline space of right instance, it would be appended on the left instance of the application without the newline character in the buffer. See the above figure.
The common syntax of commands in Operator-pending mode is as follows:
{<count1>}<operator>{<count2>}<motion>
OR
{<count>}<operator><motion>
Where count=count1 x count2
Operator = c, d, y, > etc
Motion = j, k, l, aw etc
Now following cases make exhaustive test cases:
Assume that the test file contains
"Testing for Operation-pending Mode"
Some of the test cases are listed below (Assume commands to be independent of each other):
The fact that VIM has a Normal Mode apart from just Insert Mode makes the editor special. Normal mode is basically used for executing various commands on the text like cut, copy, paste etc. Let's test the various commands available in Normal Mode in CoVim. To stress-test various commands, one should pay attention to operators, motion, count and undo commands
Now lets see what makes an exhaustive test case for Normal Mode:
Assume the following text written in the workspace and all commands to be independent of each other:
This text, would be edited by Normal Mode commands
Example 1
"This text, would be edited by Normal Mode commands"
On the above text, execute this command: [email protected]/* */
Example 2
"This text, would be edited by Normal Mode commands
Testing the Join command"
On the above text, if the user executes this command: 2J, the 2 lines will be joined as:
"This text, would be edited by Normal Mode commands Testing the Join command"
So, the <NL> is replaced by a <Space> and the cursor shifts to beginning of the newly joined line.
Example 3
"This text, would be edited by Normal Mode commands"
On the above text, execute this command: ma0d`a
Case 3: Test operator commands with motion
In Section 6.3, the operator commands were tested. Let's test the various motions provided in Vim. Assume the operator command to be used be "d".
"This text, would be edited by Normal Mode commands text"
More often than not, it is not easy to decide which command will move over the text that the user would want to change. In such a scenario, Visual mode comes in handy. It starts highlighting the text as the user is typing the required command.
For example, to delete from halfway one word to halfway another word:
This is an examination sample of visual mode
---------->
velllld
This is an example of visual mode
While doing this, the user doesn't really have to count how many to press "l" to end up in the right position. He can see what text will be deleted (in this case: ination sam) because it would be highlighted on screen.
Thus, it is observed that Visual mode is a visual interpretation of the normal mode commands wherein an operator is needed. So, no special test cases are required to test the Visual mode. The operator commands working in Normal mode would work in Visual Mode as well.
Select Mode, on the other hand, is the visual representation of the Insert/Replace Mode. The user can select the text using mouse or keyboard and the new key entered would replace the existing text. Again, no special test cases are required for Select Mode. The only difference between replace and Select mode is that a lot of text can be selected and replaced while in replace mode, it is one at a time overwriting of text.
The project was initiated in order to extend the implementations in the CoVIM so that it can be ready for release. As such, it was to be ensured that CoVIM undergoes a lot of testing from a user's point of view. Thus, in this project, the author has been successfully able to integrate the Replace Mode to CoVIM and also has been able to test the current implementations of mappings in other modes. The test results have helped CoVIM come a long way in understanding and adapting to the erratic inputs of the user.
Nothing in the world is fool-proof and there is always a scope for improvement. A lot has been done till date to prepare CoVIM for its official release. A lot of improvements are still on-going. A detailed study of behaviour of Vim is required to analyse the working of all its different modes. A good understanding of the User manual will be the first step towards further advancement as it lists various exceptions in VIM's behaviour. Following are some key issues that can be taken into consideration to further make CoVIM mimic VIM-like behaviour:
There have been numerous improvements in Vim over Vi. Given below is the summary of few such improvements:
The motion commands can be used after an operator command, to have the command operate on the text that was moved over. That is the text between the cursor position before and after the motion. Operators are generally used to delete or change text. The following operators are available:
c change
d delete
y yank into register (does not change the text)
~ swap case (only if 'tildeop' is set)
g~ swap case
gu make lowercase
gU make uppercase
! filter through an external program
= filter through 'equalprg' or C-indenting if empty
gq text formatting
g? ROT13 encoding
> shift right
< shift left
zf define a fold
The motions that can be used are:
aw a word (with white space)
iw inner word
aW a WORD (with white space)
iW inner WORD
as a sentence (with white space)
is inner sentence
ap a paragraph (with white space)
ip inner paragraph
ab a () block (with parenthesis)
ib inner () block
aB a {} block (with braces)
iB inner {} block
a< a <> block (with <>)
i< inner <> block
a[ a [] block (with [])
i[ inner [] block
User modes in VIM. (2017, Jun 26).
Retrieved November 21, 2024 , from
https://studydriver.com/user-modes-in-vim/
A professional writer will make a clear, mistake-free paper for you!
Get help with your assignmentPlease check your inbox
Hi!
I'm Amy :)
I can help you save hours on your homework. Let's start by finding a writer.
Find Writer