Preventing the join() command from adding extra space

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I am trying to use the join command to join multiple strings. The join command seems to add one character of space in between each of the strings. But I don't want any space added.



As an example, I'm working on a function that finds the associated .pdf file of a .tex file. So if I'm editing the file /home/user/paper.tex, I would like to create the string /home/user/paper.pdf. My attempt is



join([expand('%:p:r'), '.pdf'])


which returns /home/user/paper .pdf










share|improve this question

























    up vote
    1
    down vote

    favorite












    I am trying to use the join command to join multiple strings. The join command seems to add one character of space in between each of the strings. But I don't want any space added.



    As an example, I'm working on a function that finds the associated .pdf file of a .tex file. So if I'm editing the file /home/user/paper.tex, I would like to create the string /home/user/paper.pdf. My attempt is



    join([expand('%:p:r'), '.pdf'])


    which returns /home/user/paper .pdf










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I am trying to use the join command to join multiple strings. The join command seems to add one character of space in between each of the strings. But I don't want any space added.



      As an example, I'm working on a function that finds the associated .pdf file of a .tex file. So if I'm editing the file /home/user/paper.tex, I would like to create the string /home/user/paper.pdf. My attempt is



      join([expand('%:p:r'), '.pdf'])


      which returns /home/user/paper .pdf










      share|improve this question













      I am trying to use the join command to join multiple strings. The join command seems to add one character of space in between each of the strings. But I don't want any space added.



      As an example, I'm working on a function that finds the associated .pdf file of a .tex file. So if I'm editing the file /home/user/paper.tex, I would like to create the string /home/user/paper.pdf. My attempt is



      join([expand('%:p:r'), '.pdf'])


      which returns /home/user/paper .pdf







      whitespace join






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked yesterday









      wxyz

      204




      204




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          From :help join():



          join(list [, sep])

          [..]

          When sep is specified it is put in between the items. If
          sep is omitted a single space is used.

          [..]


          So the solution is to add an empty string in the second sep parameter:



          :echo join([expand('%:p:r'), '.pdf'])
          /usr/share/vim/vim81/doc/eval .pdf

          :echo join([expand('%:p:r'), '.pdf'], '')
          /usr/share/vim/vim81/doc/eval.pdf


          In this case you don't really need to use join() by the way, and could just use:



          :echo expand('%:p:r') . '.pdf'





          share|improve this answer




















          • Thanks. So in your last command, you have a period between the strings. I've seen a period used like that before, but I don't understand, what does it do?
            – wxyz
            yesterday






          • 2




            See :help expression-syntax . In this context '.' is string concatenation.
            – wbogacz
            yesterday











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "599"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f17356%2fpreventing-the-join-command-from-adding-extra-space%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          4
          down vote



          accepted










          From :help join():



          join(list [, sep])

          [..]

          When sep is specified it is put in between the items. If
          sep is omitted a single space is used.

          [..]


          So the solution is to add an empty string in the second sep parameter:



          :echo join([expand('%:p:r'), '.pdf'])
          /usr/share/vim/vim81/doc/eval .pdf

          :echo join([expand('%:p:r'), '.pdf'], '')
          /usr/share/vim/vim81/doc/eval.pdf


          In this case you don't really need to use join() by the way, and could just use:



          :echo expand('%:p:r') . '.pdf'





          share|improve this answer




















          • Thanks. So in your last command, you have a period between the strings. I've seen a period used like that before, but I don't understand, what does it do?
            – wxyz
            yesterday






          • 2




            See :help expression-syntax . In this context '.' is string concatenation.
            – wbogacz
            yesterday















          up vote
          4
          down vote



          accepted










          From :help join():



          join(list [, sep])

          [..]

          When sep is specified it is put in between the items. If
          sep is omitted a single space is used.

          [..]


          So the solution is to add an empty string in the second sep parameter:



          :echo join([expand('%:p:r'), '.pdf'])
          /usr/share/vim/vim81/doc/eval .pdf

          :echo join([expand('%:p:r'), '.pdf'], '')
          /usr/share/vim/vim81/doc/eval.pdf


          In this case you don't really need to use join() by the way, and could just use:



          :echo expand('%:p:r') . '.pdf'





          share|improve this answer




















          • Thanks. So in your last command, you have a period between the strings. I've seen a period used like that before, but I don't understand, what does it do?
            – wxyz
            yesterday






          • 2




            See :help expression-syntax . In this context '.' is string concatenation.
            – wbogacz
            yesterday













          up vote
          4
          down vote



          accepted







          up vote
          4
          down vote



          accepted






          From :help join():



          join(list [, sep])

          [..]

          When sep is specified it is put in between the items. If
          sep is omitted a single space is used.

          [..]


          So the solution is to add an empty string in the second sep parameter:



          :echo join([expand('%:p:r'), '.pdf'])
          /usr/share/vim/vim81/doc/eval .pdf

          :echo join([expand('%:p:r'), '.pdf'], '')
          /usr/share/vim/vim81/doc/eval.pdf


          In this case you don't really need to use join() by the way, and could just use:



          :echo expand('%:p:r') . '.pdf'





          share|improve this answer












          From :help join():



          join(list [, sep])

          [..]

          When sep is specified it is put in between the items. If
          sep is omitted a single space is used.

          [..]


          So the solution is to add an empty string in the second sep parameter:



          :echo join([expand('%:p:r'), '.pdf'])
          /usr/share/vim/vim81/doc/eval .pdf

          :echo join([expand('%:p:r'), '.pdf'], '')
          /usr/share/vim/vim81/doc/eval.pdf


          In this case you don't really need to use join() by the way, and could just use:



          :echo expand('%:p:r') . '.pdf'






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered yesterday









          Martin Tournoij♦

          33.1k11101176




          33.1k11101176











          • Thanks. So in your last command, you have a period between the strings. I've seen a period used like that before, but I don't understand, what does it do?
            – wxyz
            yesterday






          • 2




            See :help expression-syntax . In this context '.' is string concatenation.
            – wbogacz
            yesterday

















          • Thanks. So in your last command, you have a period between the strings. I've seen a period used like that before, but I don't understand, what does it do?
            – wxyz
            yesterday






          • 2




            See :help expression-syntax . In this context '.' is string concatenation.
            – wbogacz
            yesterday
















          Thanks. So in your last command, you have a period between the strings. I've seen a period used like that before, but I don't understand, what does it do?
          – wxyz
          yesterday




          Thanks. So in your last command, you have a period between the strings. I've seen a period used like that before, but I don't understand, what does it do?
          – wxyz
          yesterday




          2




          2




          See :help expression-syntax . In this context '.' is string concatenation.
          – wbogacz
          yesterday





          See :help expression-syntax . In this context '.' is string concatenation.
          – wbogacz
          yesterday


















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f17356%2fpreventing-the-join-command-from-adding-extra-space%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          White Anglo-Saxon Protestant

          Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

          One-line joke