Showing posts with label Word. Show all posts
Showing posts with label Word. Show all posts

05 June 2024

13 January 2022

How to automatically break long lines if lines are too long in vim?

To break long lines,

:set textwidth=78

To prevent a line from being broken from within a word,

:set linebreak

13 November 2021

vim search patterns

https://vim.fandom.com/wiki/Search_patterns

created 2001 · complexity basic · version 6.0


When searching in Vim, you enter a search pattern. This tip provides a tutorial introduction to using search patterns.

Finding a whole word

In a program, you may want to search for an identifier named i. However, entering the search /i will find every hit, including the "i" in words like "if" and "while". In a pattern, \< represents the beginning of a word, and \> represents the end of a word, so to find only the whole word "i", use the pattern:

\<i\>

In normal mode, press / to start a search, then type the pattern (\<i\>), then press Enter.

If you have an example of the word you want to find on screen, you do not need to enter a search pattern. Simply move the cursor anywhere within the word, then press * to search for the next occurrence of that whole word. Vim inserts \< and \> automatically (see searching).

The pattern \<i finds all words that start with "i", while i\> finds all words that end with "i".

Finding duplicate words

Sometimes words are accidentally duplicated in text (like this this). The following pattern finds repeated words that are separated by whitespace (spaces, tabs, or newlines):

\(\<\w\+\>\)\_s*\<\1\>

The pattern searches for \<\w\+\> (word beginning \<, word character \w, one or more \+ word characters, word end \>). That is, it searches for a whole word. It then looks for any amount of whitespace (\_s*); \s matches space or tab, while \_s matches space or tab or newline (end-of-line character). Finally, the pattern looks for \1 which is the whole word that was found in the escaped parentheses.

Finding this or that

A search pattern can use \| to search for something or something else. For example, to search for all occurrences of "red" or "green" or "blue", enter the following search pattern (in normal mode, press / then type the pattern, then press Enter):

red\|green\|blue

To replace all instances of "red" or "green" or "blue" with "purple", enter:

:%s/red\|green\|blue/purple/g

However, the above pattern finds "red" in "bored", so the substitute would change "bored" to "bopurple". If that is not what you want, use the following pattern to find only the whole words "red" or "green" or "blue":

\<\(red\|green\|blue\)\>

In a pattern, \< and \> respectively specify the beginning and end of a word, while \( and \) respectively specify the beginning and end of a group (the pattern \<red\|green\|blue\>, without escaped parentheses, would find "red" occurring at the beginning of a word, or "green" occurring anywhere, or "blue" occurring at the end of a word).

After searching with the command /\<\(red\|green\|blue\)\> you could change the whole words "red" or "green" or "blue" to "purple" by entering the following (the search pattern is empty in this command, so it uses the last search):

:%s//purple/g

In a substitute, you can use & in the replacement to mean the "whole matched pattern" (everything that was found). For example, the following will insert quotes around all occurrences of the whole words "red" and "green" and "blue":

:%s/\<\(red\|green\|blue\)\>/"&"/g

If you do not want the whole matched pattern, you can use parentheses to group text in the search pattern, and use the replacement variable \1 to specify the first group. For example, the following finds "color x" and replaces it with "colored x" where x is the whole word "red" or "green" or "blue":

:%s/color \<\(red\|green\|blue\)\>/colored \1/g

Finding two words in either order

You can search for a line that contains two words, in any order. For example, the following pattern finds all lines that contain both "red" and "blue", in any order:

.*red\&.*blue

In a pattern, \& separates alternates, each of which has to match at the same position. The two alternates in this example are:

  • .*red (will match all characters from the beginning of a line to the end of the last "red"); and
  • .*blue (will match all characters from the beginning of a line to the end of the last "blue").

A line which contains both "red" and "blue" will match both alternates, starting at the beginning of the line. The pattern .*red\&.*blue finds the last alternate (but only if all alternates match at the same position), so if you are highlighting matches, you will see text matched by .*blue highlighted.

An alternative procedure is to use a pattern that explicitly finds "red" followed by "blue", or "blue" followed by "red":

\(red.*blue\)\|\(blue.*red\)

To search for lines that contain only the whole words "red" and "blue", in either order, use one of the following patterns:

.*\<red\>\&.*\<blue\>
\(\<red\>.*\<blue\>\)\|\(\<blue\>.*\<red\>\)

