Tag Archives: vim

Linux: How to Solve vim ~/.bashrc Execute Error

1. If you want to add environment variables under Linux, execute VIM ~/The bashrc command has the following error:

2. Execute sudo apt update first to see what happens

3. Execute sudo apt install — reinstall command not found

4. Finally, execute sudo sudo chmod -R o+r /var/lib/command-not-found/ to successfully solve the problem!

[Solved] Error: no “print“ mailcap rules found for type “text/plain“

Blog background

The author has always wanted to understand how to use the Print command under Linux?

Direct Print hello. TXT will report an error

Error: no "print" mailcap rules found for type "text/plain"

Specific operation

ubuntu@139:~/temp $ cat /etc/mailcap | egrep print
application/x-troff-man; /usr/bin/nroff -mandoc -Tutf8; copiousoutput; print=/usr/bin/nroff -mandoc -Tutf8 | print text/plain:-
text/troff; /usr/bin/nroff -mandoc -Tutf8; copiousoutput; print=/usr/bin/nroff -mandoc -Tutf8 | print text/plain:-
text/plain; view %s; edit=vim %s; compose=vim %s; test=test -x /usr/bin/vim; print=cat %s; needsterminal
application/x-tar; /bin/tar tvf '%s'; print=/bin/tar tvf - | print text/plain:-; copiousoutput
application/x-gtar; /bin/tar tvf '%s'; print=/bin/tar tvf - | print text/plain:-; copiousoutput
application/x-ustar; /bin/tar tvf '%s'; print=/bin/tar tvf - | print text/plain:-; copiousoutput
ubuntu@139:~/temp $ ls
hello  hi.txt
ubuntu@139:~/temp $ cat hi.txt 
hello
ubuntu@139:~/temp $ print hi.txt 
hello

This is the situation after I edit the mailcap file. Pay attention to this line

text/plain; view %s; edit=vim %s; compose=vim %s; test=test -x /usr/bin/vim; print=cat %s; needsterminal

That is, just add a print command rule after text/plain, which is so simple.

MAC: Clion configure C compiler Error: The C compiler identification is unknown

1 click let cmake detect

View error message:
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /Users/apple/CLionProjects/untitled16
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - broken
CMake Error at /Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.17/Modules/CMakeTestCCompiler.cmake:60 (message):
  The C compiler
 
    "/usr/bin/cc"
 
  is not able to compile a simple test program.
 
  It fails with the following output:
 
    Change Dir: /Users/apple/CLionProjects/untitled16/cmake-build-debug/CMakeFiles/CMakeTmp
    
    Run Build Command(s):xxxx(can not find /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/numpy/core/include:)

2 view environment variables

cd ~
vim .bash_profile

It is found that the error path is cflags (I wonder why I set cflags to be a python library?) Solution: comment out this line of code. Result: Although there is no error message in red in this interface, the program still cannot be compiled

Replace c compiler [key to solving the problem]

View all gcc compiler paths

brew list gcc
/usr/local/Cellar/gcc/11.2.0/bin/c++-11
/usr/local/Cellar/gcc/11.2.0/bin/cpp-11
/usr/local/Cellar/gcc/11.2.0/bin/g++-11
/usr/local/Cellar/gcc/11.2.0/bin/gcc-11
/usr/local/Cellar/gcc/11.2.0/bin/gcc-ar-11
/usr/local/Cellar/gcc/11.2.0/bin/gcc-nm-11
/usr/local/Cellar/gcc/11.2.0/bin/gcc-ranlib-11
/usr/local/Cellar/gcc/11.2.0/bin/gcov-11
/usr/local/Cellar/gcc/11.2.0/bin/gcov-dump-11
/usr/local/Cellar/gcc/11.2.0/bin/gcov-tool-11
/usr/local/Cellar/gcc/11.2.0/bin/gdc
/usr/local/Cellar/gcc/11.2.0/bin/gdc-11
/usr/local/Cellar/gcc/11.2.0/bin/gfortran
/usr/local/Cellar/gcc/11.2.0/bin/gfortran-11
/usr/local/Cellar/gcc/11.2.0/bin/lto-dump-11
/usr/local/Cellar/gcc/11.2.0/bin/x86_64-apple-darwin20-c++-11
/usr/local/Cellar/gcc/11.2.0/bin/x86_64-apple-darwin20-g++-11
/usr/local/Cellar/gcc/11.2.0/bin/x86_64-apple-darwin20-gcc-11
/usr/local/Cellar/gcc/11.2.0/bin/x86_64-apple-darwin20-gcc-11.2.0
/usr/local/Cellar/gcc/11.2.0/bin/x86_64-apple-darwin20-gcc-ar-11
/usr/local/Cellar/gcc/11.2.0/bin/x86_64-apple-darwin20-gcc-nm-11
/usr/local/Cellar/gcc/11.2.0/bin/x86_64-apple-darwin20-gcc-ranlib-11
/usr/local/Cellar/gcc/11.2.0/bin/x86_64-apple-darwin20-gdc-11
/usr/local/Cellar/gcc/11.2.0/bin/x86_64-apple-darwin20-gfortran-11
/usr/local/Cellar/gcc/11.2.0/include/c++/ (796 files)
/usr/local/Cellar/gcc/11.2.0/lib/gcc/ (1304 files)
/usr/local/Cellar/gcc/11.2.0/libexec/gcc/ (15 files)
/usr/local/Cellar/gcc/11.2.0/share/gcc-11.2.0/ (4 files)
/usr/local/Cellar/gcc/11.2.0/share/man/ (12 files)

