vim 配置——manjaro xfce4环境

为vim添加系统剪贴板

https://vi.stackexchange.com/questions/3076/how-do-i-use-the-system-clipboard-with-vim-in-arch-linux
总结:删除vim安装gvim但不使用gvim。只是让vim建立与libx的连接

sudo pacman -S gvim

capslock映射为ctrl

参考:https://blog.yxwang.me/2009/05/caps-lock-to-ctrl/
总结:使用xmodmap这个工具
修改前记得先备份当前的键位映射,

xmodmap -pke > xmodmap.backup

接下来运行

xmodmap -e 'keycode 66 = Control_L'
xmodmap -e 'clear Lock'
xmodmap -e 'add Control = Control_L'

这样就修改了Caps Lock的键位映射而不需要重启x,如果要在每次启动时自动修改Caps Lock键的映射,可以新建/修改一个.Xmodmap或者.xmodmap的文件,

vim .xmodmap

在里面加入

keycode 66 = Control_L
clear Lock
add Control = Control_L

在.zshrc中加入:

xmodmap /home/yszc/.xmodmap 

终端启动时出现问题:xmodmap: please release the following keys within 2 seconds: Control_L (...
参考:https://bbs.deepin.org/forum.php?mod=viewthread&tid=43109&extra=page%3D1
错误出现原因:
你是不是在你的rc文件加入了xmodmap的操作?,比如.bashrc如果是bash的话,可能你在里面加了xmodmap ~/.Xmodmap? 如果你加了的话,你每次在开启一个bash的时候,xmodmap的命令都会被执行,好的做法是加到profile文件中去,如.bash_profile等。

再参考:https://blog.csdn.net/thisishenryzhang/article/details/77892630 删除.zshrc中的xmodmap… 在/etc/zsh/zprofile 中加入xmodmap /home/yszc/.xmodmap 效果待检验。失败。 再再参考:https://forum.manjaro.org/t/how-to-execute-a-command-at-the-system-startup/1972 将该命令加入到 /etc/profile 中,检验效果:失败 再来:选项->会话和启动->应用程序自启动 添加 xmodmap /home/yszc/.xmodmap 再再再参考:https://blog.csdn.net/u014717036/article/details/57082204 失败 再参考:https://bbs.archlinux.org/viewtopic.php?id=67363 再参考:https://askubuntu.com/questions/1083637/file-xmodmap-is-not-sourced-on-startup-in-18-04 再来:https://wiki.archlinux.org/index.php/Xmodmap_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87) 受不了:https://askubuntu.com/questions/54157/how-do-i-set-xmodmap-on-login 终于解决:
解决方法:参考(https://askubuntu.com/questions/54157/how-do-i-set-xmodmap-on-login )

Please note: if you are on Xfce, it is noted on the official Xfce FAQ
that you may have to create a startup item instead of using
~/.xinitrc, and that you might have to delay the execution so the
xmodmap changes are not overwritten by setxkbmap. You can use a delay
to achieve this in your startup entry:

/bin/bash -c "sleep 20; /usr/bin/xmodmap /home/$USER/.Xmodmap"

选项->会话和启动->应用程序自启动
添加 /bin/bash -c “sleep 20; /usr/bin/xmodmap /home/$USER/.Xmodmap”

3.新建.vimrc输入下面的代码: (暂时不用鼠标功能,翻页用n模式下c-j c-k,具体定位用EasyMotion)

" 基本设置----------------{
    {
    {
" 不兼容vi模式 必须放在第一行
set nocompatible
" 开启语法高亮
syntax on
" 高亮当前行
set cursorline
" 开启搜索高亮
set incsearch
" 设定历史记录数
set history =50
" 设定为系统剪贴板
set clipboard=unnamedplus
" 消除~后缀备份文件
set nobackup
" 消除un后缀备份文件
set noundofile
" 显示行号
set number
" 高亮搜索项
set hlsearch
" 用空格代替tab键
" 设置tab宽度,为了符合google c++标准将4空格换位2空格节省横向空间
set tabstop=2
" 设置缩进宽度
set shiftwidth=2
" 用空格代替tab,问题:用空格代替tab会导致一些快捷键无法使用
" 可以尝试用 c-j/k 来选择
set expandtab
" 设置mapleader为逗号
let mapleader=","
" 设置编码
set encoding=utf-8
language messages zh_CN.utf-8
"}}}

" 全局变量------------------{
    {
    {
let g:author="yszc"
" }}}

 " 映射-------------------{
    {
    {
" C-W +j/k/l/h可以移动窗口光标,不用按多次w
" CTRL-A 是全选
nnoremap  ggvG
" 高亮开关
nnoremap hl :set hlsearch!
" 定义快速打开加载.vimrc和.vimrc.vundle文件
nnoremap ev :split $MYVIMRC
nnoremap sv :source $MYVIMRC
nnoremap ep :split $HOME/.vimrc.vundle
" nnoremap  :echo "hi"
" insert 模式括号匹配
" inoremap < <>i
inoremap [ []i
inoremap { {}i
inoremap ( ()i
inoremap ' ''i
inoremap " ""i

" c-j/k映射成翻页键
nnoremap  
nnoremap  

" H映射为0,L映射为$
nnoremap 0 
nnoremap $ 
nnoremap H 0
nnoremap L $
vnoremap H 0
vnoremap L $
" 操作符号重映射
onoremap H 0
onoremap L $

" J/K向上/下移动一段?一页?还是easymotion
" 方向键习惯改掉
nnoremap  
nnoremap  
nnoremap  
nnoremap  
inoremap  
inoremap  
inoremap  
inoremap  
" insert模式下方向键
inoremap  
inoremap  
inoremap  
inoremap  
" insert模式jk代替
" 将inoremap模式下的映射为空导致了方向键和翻页键乱码的情况
inoremap  
inoremap jk 
" 快速保存,退出
nnoremap  :w
nnoremap  :q
" 不能映射normal模式下的esc键,因为方向键和翻页键的前缀是esc
" 这会导致在键入方向键或翻页键时退出,并且失灵
" nnoremap  :q
"}}}

修改zsh和vim光标样式(zsh改为竖线,vim改为方块竖线切换):

参考:
https://blog.csdn.net/xiaohui5319/article/details/7507042
https://unix.stackexchange.com/questions/433273/changing-cursor-style-based-on-mode-in-both-zsh-and-vim
总结:
.zshrc中加入:

# 改变光标样式为竖线
echo -ne '\e[5 q'

.vimrc中加入:

" 自动命令组----------------{
    {
    {
" 光标切换
augroup cursor_switch
    autocmd!
    au InsertLeave * silent exec "! echo -ne '\e[1 q'"
    au InsertEnter * silent exec "! echo -ne '\e[5 q'" 
    au VimLeave * silent exec "! echo -ne '\e[1 q'"
    au VimEnter * silent exec "! echo -ne '\e[1 q'"
augroup END
" }}}

安装并配置vundle(插件配置见下文)

新建.vimrc.vundle,粘贴下面的文本:(注意set rtp += 要包含正确的目录)

   set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
set rtp+=~/.fzf/
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
" 删除或添加插件后要重新加载vimrc后执行vundle才有效果
Plugin 'VundleVim/Vundle.vim'

Plugin 'morhetz/gruvbox'

Plugin 'scrooloose/nerdtree'

Plugin 'vim-airline/vim-airline'

Plugin 'Valloric/YouCompleteMe'

Plugin 'majutsushi/tagbar'

Plugin 'easymotion/vim-easymotion'

Plugin 'junegunn/fzf.vim'

Plugin 'yianwillis/vimcdoc'

Plugin 'SirVer/ultisnips'

Plugin 'scrooloose/nerdcommenter'

Plugin 'Chiel92/vim-autoformat'

Plugin 'Yggdroot/indentLine'
" Plugin 'haya14busa/incsearch.vim'

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

在.vimrc开头加入下面代码:

" 加载vundle配置文件
source $HOME/.vimrc.vundle

在vim执行

:PluginInstall

初步配置一些插件、主题和字体

下载DejaVu字体,将下载下来的ttf文件放入/usr/share/fonts中

字体下载参考:https://blog.csdn.net/devil_pull/article/details/17206377
vimrc写法参考:https://stackoverflow.com/questions/20015138/how-to-set-font-to-be-dejavu-sans-mono-in-vim-for-xp

.vimrc中加入:

" 插件配置---------------{
    {
    {

" 主题字体----------------------------{
    {
    {
colorscheme gruvbox
set background=dark
set guifont=DejaVu\ Sans\ Mono:h12
" }}}


" nerdtree-------------------{
    {
    {
" q是退出
" F1触发
nnoremap  :NERDTreeToggle
" 打开文件时退出
let g:NERDTreeQuitOnOpen = 1
" }}}


"}}}

安装youcompleteme

先用vundle安装youcompleteme

Plugin 'Valloric/YouCompleteMe'

安装过程参考官方教程 https://github.com/Valloric/YouCompleteMe#linux-64-bit ,

安装过程总结:
我安装了cmake llvm clang

sudo pacman -S cmake llvm clang

但是build-essential和python3-dev manjaro没有,装不了,(但没发现有什么影响)。
然后进入ycm目录

   cd .vim/bundle/YouCompleteMe  

执行(我需要c++补全):

python3 install.py --clangd-completer

打开vim没有出现ycm报错信息,安装成功

问题: 在vim中:PluginInstall 发现错误:no module named future 解决:
子模块未安装完整导致。进入YouCompleteMe目录

cd .vim/bundle/YouCompleteMe   

使用以下命令可以更新所有子模块。

git submodule update --init --recursive 

见文章http://www.jianshu.com/p/d908ce81017a?nomobile=yes

ycm C++配置(重点是.ycm_extra_config)

参考:
先完整阅读官方user’s guide:https://github.com/Valloric/YouCompleteMe#option-2-provide-the-flags-manually
整体参考:https://blog.csdn.net/yangcs2009/article/details/45506749
整体参考:https://www.hahack.com/codes/cmake/
.ycm_extra_conf配置参考:https://www.jianshu.com/p/5aaae8f036c1
输出编译器默认包含目录:https://blog.csdn.net/jing35030401/article/details/17303971
默认包含目录的读法:https://blog.csdn.net/yasi_xi/article/details/8833094

总结:
先配置ycm_conf文件以及vimrc,后期熟悉cmake再用cmake生成的database补全。
参考上文ycm.conf配置参考,将clang的默认包含目录放到ycm.conf中,

具体步骤:
1.复制官网的.ycm_extra_conf示例文件到家目录中,修改.ycm_extra_conf,添加 clang++的基本包含路径(clang++的路径与clang一样)
修改后的.ycm_extra_conf:

from distutils.sysconfig import get_python_inc
import platform
import os
import subprocess
import ycm_core

DIR_OF_THIS_SCRIPT = os.path.abspath( os.path.dirname( __file__ ) )
# 注意为了用vim打开.py文件时读取到家目录中的此文件导致第三方库目录错误的情况,并保证python complete调用的正确性,用绝对路径来确定第三方库目录
DIR_OF_THIRD_PARTY = os.path.join('/home/yszc/.vim/bundle/YouCompleteMe/third_party' )
SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]

# 下面的flag会在找不到compilation database时使用
# 根据具体情况来改变下面的flag
flags = [
# 编译后显示所有警告
'-Wall', 
# 显示额外警告信息
'-Wextra',
# 所有的警告变为错误,出现警告时也停止编译
# '-Werror',
# 关闭long long警告
'-Wno-long-long',
'-Wno-variadic-macros',
'-fexceptions',
# 禁止assert()函数
'-DNDEBUG',
# You 100% do NOT need -DUSE_CLANG_COMPLETER and/or -DYCM_EXPORT in your flags;
# only the YCM source code needs it.
'-DUSE_CLANG_COMPLETER',
'-DYCM_EXPORT=',
# THIS IS IMPORTANT! Without the '-x' flag, Clang won't know which language to
# use when compiling headers. So it will guess. Badly. So C++ headers will be
# compiled as C headers. You don't want that so ALWAYS specify the '-x' flag.
# For a C project, you would set this to 'c' instead of 'c++'.
'-x',
'c++',
# 包含clang++所包含的include文件夹
'-isystem',
'/usr/include',
'-isystem',
'/usr/local/include',
'-isystem',
'/usr/lib/clang/8.0.0/include',
'-isystem',
'/usr/include/c++/8.3.0',
'-isystem',
'/usr/include/c++/8.3.0/x86_64-pc-linux-gnu',
'-isystem',
'/usr/include/c++/8.3.0/backward'
# 下面包含的是当前项目include目录
# 包含当前目录
'-I',
'.',
# ...
]

# Clang automatically sets the '-std=' flag to 'c++14' for MSVC 2015 or later,
# which is required for compiling the standard library, and to 'c++11' for older
# versions.
if platform.system() != 'Windows':
  flags.append( '-std=c++11' )


# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
#
# You can get CMake to generate this file for you by adding:
#   set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
# to your CMakeLists.txt file.
#
# Most projects will NOT need to set this to anything; you can just change the
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
compilation_database_folder = ''

if os.path.exists( compilation_database_folder ):
  database = ycm_core.CompilationDatabase( compilation_database_folder )
else:
  database = None


def IsHeaderFile( filename ):
  extension = os.path.splitext( filename )[ 1 ]
  return extension in [ '.h', '.hxx', '.hpp', '.hh' ]


def FindCorrespondingSourceFile( filename ):
  if IsHeaderFile( filename ):
    basename = os.path.splitext( filename )[ 0 ]
    for extension in SOURCE_EXTENSIONS:
      replacement_file = basename + extension
      if os.path.exists( replacement_file ):
        return replacement_file
  return filename


def Settings( **kwargs ):
  if kwargs[ 'language' ] == 'cfamily':
    # If the file is a header, try to find the corresponding source file and
    # retrieve its flags from the compilation database if using one. This is
    # necessary since compilation databases don't have entries for header files.
    # In addition, use this source file as the translation unit. This makes it
    # possible to jump from a declaration in the header file to its definition
    # in the corresponding source file.
    filename = FindCorrespondingSourceFile( kwargs[ 'filename' ] )

    if not database:
      return {
        'flags': flags,
        'include_paths_relative_to_dir': DIR_OF_THIS_SCRIPT,
        'override_filename': filename
      }

    compilation_info = database.GetCompilationInfoForFile( filename )
    if not compilation_info.compiler_flags_:
      return {}

    # Bear in mind that compilation_info.compiler_flags_ does NOT return a
    # python list, but a "list-like" StringVec object.
    final_flags = list( compilation_info.compiler_flags_ )

    # NOTE: This is just for YouCompleteMe; it's highly likely that your project
    # does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
    # ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT.
    try:
      final_flags.remove( '-stdlib=libc++' )
    except ValueError:
      pass

    return {
      'flags': final_flags,
      'include_paths_relative_to_dir': compilation_info.compiler_working_dir_,
      'override_filename': filename
    }
  return {}


def GetStandardLibraryIndexInSysPath( sys_path ):
  for path in sys_path:
    if os.path.isfile( os.path.join( path, 'os.py' ) ):
      return sys_path.index( path )
  raise RuntimeError( 'Could not find standard library path in Python path.' )


def PythonSysPath( **kwargs ):
  sys_path = kwargs[ 'sys_path' ]
  for folder in os.listdir( DIR_OF_THIRD_PARTY ):
    if folder == 'python-future':
      folder = os.path.join( folder, 'src' )
      sys_path.insert( GetStandardLibraryIndexInSysPath( sys_path ) + 1,
                       os.path.realpath( os.path.join( DIR_OF_THIRD_PARTY,
                                                       folder ) ) )
      continue

    if folder == 'cregex':
      interpreter_path = kwargs[ 'interpreter_path' ]
      major_version = subprocess.check_output( [
        interpreter_path, '-c', 'import sys; print( sys.version_info[ 0 ] )' ]
      ).rstrip().decode( 'utf8' )
      folder = os.path.join( folder, 'regex_{}'.format( major_version ) )

    sys_path.insert( 0, os.path.realpath( os.path.join( DIR_OF_THIRD_PARTY,
                                                        folder ) ) )
  return sys_path

2.在vimrc中添加ycm配置

" youcompleteme---------------{
    {
    {
" C语义补全
let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
" python语义补全
let g:ycm_python_binary_path = '/usr/bin/python3'
" GoTo映射
nnoremap g :YcmCompleter GoToDefinitionElseDeclaration
" 停止提示是否载入本地ycm_extra_conf文件
let g:ycm_confirm_extra_conf = 0
" 语法关键字补全
let g:ycm_seed_identifiers_with_syntax = 1
" 开启 YCM 基于标签引擎
let g:ycm_collect_identifiers_from_tags_files = 1
" 从第2个键入字符就开始罗列匹配项
let g:ycm_min_num_of_chars_for_completion=2
" 在注释输入中也能补全
let g:ycm_complete_in_comments = 1
" 在字符串输入中也能补全
let g:ycm_complete_in_strings = 1
" 注释和字符串中的文字也会被收入补全
let g:ycm_collect_identifiers_from_comments_and_strings = 1
" 错误和警告符号
let g:ycm_error_symbol = '✘'
let g:ycm_warning_symbol = '►'
" 打开错误和警告表
noremap  : YcmDiags
"}}}

安装过程中的问题:编辑.py文件时报错找不到/home/yszc/third_party的情况,通过:YcmDebugInfo看到错误报告在/tmp/中,查之,发现在我主目录中的.ycm_extra_conf.py报错,原来python补全器需要调用.ycm_extra_conf中的PythonSysPath函数而该函数需要一个第三方库路径,但是该路径是通过当前脚本路径+/third_path来读取的,这导致在打开python文件时,ycm会发现/home/user/third_party目录不存在,为防止此问题,将家目录中的库目录改为ycm内的绝对路径,(该文件就是从ycm目录里拷贝出来的),修改家目录中的.ycm_extra_conf.py中第8行如下:

# 注意为了防止子目录用vim打开.py文件时读取到家目录中的此文件导致第三方库目录错误的情况,为保证python complete调用的正确性,用绝对目录来确定第三方库目录
    DIR_OF_THIRD_PARTY = os.path.join('/home/yszc/.vim/bundle/YouCompleteMe/third_party' )

ycm python配置

.py文件中输入:YcmShowDetailedDiagnostic
出现:

NoDiagnosticSupport: YCM has no diagnostics support for this filetype; refer to Syntastic docs
 if using Syntastic.

参考:https://groups.google.com/forum/#!topic/ycm-users/feF1hauaJ14
ycm没有提供python诊断的功能

ycm python第三方库补全:
参考:https://github.com/Valloric/YouCompleteMe#python-semantic-completion
~/.ycm_extra_config.py中的:

def Settings(**kwargs):

函数中的return中加入:(注意是最后一个return不是if中的return!)

return {
        # 第三方库添加
        'sys_path': ['/home/yszc/.local/lib/python3.7/site-packages']
    }

第三方库目录位置的查找用

pip show yourpackage

来查找

在虚拟python环境中添加第三方库:

~/.ycm_extra_config.py中的:

def Settings(**kwargs):

函数中的return中加入:(注意是最后一个return不是if中的return!)

return {
		#解释器添加
		'interpreter_path': '/home/yszc/Projects/python_projects/machine_learning/machine_learning_env/bin/python3',
        # 第三方库添加
        'sys_path': ['/home/yszc/Projects/python_projects/machine_learning/machine_learning_env/lib/python3.7/site-packages']

    }

ctags tagbar 安装与配置

安装ctags:

sudo pacman -S ctags

安装tagbar:

Plugin 'majutsushi/tagbar'

vimrc添加:

" tagbar-----------------------{
    {
    {
" tagbar的q是退出
" 设置触发按键
noremap  : TagbarToggle
" 设置tagbar要使用的ctags路径
let g:tarbar_ctags_bin = '/usr/bin/ctags'
" 设置窗口宽度
let g:tarbar_width = 30
" 显示在窗口右边
let g:tarbar_right = 1
" 开启自动预览
let g:tagbar_autopreview = 1
" 光标自动切换到tagbar中
let g:tagbar_autoclose = 1
" }}}

安装快速移动插件EasyMotion

介绍
EasyMotion在触发时,会为附近的单词。。。随机标上符号,只要按下对应的符号就能跳转到对应的位置,教程参考:https://github.com/easymotion/vim-easymotion , http://www.wklken.me/posts/2015/06/07/vim-plugin-easymotion.html#yong-fa-1-tiao-zhuan-dao-dang-qian-guang-biao-qian-hou-de-wei-zhi-wb

步骤:

 Plugin 'easymotion/vim-easymotion'

默认双leader键触发,改为单leader键,vimrc中加入:

map  (easymotion-prefix)
# 不能用nnoremap,会失效
nmap J (easymotion-j)
nmap K (easymotion-k)
nmap W (easymotion-w)
nmap B (easymotion-b)
#这个有奇效
nmap F (easymotion-f)

vim设置ctrl-s保存 ctrl-q退出:

ctrl-s是终端默认锁屏键,要禁止掉。
参考:http://ju.outofmemory.cn/entry/42007
在.zshrc中加入:

stty -ixon

在vimrc中加入:

nnoremap  :w
nnoremap  :q

模糊搜索神器fzf安装:

参考:https://segmentfault.com/a/1190000011328080
配置参见: https://blog.csdn.net/Demorngel/article/details/85464796
fzf example:https://github.com/junegunn/fzf/wiki
步骤:
下载安装fzf:

git clone https://github.com/junegunn/fzf.git 
./install

安装后发现 ** 终端补全失效:
更新系统

git pull
./install

安装后发现无法使用(E121 E117),所以删除:

./uninstall

使用pacman下载:

sudo pacman -S fzf

vim下载安装fzf.vim,在.vimrc.bundle中配置:

set rtp+=/home/username/.fzf/
    Plugin 'junegunn/fzf.vim'

教程介绍参考:https://segmentfault.com/a/1190000016186540?utm_source=tag-newest#articleHeader2
总结:
1。 :Files 递归搜索当前目录中的文件名
2。 :Buffers 搜索Buffer中的文件名,常用于标签切换
3。 :Lines 搜索Buffer文件中的行内容
4。:BLines搜索当前Buffer中的行内容
5。为了能在当前目录中搜索行内容,采用ripgrep加脚本的形式:
先下载ripgrep:

sudo pacman -S ripgrep

vimrc写入:

" fzf-----------------------{
    {
    {
" esc是退出
" 要先保存再搜索
"双f在当前目录搜索文件 
nnoremap  f :w:Files
"双b切换Buffer中的文件
nnoremap  b :wBuffers
"双p在当前所有加载的Buffer中搜索包含目标词的所有行,:BLines只在当前Buffer中搜索
nnoremap  l :wLines
"双h在Vim打开的历史文件中搜索,相当于是在MRU中搜索,:History:命令历史查找
nnoremap  h :wHistory
"双r利用ripgrep搜索当前文档中的行
nnoremap  r :wRg
"调用Rg进行搜索,包含隐藏文件
command! -bang -nargs=* Rg
      \ call fzf#vim#grep(
      \   'rg --column --line-number --no-heading --color=always --smart-case --hidden '.shellescape(), 1,
      \   0 ? fzf#vim#with_preview('up:60%')
      \           : fzf#vim#with_preview('right:50%:hidden', '?'),
      \   0)
" }}}

fzf 利用tab在窗口跳转,
打开.profile文件,在FZF_DEFAULT_OPTS中添加fzf

控制台分屏tmux安装

sudo pacman -S tmux

Oh My Tmux主题安装:

$ cd
$ git clone https://github.com/gpakosz/.tmux.git
$ ln -s -f .tmux/.tmux.conf
$ cp .tmux/.tmux.conf.local .

然后阅读~/.tmux.conf 了解各快捷键的用处。

配置教程参考:https://www.cnblogs.com/cherishry/p/5674518.html
学习教程:https://www.cnblogs.com/maoxiaolv/p/5526602.html
更好的教材:https://www.cnblogs.com/oxspirt/p/10218284.html

学习总结:
快捷键:
1。创建会话:

tmux new -s 

在tmux中按下 prefix 加冒号(:)
输入:

new -s 

从而再创建一个新的会话。

prefix+s可以浏览已经创建的会话
若tmux会话已经创建但tmux尚未执行,使用:

  tmux attach    

可以进入之前创建的会话。

2.创建窗口
prefix+c 创建新窗口
prefix+number 切换到指定编号的窗口
prefix+%或"在窗口中分割出窗格
(窗口是个窗格容器,你可以将多个窗格放置在窗口中)
总之,一个tmux会话包含多个窗口,一个窗口可以包含多个窗格

tmux翻页,ctrl+[进入vim复制模式,vim复制模式中c-f c-b翻页,space进入复制模式,enter结束复制模式,ctrl-]粘贴

tmuxinator安装

由于tmuxinator依赖ruby的gem下载,要先下载ruby:

sudo pacman -S ruby
gem install tmuxinator

报错:

WARNING:  You don't have /home/yszc/.gem/ruby/2.6.0/bin in your PATH,
	  gem executables will not run.

.profile文件中加入该环境变量,
vim .profile
加入:

# 将ruby支持的可执行文件目录添加到环境变量中
export PATH=$PATH:/home/yszc/.gem/ruby/2.6.0/bin

在.zshrc中设置别名:

alias mux='tmuxinator'

初步使用:

mux n ws # 创建工程ws
mux o ws # 打开工程ws的配置文件
mux e ws # 同上
mux c ws ws1 # 复制ws工程到ws1
mux d ws # 删除ws工程
mux l # 显示所有工程
mux ws # 开启ws工程

参考:https://www.jianshu.com/p/49b70f705acf
mux n ml_learn 创建一个ml_learn工程。
自动进入配置文件,默认格式如下:

name: ws # session名称
root: ~/ # 工程根目录,活动Pane会首先cd到此目录

windows:
  - editor: # 第1个名为Editor的Window
      layout: main-vertical # Pane的布局
      panes: # 各个Pane
        - vim # 第一个Pane运行vim命令
        - guard # 第二个Pane运行guard命令
  - server: bundle exec rails s # 第2个名为server的Window,运行命令为bundle
  - logs: tail -f log/development.log # 第3个名为logs的Window,运行命令为tail

在修改为自己的配置:

# /home/yszc/.tmuxinator/ml_learn.yml

name: ml_learn
root: ~/

windows:
  - notebook: vim $HOME/Desktop/机器学习笔记.txt
  - editor: source $HOME/Tools/tmux_win_editor.sh
  - shell: 
  - jupyter: source $HOME/Tools/tmux_win_jupyter.sh

其中:
tmux_win_editor.sh为:

#!/bin/sh
# 配置tmux editor窗口必要命令
cd ~/Projects/python_projects/machine_learning
source ~/Projects/python_projects/machine_learning/machine_learning_env/bin/activate
vim ~/Projects/python_projects/machine_learning/src/classification.py

tmux_win_jupyter为:

#!/bin/sh
# 配置tmux jupyter窗口必要命令
cd ~/Projects/python_projects/machine_learning
source ~/Projects/python_projects/machine_learning/machine_learning_env/bin/activate
jupyter notebook

自定义页面布局:
https://stackoverflow.com/questions/9812000/specify-pane-percentage-in-tmuxinator-project

自己设置好一个window的layout后,输入:

tmux list-window

将获得的layout粘贴到yml文件中的layout项上

在.tmux.conf 配置中:
tmux 的 ctrl-t tab可以在两个常用窗口不断切换,n,p切换window有-r选项可以方便不断切换
-r参数不要加到窗格切换选项中

vim中文文档

参考:https://github.com/yianwillis/vimcdoc
查看vim编码:

:set enc?

发现是utf-8.
在.vimrc.vundle中加入

Plugin 'yianwillis/vimcdoc'

:PluginInstall即可。

安装UltiSnips,代码块插入神器

参考:https://blog.csdn.net/solomonxiewise/article/details/85916085
安装配置步骤:
vundle写入:

Plugin 'SirVer/ultisnips'

vimrc写入:

 " ultisnips-----------------{
    {
    {
" 指定snipper存储文件夹
let g:UltiSnipsSnippetDirectories=['UltiSnips']
" 此键默认为tab,会导致you_complete_me混乱,一定要改
let g:UltiSnipsExpandTrigger=""
" 展开可用snips表
let g:UltiSnipsListSnippet=""
" 只会在打开时映射下面的跳转键,应该不会影响之前的映射
let g:UltiSnipsJumpForwardTrigger=""
let g:UltiSnipsJumpBackwardTrigger=""
" 指定python版本,py2.7 或者 py3.6
let g:UltiSnipsUsePythonVersion = 3
" 编辑snips窗口以分割窗口打开,此操作会在当前目录创建UltiSnips文件夹并新建.snippets文件
let g:UltiSnipsEditSplit="vertical"
" }}}

出现问题:ExpandTrigger无效
参考:http://www.itboth.com/d/aYBfAr/python-snippet-youcompleteme-vim
参考:https://blog.csdn.net/solomonxiewise/article/details/85916085 解决:

必须在ultisnips文件夹下创建一个UltiSnips文件夹,将所有自定义代码都放在这里。

如何自定义请见:https://github.com/SirVer/ultisnips 里面的视频教材(kxsw)
snips教程:https://blog.51cto.com/10245818/2167828
高级snips需要python和正则表达式知识,后面要看看基本python语法和snips正则表达式

但目前就先从honza/vim-snippet项目复制一些代码配置一些基本的snippet:

自定义总结:
首先:

cd ~/.vim/bundle/ultisnips/
mkdir UltiSnips
cd UltiSnips
vim snippets.snippets

加入

   # snippet代码块
    snippet usnip "ultisnips snippet definition" b
    `!p snip.rv = "snippet"` ${1:trigger} "${2:description}" ${3:b}
    ${0:${VISUAL}}
    `!p snip.rv = "endsnippet"`
    endsnippet

用于快速扩展snippet定义代码块

1.创建c++补全文件:

vim cpp.snippets

(目前cpp.snippets可以正确的匹配.cc .cpp .h文件,但cc.snippets不行)
加入:(参考了google c++ 编码规范和honza/vim-snippet的代码)

# python函数配置
global !p
def get_args(arglist):
	args = [arg.strip() for arg in arglist.split(',') if arg]
	return args

def write_docstring_args(arglist, snip):
	args = str(arglist).split(',')

	if len(args) > 1:
		c = 0
		for arg in args:
			if c == 0:
				snip.rv += arg
				c = 1
			else:
				snip += '*       : %s' % arg.strip()
	else:
		snip.rv = args[0]
endglobal

# 代码块

#文件头作者信息
snippet head "file header" b
/*
* File:             `!p snip.rv = fn`
*
* Author:           `echo $USER`  
* Created:          `date +%m/%d/%y` 
* Description:      ${4:${VISUAL}}
* Encoding:			    `!v &fileencoding`
*
*/
${0}
endsnippet

#函数定义与实现
snippet fun "Function Header" 
/*
* Description:      ${4:${VISUAL}}
*/
${1:ReturnType} ${2:FunctionName}(${3:param}){
	${0}
}
endsnippet

#main函数
snippet main "main() (main)"
int main(int argc, char *argv[])
{
	${VISUAL}$0
	return 0;
}
endsnippet

# 头文件保护
snippet #ifndef "#ifndef ... #define ... #endif"
#ifndef ${1/([A-Za-z0-9_]+).*/$1/}
#define ${1:SYMBOL_H_} 
$2
#endif /* ifndef $1 */
endsnippet

# 头文件注释
snippet include_order "include order tip" b
//本类声明

//C系统文件

//C++系统文件

//外部库头文件

//本项目头文件

endsnippet

# 读取文件名构造类的头文件,文件名,以下划线读取文件名称并整合到类名上
snippet h_p "An entire .h generator" b
/*
* File:             `!p snip.rv = fn`
*
* Author:           `echo $USER`  
* Created:          `date +%m/%d/%y` 
* Description:      ${1:None}
* Encoding:			    `!v &fileencoding`
*/

//确保header guard宏名永不重复
#ifndef ${3:`!v substitute(Vim_snippets_filename('$1_H_','ClassName'),'.*','\U&\E','')`}
#define $3

//C系统文件

//C++系统文件

//外部库头文件

//本项目头文件

//前置声明


class ${2:`!v substitute(substitute(Vim_snippets_filename('$1','ClassName'),'^.','\u&',''), '_\(\w\)', '\u\1', 'g')`}
{
 private:
	$4

 public:
	$2();
	virtual ~$2();
};

#endif /* $3 */
endsnippet

snippet class "a single class" b
class $1
{
 private:
	$2

 public:
	$1();
	virtual ~$1();
}
endsnippet

# 存取函数 默认类成员变量以下划线结尾
snippet set "set template 小写" b
void set_${1:param_name}(${2:type} $1){ this->$1_ = $1; }
endsnippet

snippet get "get template 小写" b
${1:type} get_${2:param_name} const (){ return this->$2_; }
endsnippet

# 类函数定义
snippet cla_fun_dec "class function declare 大写" b
/*
* @brief: ${5:功能概述:输入输出(功能)、是否分配了需要调用者释放的空间、是否会修改或释放引用参数}
*/
${1:ReturnType} ${2:FunctionName}(${3:param})
{
	${0:FunctionBody}
}
endsnippet

# .cc预编码
snippet cc_p "cc precode" b
//本类声明
#include "${1:Header}.h"
//C系统文件

//C++系统文件

//外部库头文件

//本项目头文件


namespace{
$2
}
endsnippet

# .cc类函数定义
snippet cla_fun_def "class function define" b
/**
* @brief: ${5:实现概述}
*/
${1:ReturnType} ${4:`!v substitute(substitute(Vim_snippets_filename('$1','ClassName'),'^.','\u&',''), '_\(\w\)', '\u\1', 'g')`}::${2:FunctionName}(${3:param})
{
	${0:FunctionBody}
}
endsnippet


# to do
snippet todo "todo 注释" b
//TODO(yszc):$1
endsnippet

# if
snippet if "单独一个if" b
if (${1}) {
	${2}
} 
endsnippet

# ifel
snippet ifel "if else" b
if (${1}) {
	${2}
} else {
	${3}
} 
endsnippet

# elif
snippet elif "else if" w
else if ($1) {
	$2
} 
endsnippet

# else
snippet else "else" w
else {
	$1
} 
endsnippet

# while
snippet while "while" b
while ($1) {
	$2
} 
endsnippet

# for
snippet for "for" b
for (${1: }; ${2: }; ${3: }) {
	$4
}
endsnippet

# switch
snippet switch "switch" b
switch ($1) {
	case $2: {
		$3
	break;
	}
	default: {
		$4
	}
}
endsnippet

然后随便新建一个.h或.cc .cpp后缀的文件,ycm会自动显示ultisnip选择,按下ctrl-e就可扩展

2.python代码块以后再配置:

nerdcommenter 代码注释插件

.vimrc.vundle中添加:

Plugin 'scrooloose/nerdcommenter'

:PluginInstall
用法:
紧靠着添加注释

 cc

最左侧添加注释

cb

取消注释

cu

vimrc中加入:

" nerdcommenter-------------------{
    {
    {
" cc 紧贴当前行添加注释
" cb 紧贴左侧行添加注释
" cu 取消注释
" 注释自动添加空格
let g:NERDSpaceDelims=1
" }}}

自动格式化插件 vim-autoformat

参考:https://blog.csdn.net/demorngel/article/details/69053613
参考:https://blog.csdn.net/SimpleForest/article/details/77429744
参考:https://github.com/Chiel92/vim-autoformat
步骤:
.vimrc.vundle加入:

Plugin 'Chiel92/vim-autoformat'

:PluginInstall
下载astyle(c c++ java)和autopep8(python)

sudo pacman -S astyle
sudo pacman -S autopep8

vimrc中加入:

" vim-autoformat-------------------{
    {
    {
" 定义astyle c++代码格式化风格
" 对指定后缀的文件名,使用指定的c++格式化工具,设置c++代码风格为google,缩进设为2空格,节省横向空间。
let g:formatdef_my_cpp = '"astyle --style=google --indent=spaces=2"'
let g:formatters_cpp = ['my_cpp']
" F12触发自动格式化
noremap  :Autoformat

augroup autoformat
  autocmd!
" 最好不要将所有文件都进行保存格式化,比如.snippets文件不能格式化,不然你的代码块会乱掉
    au BufWrite *.h,*.cpp,*.cc,*.cxx,*.py :Autoformat
augroup END
" }}}

indentLine显示缩进线

参考:https://segmentfault.com/a/1190000014560645
.vimrc.vimrc加入

Plugin 'Yggdroot/indentLine'

.vimrc加入:

" indentLine-----------------{
    {
    {
let g:indentLine_noConcealCursor = 1
" 这个颜色正好是灰色,0就看不见了
let g:indentLine_color_term = 239
let g:indentLine_char = '|'
" }}}

以后待研究。

airline配置安装

安装:

Plugin 'vim-airline/vim-airline'

问题:出现乱码,且没有箭头。
试了试官网的解决方案:

The powerline font symbols are partially messed up
You are likely
using the fontconfig method. If that is the case, you need to override
the space character like so:

if !exists('g:airline_symbols')
  let g:airline_symbols = {}
endif
let g:airline_symbols.space = "\ua0"

The powerline font symbols are not showing up Adding let
g:airline_powerline_fonts = 1 to your vimrc will automatically
populate the g:airline_symbols dictionary with the proper font glyphs
for various symbols.

The powerline font is not perfectly lined up, or there a bit of
whitespace in between symbols, or they are cut off(和字体有关)

If you are using fontconfig, make sure bitmap fonts are not disabled.
That rule, if exists, is usually under
/etc/fonts/conf.d/70-no-bitmaps.conf for linux users, which might be a
symbolic link. If that’s the case, remove that link so that bitmap
fonts are available system-wide.
(参考这里,我将70-no-bitmaps.conf做了备份然后删掉了,没啥改观)

Also make sure Terminal uses the same font style (e.g. Meslo) as
specified in your vimrc. (参考这里,我将终端字体改成了和vim相同的DejaVu字体)

结果:出现了箭头,但还是有些奇怪的乱码。箭头有小空隙但无伤大雅。

安装autopairs

Plugin 'jiangmiao/auto-pairs'

:PluginInstall

问题:插入模式下变成了backspace
原因:autopairs映射了到自己的操作,覆盖了我的映射
解决:加入:

" auto-pairs------------------------{
     {
     {
" 关闭映射
let g:AutoPairsMapCh = 0
" }}}

NerdTree改进

参考:https://www.jianshu.com/p/3066b3191cb1
安装vim-nerdtree-tabs,用于统一标签页:

Plugin 'jistr/vim-nerdtree-tabs'

vimrc中nerdtree配置修改为:

nnoremap  :NERDTreeTabsToggle
inoremap  :NERDTreeTabsToggle

参考:https://www.jianshu.com/p/3066b3191cb1
安装nerdtree-git-plugin,显示git信息

Plugin 'Xuyuanp/nerdtree-git-plugin'

vimrc中加入:

let g:NERDTreeIndicatorMapCustom = {
    \ "Modified"  : "✹",
    \ "Staged"    : "✚",
    \ "Untracked" : "✭",
    \ "Renamed"   : "➜",
    \ "Unmerged"  : "═",
    \ "Deleted"   : "✖",
    \ "Dirty"     : "✗",
    \ "Clean"     : "✔︎",
    \ 'Ignored'   : '☒',
    \ "Unknown"   : "?"
    \ }

Git相关设置

commit提交规范:https://blog.csdn.net/h8y0bDJVUkwE1LboZlE/article/details/79695666

修改 ~/.gitconfig, 添加:

[commit]
template = ~/.gitmessage

修改gitmessage , 添加额外注释:

vim ~/.gitmessage

添加snippets:
在all.snippets中添加git的commit句法:

snippet git_commit "git提交格式" b
# Header 是必需的,Body 和 Footer 可以省略
# type: 用于说明 commit 的类别,只允许使用下面7个标识。
#   feat:新功能(feature)
#   fix:修补bug
#   docs:文档(documentation)
#   style: 格式(不影响代码运行的变动)
#   refactor:重构(即不是新增功能,也不是修改bug的代码变动)
#   test:增加测试
#   chore:构建过程或辅助工具的变动
#
# scope: 用于说明 commit 影响的范围,比如数据层、控制层、视图层等等,视项目不同而不同。如果对项目的更改是全局性的或者难以归结到一个目录中时可以为空
# subject: 是 commit 目的的简短描述,不超过50个字符。要求:
#   * 以动词开头,使用第一人称现在时,比如change,而不是changed或changes
#   * 第一个字母小写
#   * 结尾不加句号
${1:}(${2:}): ${3:}

# body: 详细描述,可分为多行,要求:
#   * 为什么这次改动是必要的
#   * 此次改动处理了什么问题
#   * 有无任何副作用
${4:}

# footer: 
# - Include a link to the ticket, if any.
# - BREAKING CHANGE
${5:
} endsnippet

vim的复制粘贴问题,用好寄存器:

https://jingyan.baidu.com/article/7f766daf43789b4101e1d0f3.html

vim esc键有延迟

https://blog.csdn.net/henryhu712/article/details/83904824

github上的一个不错的vim配置

针对c++的全套vim解决方案,要是写c++可以参考
https://github.com/yangyangwithgnu/use_vim_as_ide#3.2
有趣的东西:
-代码收藏
-快速编辑结对符
-markdown 即时预览
参考并新增:

" 基于缩进或语法进行代码折叠
"set foldmethod=indent
set foldmethod=syntax
" 启动 vim 时关闭折叠代码
set nofoldenable

关注一下tpope的几个插件:
https://github.com/tpope
vim-surround:https://blog.csdn.net/u011500307/article/details/33400853

vimtex

首先下载latex环境–texlive,texlive包含了整个latex的相关工具,后面主要使用xelatex
参考:https://techknight.eu/2015/09/30/setup-latex-environment-linux-manjaro-pacman/
非常大,下载372mb,解压1.7Gb:

sudo pacman -S texlive-most

输出记录:

1) texlive-bibtexextra  2) texlive-core  3) texlive-fontsextra
   4) texlive-formatsextra  5) texlive-games  6) texlive-humanities
   7) texlive-latexextra  8) texlive-music  9) texlive-pictures
   10) texlive-pstricks  11) texlive-publishers  12) texlive-science

texlive-bibtexextra-2019.50908-1  texlive-core-2019.50917-1
            texlive-fontsextra-2019.50876-1          
            texlive-formatsextra-2019.50602-1  texlive-games-2019.50815-1
            texlive-humanities-2019.50921-1  texlive-latexextra-2019.50920-1
            texlive-music-2019.50602-1  texlive-pictures-2019.50872-1
            texlive-pstricks-2019.50587-1  texlive-publishers-2019.50915-1
            texlive-science-2019.50760-1

updmap custom entries should go into /etc/texmf/web2c/updmap-local.cfg
fmtutil custom entries should go into /etc/texmf/web2c/fmtutil-local.cnf
error while loading shared libraries: libpoppler.so.89: cannot open sh
ared object file: No such file or directory

缺失poppler库,升级:
sudo pacman -S poppler
报错:

  :: 安装 poppler (0.79.0-1) 破坏依赖 'poppler=0.76.1' (poppler-glib 需要)    
:: 安装 poppler (0.79.0-1) 破坏依赖 'poppler=0.76.1' (poppler-qt5 需要)

依赖问题,决定先删除poppler-glib poppler-qt5

sudo pacman -Rs poppler-glib
:: gimp可选依赖于poppler-glib: for pdf support
:: tumbler可选依赖于poppler-glib: for PDF thumbnails

软件包 (1) poppler-glib-0.76.1-1

全部移去体积:  2.37 MiB

sudo pacman -Rs poppler-qt5
:: okular:移除 poppler-qt5 将破坏依赖关系 'poppler-qt5'                      
:: qpdfview:移除 poppler-qt5 将破坏依赖关系 'poppler-qt5' 

删除okular 和 qpdfview:

sudo pacman -Rs qpdfview
sudo pacman -Rs okular
:: python-pyqt5可选依赖于qt5-webkit: QtWebKit, QtWebKitWidgets
警告:检测到依赖关系环:
警告:phonon-qt5-gstreamer 将在它 phonon-qt5 的依赖关系之后被删除

软件包 (33) accounts-qml-module-0.7-2  discount-2.2.6-1  djvulibre-3.5.27-4
            kaccounts-integration-19.04.3-1  kactivities-5.60.0-1
            kcmutils-5.60.0-1  kdeclarative-5.60.0-1  kirigami2-5.60.0-1
            kjs-5.60.0-1  kpackage-5.60.0-1  kpty-5.60.0-1
            libaccounts-glib-1.24-1  libaccounts-qt-1.15-2
            libkexiv2-19.04.3-1  libspectre-0.2.8-2  phonon-qt5-4.10.3-1
            phonon-qt5-gstreamer-4.9.1-1 !poppler-qt5-0.76.1-1!
            purpose-5.60.0-1  qca-2.2.1-2  qt5-graphicaleffects-5.13.0-1
            qt5-location-5.13.0-1  qt5-quickcontrols-5.13.0-1
            qt5-quickcontrols2-5.13.0-1  qt5-sensors-5.13.0-1
            qt5-webchannel-5.13.0-1  qt5-webkit-5.212.0alpha3-3
            signon-kwallet-extension-19.04.3-1  signon-plugin-oauth2-0.24-2
            signon-ui-0.17+20150611-2  signond-8.60-1  threadweaver-5.60.0-1
            okular-19.04.3-1

从上述删除软件包可以发现之前的okular下载了老版本的poppler-qt5-0.76,导致新旧依赖。
安装poppler:

sudo pacman -S poppler

重新下载okular:

sudo pacman -S okular 
正在解析依赖关系...
:: 有 2 个软件包可提供 phonon-qt5-backend :
:: 软件仓库 extra
   1) phonon-qt5-gstreamer  2) phonon-qt5-vlc

输入某个数字 ( 默认=1 ): 2
正在查找软件包冲突...
警告:检测到依赖关系环:
警告:phonon-qt5-vlc 将在它 phonon-qt5 的依赖关系之前被安装

软件包 (33) accounts-qml-module-0.7-2  discount-2.2.6-1  djvulibre-3.5.27-4
            kaccounts-integration-19.04.3-1  kactivities-5.60.0-1
            kcmutils-5.60.0-1  kdeclarative-5.60.0-1  kirigami2-5.60.0-1
            kjs-5.60.0-1  kpackage-5.60.0-1  kpty-5.60.0-1
            libaccounts-glib-1.24-1  libaccounts-qt-1.15-2
            libkexiv2-19.04.3-1  libspectre-0.2.8-2  phonon-qt5-4.10.3-1
            phonon-qt5-vlc-0.10.3-1  poppler-qt5-0.79.0-1  purpose-5.60.0-1
            qca-2.2.1-2  qt5-graphicaleffects-5.13.0-1  qt5-location-5.13.0-1
            qt5-quickcontrols-5.13.0-1  qt5-quickcontrols2-5.13.0-1
            qt5-sensors-5.13.0-1  qt5-webchannel-5.13.0-1
            qt5-webkit-5.212.0alpha3-3  signon-kwallet-extension-19.04.3-1
            signon-plugin-oauth2-0.24-2  signon-ui-0.17+20150611-2
            signond-8.60-1  threadweaver-5.60.0-1  okular-19.04.3-1

下载大小:     0.26 MiB
全部安装大小:  114.58 MiB

选择第二个软件包发现poppler-qt5的版本为0.79已经正常。
查看库版本:

ls /usr/lib/ | grep libpoppler
libpoppler-cpp.so
libpoppler-cpp.so.0
libpoppler-cpp.so.0.7.0
libpoppler-qt5.so
libpoppler-qt5.so.1
libpoppler-qt5.so.1.20.0
libpoppler.so
libpoppler.so.89
libpoppler.so.89.0.0

版本为89,成功安装

再次重新安装texlive:

sudo pacman -S texlive-most

成功

根据help文件:

g:vimtex_compiler_latexmk_engines Defines a map between TeX program directive (|vimtex-tex-program|) and compiler engine. This
is used by |vimtex-latexmk| to define the LaTeX program. The _ key
defines the default engine.

Note: If the TeX program directive is not specified within the main
project
file, and if $pdf_mode is added to a project-specific .latexmkrc
file, then the compiler engine will be deduced from the value of
$pdf_mode. The supported values of $pdf_mode are 0 (pdflatex), 4
(lualatex) and 5 (xelatex). See the latexmk documentation for details.

Default value: >

let g:vimtex_compiler_latexmk_engines = {
    \ '_'                : '-pdf',
    \ 'pdflatex'         : '-pdf',
    \ 'dvipdfex'         : '-pdfdvi',
    \ 'lualatex'         : '-lualatex',
    \ 'xelatex'          : '-xelatex',
    \ 'context (pdftex)' : '-pdf -pdflatex=texexec',
    \ 'context (luatex)' : '-pdf -pdflatex=context',
    \ 'context (xetex)'  : '-pdf -pdflatex=''texexec --xtx''',
    \}

创建.latexmkrc文件,

cd ~
vim .latexmkrc

文件中设置为使用xelatex

$pdf_mode=5

在vim中输入\lo查看编译器信息发现已经开始使用xelatex,设置成功:

Latexmk: This is Latexmk, John Collins, 17 March 2019, version: 4.63b.
Viewing pdf
======= Need to update make_preview_continuous for target files
Latexmk: Previewer is already running
Rule 'xelatex': The following rules & subrules became out-of-date:
      'xelatex'
------------
Run number 1 of rule 'xelatex'
------------
Latexmk: applying rule 'xelatex'...
------------
Running 'xelatex -no-pdf -file-line-error -synctex=1 -interaction=nonstopmode -recorder  "mathbook.tex"'

再安装中文支持:
参考:
https://www.cnblogs.com/propheteia/archive/2012/10/16/2726872.html
https://blog.csdn.net/baccon/article/details/51301683
CJK宏包下载网址:
https://cjk.ffii.org/
Latex,CJK理解:
https://zhidao.baidu.com/question/175441414431873644.html

无需安装中文支持,直接倒入xeCJK宏包,xeCJK中可以直接使用系统字体并支持中文。
获取中文字体:复制windows文件夹中的fonts文件夹到linux,将simsum.ttc simhei.ttf 放入/usr/share/fonts/windows-fonts中。
参考:https://blog.csdn.net/Box_clf/article/details/85224413
出现问题:控制台字体全部自动变为宋体:
原因参考:https://forums.debiancn.org/t/topic/954/7

在 xfce4-terminal 的设置 - Appearance 中取消勾选 “Use system font”,然后选择一项等宽字体

xfce4-terminal 无法分开设置中西文字体,中文字体是由 fontconfig
中的回退顺序自动选择的。例如,如果您将终端字体设置为 “Monospace”,那么中文字体将是 fc-match -s Monospace
输出中从上往下的第一个中文字体

例如在下面的情况中,将终端字体设置为 “Monospace”,实际使用的西文字体是 DejaVu Sans Mono,中文字体是
WenQuanYi Zen Hei Mono

fc-match输出:发现宋体放到了思源黑体的前面

 yszc@yszc-pc: fc-match -s DejaVu
simsun.ttc: "宋体" "常规"
Vera.ttf: "Bitstream Vera Sans" "Roman"
NimbusSans-Regular.otf: "Nimbus Sans" "Regular"
MuktiNarrow.ttf: "Mukti Narrow" "Regular"
malayalam.ttf: "malayalam" "Regular"
Sampige.ttf: "Sampige" "Regular"
padmaa-Medium-0.5.ttf: "padmaa" "regular"
TSCu_Paranar.ttf: "TSCu_Paranar" "Regular"
TSCu_paranarb.ttf: "TSCu_Paranar" "Bold"
TSCu_paranari.ttf: "TSCu_Paranar" "Italic"
FuraMono-Regular Powerline.otf: "Fira Mono for Powerline" "Regular"
DroidSansFallbackFull.ttf: "Droid Sans Fallback" "Regular"
DejaVu Sans Mono for Powerline.ttf: "DejaVu Sans Mono for Powerline" "Book"
DroidSansFallbackLegacy.ttf: "Droid Sans Fallback" "Regular"
Source Code Pro for Powerline.otf: "Source Code Pro for Powerline" "Regular"
Go Mono for Powerline.ttf: "Go Mono for Powerline" "Regular"
SourceHanSansCN-Regular.otf: "思源黑体 CN" "Regular"

修改字体优先级:
主要参考,非常好:https://coswind.github.io/blog/2013/01/19/archlinux-font-pei-zhi/
临时修改:

/etc/fonts/conf.d:sudo mousepad 65-nonlatin.conf

将宋体向下方移动即可
查看ttf文件的正确名称:
https://stackoverflow.com/questions/16788330/how-do-i-get-the-font-name-from-an-otf-or-ttf-file
利用下面的代码:可以查看当前文件夹下的otf文件的字体名称:

fc-scan --format "%{postscriptname}\n" *.otf

查出思源字体的名称如下:

SourceHanSansCN-Bold
SourceHanSansCN-ExtraLight
SourceHanSansCN-Heavy
SourceHanSansCN-Light
SourceHanSansCN-Medium
SourceHanSansCN-Normal
SourceHanSansCN-Regular

初步设置参考:https://blog.csdn.net/nkcxr/article/details/7799904
vimtex自动隐藏$符号: 解决方法:
https://stackoverflow.com/questions/18160953/disable-latex-symbol-conversion-in-vim
https://github.com/lervag/vimtex/issues/368
即使在.vimrc中设定set conceallevel=0,重新打开tex文件都会自动调回conceallevel=2
解决方法:

let g:tex_conceal=''

示例:

参考:
https://www.latexstudio.net/archives/51613.html

" vimtex----------------{
    {
    {
" 设置格式缺省值
let g:tex_flavor='latex'
“ help ... 发现这里只有四个值可以设置,否则报错
let g:vimtex_view_method='general'
" quickfix不会在有错误时自动打开
let g:vimtex_quickfix_mode=0
" 隐藏非当前行的Latex代码
" set conceallevel=2
" let g:tex_conceal='abdmg'
" 开启ycm自动补全
if !exists('g:ycm_semantic_triggers')
  let g:ycm_semantic_triggers = {}
endif
au VimEnter * let g:ycm_semantic_triggers.tex=g:vimtex#re#youcompleteme
" 开启okular viewer 
let g:vimtex_view_general_viewer = 'okular'
let g:vimtex_view_general_options = '--unique file:@pdf\#src:@line@tex'
let g:vimtex_view_general_options_latexmk = '--unique'
" }}}

conceallevel和concealcursor选项总是被自动设置:

  verbose set conceallevel

查看最近在那里修改此项,发现indentLine修改了此项。
设置排除tex文件:

let g:indentLine_fileTypeExclude = ['tex']
" 这个颜色正好
let g:indentLine_color_term = 239
let g:indentLine_char = '┊'
" let g:indentLine_char_list = ['|', '¦', '┆', '┊']

添加snippet:
参考:https://github.com/gillescastel/latex-snippets/blob/master/tex.snippets

jupyter vim设置

参考:https://github.com/lambdalisue/jupyter-vim-binding

vim-markdown

由于tex配置复杂且编译缓慢,不适合作为数学笔记工具,改用markdown,配合数学公式snippet
下载nodejs等支持库:

sudo pacman -S nodejs
sudo pacman -S npm
sudo pacman -S xdg-utils
sudo pacman -S curl

下载预览服务器脚步插件:(注意一定要是@next版本,否则没有数学补全)

sudo npm -g install instant-markdown-d@next

下载vim插件:

" markdown语法高亮匹配及映射
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'
" markdown实时预览
Plugin 'suan/vim-instant-markdown', {'rtp': 'after'}

修改indentLine的Exclude名单防止修改concealcursor:注意名字是markdown不是md

let g:indentLine_fileTypeExclude = ['tex','markdown']

创建snippets文件也应该创建markdown.snippets而非md.snippets否则没反映

附录:阅读过程中提出的问题:
参考插件大全:https://blog.csdn.net/u010826976/article/details/38659541
注释键

用cmake管理compilation database:
先学一边cmake教程:https://cmake.org/cmake-tutorial/

c++代码规范空格

tab键要不要改?要:tab键不变,c-j c-k改为上下翻动
错误提示栏常显示:
视频网站:http://vimcasts.org/
goto :

诊断:

git:

以src为截断点提供.cc头文件

baskspace有4个空格一次退四格,先找插件

vim自动规范代码加空格,先找插件

vim撤销的太多了

系统时间还是有问题

vim括号高亮太恶心了

括号相关的操作

vim搜索,输入时无法自动高亮

g:ycm_collect_identifiers_from_tags_files的意思

g:ycm_seed_identifiers_with_syntax的意思

EasyMotion特性探索

fzf特性探索

能否让ycm左侧的错误提示栏一直显示,错误提示能不能是下划线

vim语句没颜色

EasyMotion 双leader改单leader,其他键换成ctrl开头

vimrc example研读

终端粘贴快捷键盘

研读vim help中文文档

rm功能太垃圾要改!!!

vim cmdline 按下tab没有补全表提示

ycm tab键,c-j c-k 同模式

python+正则 ultsnip进阶

在插入模式下也可以c-s

.cc文件按照源代码目录树截断

fzf example研读:https://github.com/junegunn/fzf/wiki/examples

参考以下配置:https://segmentfault.com/a/1190000002662054

好用vim插件参考:https://vimawesome.com/

你可能感兴趣的:(Vim,manjaro)