Finding trailing zeroes

The following pattern finds redundant trailing zeroes in numbers:

\(\.\d\+\)\@<=0\+\>

The pattern does not find the "0" in "1.0", but it finds the trailing "00" in each of the following numbers: 1.000 1.000200 1.0002000300. After searching, the command :%s///g would delete all the redundant zeroes (the search pattern is empty, so it uses the last search).

The pattern:

  • Contains \@<= which checks if the preceding atom matches just before what follows.
  • First searches for 0\+\> (what follows).
  • Then checks if what is just before matches \(\.\d\+\) (preceding atom).

The first search is 0\+\> which finds one or more (\+) of 0 followed by end of word (\>).

The check is \(\.\d\+\)\@<=0\+\> which verifies that the text immediately before the trailing zeroes consists of a decimal point (\.), then one or more decimal digits (\d\+). The escaped parentheses \(...\) make an "atom" from what is enclosed by the parentheses.

References

13 September 2021

How to grep word1 & word2?

https://stackoverflow.com/questions/4487328/match-two-strings-in-one-line-with-grep

You can use

grep -inH 'string1' filename | grep -inH 'string2'

Or

grep -inH 'string1.*string2\|string2.*string1' filename

 

01 July 2021

How to find all the files containing the string 'abc' in the current directory and all the sub-directories

How to find all the files containing the string 'abc' in the current directory and all the sub-directories?


find . -type f | xargs fgrep '...'

21 March 2018

You cannot use Outlook to complete a Microsoft Word Mail Merge

You cannot use Outlook to complete a Microsoft Word Mail Merge


Symptoms


You use Microsoft Word to start a Mail Merge that is configured to send email messages to the recipients. However, Microsoft Outlook does not send the email messages. In some cases, you do not receive an error message. Or, you may receive the following error message:
Word could not load the e-mail envelope. This could be caused by a network connection problem or a problem with your Office installation.

Cause


If you are using Microsoft Outlook 2002, Microsoft Office Outlook 2003, or Microsoft Office Outlook 2007, this issue may occur if you install a newer version of Microsoft Office and then uninstall the newer version. This issue also occurs when you install a trial edition of a newer version of Microsoft Office.

If you are using Microsoft Outlook 2010, this issue may occur if you install the 64-bit version of Microsoft Office 2010 or of Microsoft Outlook 2010, you uninstall the 64-bit version, and then you install the 32-bit version.

Resolution


Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:
322756 How to back up and restore the registry in Windows

Outlook 2002, Outlook 2003, or Outlook 2007

To resolve this issue for Outlook 2002, for Outlook 2003, or for Outlook 2007, follow these steps:
  1. Exit all Microsoft Office applications.
  2. Start Registry Editor:
    • In Windows Vista or in Windows 7, click Startthe Start button, type regedit in the Start Search box, and then press Enter.


      User Account ControlIf you are prompted for an administrator password or for confirmation, type the password, or provide confirmation. 
    • In Windows XP, click Start, click Run, type regedit in the Open box, and then click OK.
  3. Locate and then click the following registry subkey: 
    HKEY_CLASSES_ROOT\TypeLib\{00062FFF-0000-0000-C000-000000000046}
  4. On the Edit menu, click Delete.
  5. Exit Registry Editor.
  6. Repair or reinstall the Microsoft Office program.

Outlook 2010

To resolve this issue for Outlook 2010, follow these steps:
  1. Exit all Microsoft Office applications.
  2. Start Registry Editor:
    • In Windows Vista or in Windows 7, click Startthe Start button, type regedit in the Start Search box, and then press Enter.


      User Account ControlIf you are prompted for an administrator password or for confirmation, type the password, or provide confirmation. 
    • In Windows XP, click Start, click Run, type regedit in the Open box, and then click OK.
  3. Locate and then click the following registry subkey:
    HKEY_CLASSES_ROOT\TypeLib\{00062FFF-0000-0000-C000-000000000046}\9.4\0\win64
  4. On the Edit menu, click Rename.
  5. Type BAKwin64, and then press Enter.
  6. Exit Registry Editor.
  7. Repair the Microsoft Office 2010 or Microsoft Outlook 2010 installation.
    • In Windows Vista or in Windows 7, click Startthe Start button, type programs and features in the Start Search box, and then press Enter.
    • In the list of installed programs, right-click Microsoft Office 2010 or Microsoft Outlook 2010, and then click Repair.