C compiler and C + + compiler use respectively:

/usr/local/Cellar/gcc/11.2.0/bin/gcc-11
/usr/local/Cellar/gcc/11.2.0/bin/g++-11

After selection, Clion automatically compiles and succeeds.

SLAMBook2 in ch3 code run fatal error: Eigen/Core: No such file or directory

1. First determine whether you have installed eigen3

If not, use the following command to install:

sudo apt-get install libeigen3-dev

2. The installation directory is inconsistent with the directory specified in cmakelists.txt

The default installation directory in cmakelists.txt is as follows:

modify it to the correct path

the final running success is as follows:

[solution] install youcompleteme through VIM plug-in manager VIM plug, including ycmd server shutdown solution

Reference article:
take you step by step to install the most difficult VIM plug-in in history: youcompleteme
VIM plug-in: minimalist VIM plug-in manager

Installation method

    install VIM
    sudo apt get install VIM edit vimrc
    first add VIM ~ /. Vimrc
    at the top:
    call plug#begin (‘~ /. VIM/plugged’)
    plug ‘valloric/youcompleteme’
    call plug#end() to install VIM plug and install youcompleteme through plugged

    Input: curl – flo ~ /. VIM/autoload at the terminal/ plug.vim –create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim Open VIM
    Enter “: source ~ /. Vimrc” at the command line
    Enter “: pluginstall” at the command line to install youcompleteme, which takes a long time. Please wait patiently for YCM to be compiled and installed_ core
    mkdir ~/.ycm_ build
    cd ~/.ycm_ build
    cmake -G “Unix Makefiles” . ~/.vim/plugged/YouCompleteMe/third_ party/ycmd/cpp
    cmake –build . –target ycm_ core –config Release

Supplement: VIM prompts the debugging method of the ycmd server shut down:

Select log through ycmtogglelogs to view errors

For example, the solution of no module named watchdog: PIP3 install watchdog

Mac command not found solution

MacBook Air command not found. This may have been caused by modifying the Profile when configuring Java Path.
: ls CD, vim, sudo, man command not found

1. First, enter commands so that you can use commands such as Vim temporarily

export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin

Then open ~/.bash_profile

vim ~/.bash_profile

2. Add PATH

export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:${JAVA_HOME}:${JAVA_HOME}/bin"

3. Restart Profile

source ~/.bash_profile

Exit Terminal, open it again, and type Vim to see if it works

How to replace strings in VIM

Replacement string
Global, replace string:
Command mode :% s/old/new/g
Old, new does not need double quotes, g is global, without g is the first line to be changed example: % s/test_shm_tool.c/$(SOURCE)/g local, replace string:
: n1, n2 s/old_str/new_str/g, add c if each line is confirmed

Error analysis of swap file “*. SWP” already exists! When editing files with VIM

When editing a file with VIM, exit the terminal in time out, or close the terminal directly without quitting, resulting in an abnormal exit scenario. The following error will be reported when editing again:
E325: ATTENTION
Found a swap file by the name “.test.txt. SWP “
owned by: root dated: Thu Jun 27 14:38:06 2019
file name: ~root/test.txt
modified: YES
user name: root host name: VMcentos
process ID: 20994
While opening file “test.txt”
dated: Thu Jun 27 13:42:52 2019
(1) Another program may be editing the same file. If this is the case,
be careful not to end up with two different instances of the same
file when making changes. Quit,
(2) An edit session for this file comedown.
If this is the case,
to recover (see “:help recovery”).
If you did this already, delete the swap file “.test.txp “
to avoid this message.
Swap file “.test.txt.swp” already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
Use LL-A command to check, there is indeed a hidden file, originally when editing the file, the system will copy a temporary file. Test.txt.swap, also will edit this file, the temporary file will be written to the official file when executing: W, the temporary file will be deleted when executing: Q.
Solutions:
Delete the file.test.txt.swap, rm.test.txt.swap

Error of replacing VIM editor: s in Linux: pattern not found

In a very simple example, when writing shell scripts, you want to use :s in the Vim editor to implement the substitution function.
I used s/SCORE/1/g
SCORE exists in the script, but the error pattern not found is reported.
Look at this and the result is going to be
s –> %s
g –> ge

%s/SCORE/1/ge
It does, because S will search only on the current row, and %s is needed to replace it throughout the script