📜 ⬆️ ⬇️

Using Midnight Commander as IDE (codejump)

Preamble…


I have long been looking for an editor capable of satisfying my modest requests in terms of writing C code. It should:
  1. work in the console;
  2. be as fast as possible;
  3. support syntax highlighting;
  4. be able to navigate through the source code (go to the definition of functions, display properties of objects, etc.);
  5. set bookmarks in the text and navigate through them;
  6. display line numbers;
  7. allow conveniently and intuitively format the source code of the program;
  8. have the usual keyboard shortcut for me, or be able to override these combinations;


There are not too many such editors - vim, emacs, motor and a small group of disparate editors in the 0.0.7-pre-alfa stage. The first two are good for everyone, except for one small, but essential detail for me - they are very specific in terms of keyboard shortcuts and behavior. After a long sitting in vim, it was extremely annoying to spoil editable text in far. Most of all, the constant pressing esc (on the machine after vim) was strained to far, which sooner or later led to the fact that the typed text or simply did not save after the next escape or deteriorated. And vice versa, after far it was difficult to switch to typing in vim. In other words, I got a bunch of problems instead of the pleasure of writing code :)
Motor was all good, but he didn’t keep Unicode and wasn’t updated for a significant time (the last ovy on their website was dated 2000th year). After tormenting for six months, I decided that you should not try to teach the old dog new tricks, you need to find some other editor more familiar to me. Oddly enough, the Midnight Commander's built-in editor turned out to be. Below is one of the features of mc 4.7, namely the use of the ctags / etags utilities together with mcedit to navigate through the code.

Code Navigation


Training


Support for this functionality appeared in mcedit from version 4.7.0-pre1.
To use it, you need to index the directory with the project using the ctags or etags utility, for this you need to run the following commands:

$ cd /home/user/projects/myproj
$ find . -type f -name "*.[ch]" | etags -lc --declarations -

or
$ find . -type f -name "*.[ch]" | ctags --c-kinds=+p --fields=+iaS --extra=+q -e -L-

')
After the utility completes, a TAGS file will appear in the root directory of our project, which mcedit will use.
Well, practically all that needs to be done in order for mcedit to find the definition of the functions of variables or properties of the object under study.

Using


Imagine that we need to determine the place where the definition of the locked property of an edit object is located in some source code of a rather large project.


/* Succesful, so unlock both files */
if (different_filename) {
if (save_lock)
edit_unlock_file (exp);
if (edit->locked)
edit->locked = edit_unlock_file (edit->filename);
} else {
if (edit->locked || save_lock)
edit->locked = edit_unlock_file (edit->filename);
}


To do this, put the cursor at the end of the word locked and press alt + enter , a list of possible options appears, as in the screenshot below.
image

After selecting the desired option, we get to the line with the definition.
image

To return to the file being edited, you need to press alt + '-' , to go back to the desired definition, you must press alt + '='

Source: https://habr.com/ru/post/70266/


All Articles