Menu

#382 auto completion of text

open
nobody
None
1
2013-01-14
2013-01-14
Anonymous
No

Hello,

I'm using TeXstudio 2.5.1 with Win7-64.
What I'm really missing is the auto completion of (long) words, the user has already written in the current document. Writing s.th. like 'trans-impedance-amplifier' a dozen times in a text is awful. Writing it out once and later just typing 'tran' and pressing Enter would be really alleviative. Surely it would make sense to limit the list of suggested words to entries longer than 5..6 characters (maybe adjustable in the options).
I know that using a word very often is not a good writing style, but in technical/science texts it's not usual to use synonyms.

Discussion

  • Denis Bitouzé

    Denis Bitouzé - 2013-01-14

    I don't think such a feature is necessary. You are better to use instead personal macros, such as:

    \documentclass{article}
    \newcommand{\trimam}{trans-impedance-amplifier}
    \begin{document}
    Let us study \trimam{}. A \trimam{} is a very nice and funny machine...
    \end{document}
    

    and then make use of TXS features about personal macros (see § 4.5 Personal macros of TXS manual).

    IMHO, you should even use glossary and/or acronym for such af technical term. See for instace glossaries package.

     
  • Tim Hoffmann

    Tim Hoffmann - 2013-01-14

    Personally, I would not use \newcommand for abbreviation because it reduces readability of the text.

    But User Macros/Scripting can be really helpful here. Below is a script for autocompletion of a fixed word list:

    %SCRIPT
    // simple script for automatic word completion
    var words = ["trans-impedance-amplifier", "Dzyaloshinskii-Moriya interaction"]
    cursor.movePosition(1, cursorEnums.WordLeft, cursorEnums.KeepAnchor)
    txt = cursor.selectedText()
    for (var i=0; i<words.length; i++) {
        if (words[i].indexOf(txt) == 0) {
            cursor.removeSelectedText()
            editor.write(words[i])
            break
        }
    }
    if (cursor.hasSelection())
        cursor.moveTo(cursor.anchorLineNumber(), cursor.anchorColumnNumber())
    

    Once you've created this macro, you can change it's shortcut to e.g. Shift-Enter
    Options -> Configure -> Shortcuts -> Macros

    Btw. you could even set the shortcut to Enter, however then you'd have to insert the newline in case no replacement was found (add editor.write("\n") to the last if statement).

     
    • Denis Bitouzé

      Denis Bitouzé - 2013-01-14

      Personally, I would not use \newcommand for abbreviation because it reduces readability of the text.

      You should ;) The big advantage is that \newcommand lets you easily change the way such terms are typeset. For instance, if you decide just the day before the dead line to typeset "trans impedance amplifier" rather than "trans-impedance-amplifier", you need to change it in a single location. If you decide just the hour before the dead line to typeset "trans impedance amplifier" in red rather than in black, it is still easy, quick and "errorless" to do it.

      I must admit the macro name I used was not that clear (2 first letters of each word of "trans-impedance-amplifier") but it was just an example.

      Moreover, reading quite often such a long term makes the reader tired and doesn't increase readability. By contrast, clear acronyms with easy to find definitions are easier to read.

       
      • Tim Hoffmann

        Tim Hoffmann - 2013-01-14

        Well, I think it's personal taste :). I know that some people use \newcommand that way. I do this myself for chemical formulas. For plain words I think it is cracking a nut with a sledgehammer. (Concerning the change argument: This happens quite rarely and in many cases you can go search-replace, if required with a regexp.) But I don't want to start an argument about this.

         
        • Denis Bitouzé

          Denis Bitouzé - 2013-01-15

          For plain words I think it is cracking a nut with a sledgehammer.

          \Of \course \I \do \not \proceed \that \way \for \every \plain \word :) But for long, error-prone and technical ones, I'm convinced it is not cracking a nut with a sledgehammer. (And, once again, I'm convinced an acronym should be used in the present case.)

          (Concerning the change argument: This happens quite rarely

          In the precise case of this long expression with the minus symbols, I'm not so sure: maybe the original poster will decide to remove them because of the numerous overfull hbox it will probably generate.

          and in many cases you can go search-replace, if required with a regexp.)

          Except that, precisely because of the error-prone nature of such a long term, some occurrences of it may be missed when searching-replacing because they are not properly spelled.

          But I don't want to start an argument about this.

          The same for me ;)

           
          • Tim Hoffmann

            Tim Hoffmann - 2013-01-15

            Except that, precisely because of the error-prone nature of such a long term, some occurrences of it may be missed when searching-replacing because they are not properly spelled.

            Our spellchecker protects me from this ;)

             
            • Denis Bitouzé

              Denis Bitouzé - 2013-01-15

              Our spellchecker protects me from this ;)

              Even for words as 'trans-impedance-amplifier'? ;)

              Another argument against search-replace: if you deal with master and slave files, you'll need to proceed in each slave files.

               
              • Tim Hoffmann

                Tim Hoffmann - 2013-01-16

                Our spellchecker protects me from this ;)

                Even for words as 'trans-impedance-amplifier'? ;)
                Partly, yes. IIRC Hunspell splits at the spaces. Even if it is not in the words list, I can add it to the ignore list and also then other spellings are marked :)

                Search-replace across multiple files is indeed an issue that could be improved. I currently use Notepad++ for this.

                 
                • Denis Bitouzé

                  Denis Bitouzé - 2013-01-16

                  Partly, yes. IIRC Hunspell splits at the spaces. Even if it is not in the words list, I can add it to the ignore list and also then other spellings are marked :)

                  Indeed :) Nevertheless it would be longer to type than a shortcut or a trigger assigned to a personal macro and, also, such a feature as requested by the OP would be annoying because intrusive.

                  Search-replace across multiple files is indeed an issue that could be improved.

                  Could be nice.

                   
  • Benito van der Zander

    if there weren't these minus symbols in the name, you could just press
    ctrl+space to complete it...

    I doubt many words have them

     

Anonymous
Anonymous

Add attachments
Cancel