6

On Excel, you can do "carriage return", that is, jump a line, using Alt+Enter within a cell.

When I copy a cell from excel in my attribute table, this format is respected. I can find no way to write it directly within QGIS table. I tried Alt+Enter, Control+Enter, Shift+Enter... nothing works.

Has anybody got a clue ?

  • Do you mean an attribute field containing data on more than one line? – Joseph Oct 29 '14 at 14:12
  • Yes. In the case I'm on, I have plots of land that belong to more than one person : in the owner raw, I have one line for each name in a given cell. Very easy to read, and this format is also respected in the label, no need to write a formula in the label engine to jump a line after a given character. – Gilles Oct 29 '14 at 14:22
  • Interesting...never knew you could even do that! I was aware of doing it through Labels but not with the actual data. I'm not sure it's possible but hopefully others can enlighten us. – Joseph Oct 29 '14 at 14:26
  • If you want to test it : open excel (I haven't tested with openoffice), add data to a cell on, say, three lines, using alt+enter, then copy the content of your cell into a compatible (type and lenght) cell in qgis, and it should work. Funny thing, when I copy the data in a text editor, say notepad++, there is no symbol for this alt+enter info. But the info must be coded somehow, as if you delete the space just before the line jump in the qgis cell, and replace it by a normal space, the format is lost. – Gilles Oct 29 '14 at 14:30
  • Thanks Giles, tested it. I guess there's little restriction for strings in terms of format compared to the other field types. But still intriguing to know! – Joseph Oct 29 '14 at 14:34
7

There is another approach I found by chance.

You can transform the cells of your attribute table into Multi-Line Text Edit widgets, that is, switch from a single line editor to a multi-line one.

This is how you do it:

  1. Open QGIS and load a layer.

  2. Right click on the layer and open the Properties dialog.

  3. Go to Properties->Fields and in the row corresponding to your field, click on the button Text Edit to select what widget you want to use when editing.

    enter image description here

  4. Check Multiline and click on OK.

    enter image description here

  5. Open your attribute table and start editing. You can now edit multi-line field values by pressing ENTER when you want to start a new line. When you are done editing a cell value, just click on another cell. This is how the multi-line editor looks like:

    enter image description here

3

Since there were no answers providing you with shortcuts, I'd like to answer with another workaround based on the Field Calculator.

Start editing string values in the attribute table and insert a special character (I chose _ for the example) that will serve as a delimiter character to wrap to a new line:

enter image description here

Once you have edited the values, open the Field Calculator, select Update existing field, and copy this as Expression ("names" is the field name I edited):

wordwrap( "names", -1, '_')

enter image description here

Click on Ok. Now you have your attribute table with multi-line values. As you mentioned, labels are able to deal with such values, as well as other tools such as identify.

enter image description here

The approach I exposed is good because in a single action (calculating values from an expression in the Field Calculator) you get what you need.

2

Yes there is an inelegant, but simple way to do this.

Since you are working with property data I'm assuming that you already have tax cards or maybe even a spread sheet.

enter image description here

If you have a carriage return in an excel file or text file, when you copy and paste that data into a cell in the attributes the carriage return is preserved and will show up in your label.

thanks, Scott B

  • 2
    This is the workaround I described above. I'm looking for a qgis shortcut, if indeed it exists. – Gilles Oct 29 '14 at 14:51
  • char(10) or char(13) - would those work? – Scott_B Oct 29 '14 at 15:08
  • I don't understand what "char(10)" is ! – Gilles Oct 29 '14 at 16:13
  • Those can sometimes be used for carriage returns. I think in qgis in might be \n or /n – Scott_B Oct 29 '14 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.