Skip to Content

How to change keyboard shortcut to insert line break in LibreOffice Calc

  • The article explains how to change the insert line break shortcut in LibreOffice Calc from Ctrl + Enter to Enter using a macro.
  • The article provides step-by-step instructions for creating and assigning the macro to the Enter key, as well as some frequently asked questions and answers related to the topic.

LibreOffice Calc is a powerful spreadsheet application that allows you to perform various calculations, analyze data, and create charts and graphs. However, sometimes you may want to insert a line break within a cell to make your text more readable or to fit the cell width. By default, the keyboard shortcut for inserting a line break in a cell is Ctrl + Enter. But what if you want to change this shortcut to something else, such as just Enter or Shift + Enter? In this article, I will show you how to do that in LibreOffice Calc.

How to change keyboard shortcut to insert line break in LibreOffice Calc

The Problem

The problem is that there is no option in the LibreOffice Calc settings to change the keyboard shortcut for inserting a line break in a cell. You can customize many other keyboard shortcuts in Tools – Customize – Keyboard, but not this one. The reason is that this shortcut is hard-coded in the source code of LibreOffice Calc and cannot be modified by the user.

However, there is a workaround that involves using a macro to override the default behavior of the Enter key. A macro is a small piece of code that can automate certain tasks or perform custom actions in LibreOffice. By creating and assigning a macro to the Enter key, you can make it insert a line break in a cell instead of moving to the next cell.

The Solution

To change the insert line break shortcut in LibreOffice Calc, follow these steps:

  1. Open LibreOffice Calc and create a new spreadsheet or open an existing one.
  2. Go to Tools – Macros – Organize Macros – LibreOffice Basic.
  3. In the Macro from section, select My Macros – Standard – Module1. If Module1 does not exist, click New and name it Module1.
  4. In the Existing macros in section, select Main and click Edit.
  5. In the Basic IDE window that opens, delete any existing code and paste the following code:
REM  *****  BASIC  *****

Sub Main
End Sub

Sub InsertLineBreak
    Dim oDoc As Object
    Dim oSheet As Object
    Dim oCell As Object
    Dim oCursor As Object
    Dim oView As Object
    Dim oController As Object
    Dim sText As String
    Dim nPos As Long
    oDoc = ThisComponent
    oController = oDoc.getCurrentController()
    oView = oController.getViewData()
    oSheet = oDoc.getSheets().getByIndex(0)
    oCell = oController.getActiveCell()
    sText = oCell.getString()
    nPos = Len(sText)
    If nPos > 0 Then
        oCursor = oCell.createTextCursor()
        oCell.setString(sText & Chr(10))
        oView = oController.getViewData()
    End If
End Sub
  1. Click Save and close the Basic IDE window.
  2. Go to Tools – Customize – Keyboard.
  3. In the Shortcut keys section, select Enter from the list.
  4. In the Category section, expand LibreOffice Macros – user – Standard – Module1.
  5. In the Function section, select InsertLineBreak.
  6. Click Modify and then OK.

Now you have changed the insert line break shortcut in LibreOffice Calc from Ctrl + Enter to Enter. To test it, go to any cell and type some text. Then press Enter and type some more text. You should see a line break inserted within the cell.

Frequently Asked Questions (FAQs)

Here are some frequently asked questions related to changing the insert line break shortcut in LibreOffice Calc:

Question: How can I revert back to the original shortcut of Ctrl + Enter?

Answer: To revert back to the original shortcut of Ctrl + Enter, go to Tools – Customize – Keyboard and select Enter from the Shortcut keys section. Then click Delete and then OK.

Question: How can I assign a different shortcut for inserting a line break in a cell?

Answer: To assign a different shortcut for inserting a line break in a cell, follow the same steps as above, but choose a different key from the Shortcut keys section, such as Shift + Enter or Alt + Enter.

Question: How can I insert multiple line breaks in a cell?

Answer: To insert multiple line breaks in a cell, press Enter as many times as you want after typing some text. Each time you press Enter, a new line break will be inserted within the cell.

Question: How can I remove line breaks from a cell?

Answer: To remove line breaks from a cell, select the cell and press Ctrl + H to open the Find & Replace dialog box. In the Search for box, type \n (backslash followed by n). In the Replace with box, leave it blank. Then click Replace All and then Close.


This article is for informational purposes only and does not constitute professional advice. The author is not responsible for any damages or losses that may result from following the instructions in this article. Always backup your data before making any changes to your LibreOffice Calc settings or macros. Use this solution at your own risk.

Alex Lim is a certified IT Technical Support Architect with over 15 years of experience in designing, implementing, and troubleshooting complex IT systems and networks. He has worked for leading IT companies, such as Microsoft, IBM, and Cisco, providing technical support and solutions to clients across various industries and sectors. Alex has a bachelor’s degree in computer science from the National University of Singapore and a master’s degree in information security from the Massachusetts Institute of Technology. He is also the author of several best-selling books on IT technical support, such as The IT Technical Support Handbook and Troubleshooting IT Systems and Networks. Alex lives in Bandar, Johore, Malaysia with his wife and two chilrdren. You can reach him at [email protected] or follow him on Website | Twitter | Facebook

    Ads Blocker Image Powered by Code Help Pro

    Your Support Matters...

    We run an independent site that is committed to delivering valuable content, but it comes with its challenges. Many of our readers use ad blockers, causing our advertising revenue to decline. Unlike some websites, we have not implemented paywalls to restrict access. Your support can make a significant difference. If you find this website useful and choose to support us, it would greatly secure our future. We appreciate your help. If you are currently using an ad blocker, please consider disabling it for our site. Thank you for your understanding and support.