21 December 2015

Word with Chinese Contents Can not be Converted into PDF | There is NO PDFMaker | There is NO PDF Menu

If an Office document contains both English and Chinese, then after I have removed the Chinese words in it, it will be able to be converted into PDF.

My Office is 2010 64bit. My Adobe Acrobat is X Pro (10.0.0)

The problems in the subject happen only when your Office is 2010 64bit (32bit Office does not have those problems) and your Adobe Acrobat is X (10.0.0 or older) (10.1 or newer Acrobat does not have those problems.)

Solution: Within Acrobat, click Help | Check for Updates.. After installing the updates, version of Acrobat will become 10.1.16 (on 21 December 2015) or newer.

Install a patch from here -

http://www.adobe.com/support/downloads/product.jsp?product=1&platform=Windows

After you have installed the patch, the problems in the subject will be gone.

11 September 2012

Received a Word attachment in Outlook, but it is blank

http://www.howto-outlook.com/faq/securetemp.htm

Error opening attachments / Cleaning out the Temporary Outlook Files folder

When opening an attachment directly from within Outlook you could get an error message saying that it can’t create the file and to that you need check the permissions on the folder you want to save it in. In most cases the permissions on the folder isn’t the issue but the fact that the folder is “full”. When you open an attachment directly from within Outlook it will first save a copy to a subfolder of the Temporary Internet Files folder. Cleaning out the folder will solve the issue.

Outlook Secure Temp folder

Unfortunately this is easier said than done. The subfolder name Outlook creates (on installation of Outlook) in the Temporary Internet Files folder is quite random. In Outlook 2003 and previous, the name starts with OLK and is followed by up to 4 random numbers or letters. In Outlook 2007 and Outlook 2010, this folder is called Content.Outlook and then has a subfolder which is named with with 8 random numbers and letters. In addition, by default, you cannot simply browse to the folder to clean it out. Getting to the Temporary Outlook Folder can still be accomplished in 2 easy steps though.
Step 1: Locate the folder
The folder location is stored in the registry in the following key;
Outlook 97HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Outlook\Security
Outlook 98HKEY_CURRENT_USER\Software\Microsoft\Office\8.5\Outlook\Security
Outlook 2000HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Outlook\Security
Outlook 2002/XPHKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Outlook\Security
Outlook 2003HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Security
Outlook 2007HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Security
Outlook 2010HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Security
Step 2: Get to the folder
  1. Open the OutlookSecureTempFolder registry key from the location provided in Step 1.
  2. Copy the path from the key.
  3. Open Explorer
  4. Paste the address in the Address Bar and press Enter

Use OutlookTools or OutlookTempCleaner

Still not easy enough or just don’t want to go in the Registry to find the folder location? I’ve created two free tools which can do the trick as well.
OutlookTools offers besides locating, opening and cleaning up the SecureTempFolder also quite a lot of additional features to troubleshoot and tweak Outlook.
OutlookTempCleaner focuses only on dealing with the SecureTempFolder and can also be used in (corporate) login and logoff scripts to clean up the folder without any end-user interaction.
OutlookTempCleaner
OutlookTempCleaner can detect and empty Outlook’s Secure Temp folder automatically for you.

30 August 2011

How to remove the page numbers on the 4 beginning pages, and start to number the pages starting the fifth page?

Put the cursor at the end of page 4. Click on 'Page Layout', 'Breaks', and select 'Continuous'. You have inserted a section break there. The whole document has been split into two sections in terms of header and footer.

Double-click on the page number '5', and select '5'. You will see that the tab 'Design' has automatically been selected, and the 'Link to Previous' button is down. That means that the header and footer in the current section contain the same content as in the previous section.

Click on 'Link to Previous' button, to let it be up. You have un-linked the current section from the previous section, so that the header and footer in the current section do NOT contain the same content as in the previous section.

Double-click on the page number '4', select number '4', and delete the number '4'. You will see that the pages numbers from 1 to 3 have automatically deleted, but page numbers starting 5 still remain.

Double-click on the page number '5', and select '5' again. Click on 'Page Number', 'Format Page Numbers...'. Choose 'Start at 1'. Click on 'OK'. You will see that the page number on the fifth page has become '1', and the page number on the sixth page '2', and so on and so forth.