AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题

问题[vimrc](unix)

Martin Hope
Szilan
Asked: 2019-12-26 04:56:37 +0800 CST

通过 nix home-manager 定义的 vimrc 中的空字符串语法

  • 0

我想使用 home-manager 在带有 extraConfig 选项的 nix-expression 中声明我的 vim 配置。我正在尝试从 coc.nvim 运行示例 .vimrc 配置,其中一行显示:

设置状态行^=%{coc#status()}%{get(b:,'coc_current_function','')}

在最小的 home.nix 中,我将其设置为:

{ config, pkgs, ... }:

{
  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;

  home.packages = [ 
    pkgs.nodejs
  ];

programs.vim = { 
    enable = true;
    plugins = [
      pkgs.vimPlugins.coc-nvim
    ];
    extraConfig = ''
" Add status line support, for integration with other plugin, checkout `:h coc-status`
set statusline^=%{coc"status()}%{get(b:,'coc_current_function','')}
      '';
  };
}

不幸的是,空的 vim 字符串关闭了多行 nix 字符串并留下home-manager build switch:

error: syntax error, unexpected ')', expecting ';', at /home/demo/.config/nixpkgs/home.nix:18:66

我已经尝试在 get 函数中替换''with "",但 vim 不喜欢这样:

E540: Unclosed expression sequence: statusline^=%{coc
nix vimrc
  • 1 个回答
  • 180 Views
Martin Hope
tomcam
Asked: 2019-08-06 17:28:47 +0800 CST

使用 set paste 禁用 imap jk <Esc>

  • 1

我在 ~/.vimrc 中使用以下行来允许我按 jk 而不是 Esc。

:imap jk <Esc>

在我添加 :set paste 之前它工作正常:

" Pressing jk is same as pressing Esc
:imap jk <Esc>

" Enable paste from system clipboard
" Bug? This disables imap jk <Esc>  
set paste 

谁能告诉我为什么会这样?它至少发生在这些系统上:

主机:Amazon Linux AMI Vim 版本:7.4

主机:MacOS 10.14.5 Vim 版本 8.0.1283

vim vimrc
  • 1 个回答
  • 175 Views
Martin Hope
Roland Puntaier
Asked: 2019-06-26 02:13:10 +0800 CST

vim:命令映射到两个命令给出 E488

  • 1

我想要一个Build独立于使用的构建系统启动构建的命令。

command! -nargs=* Build :Makeshift<Bar>MakeshiftBuild <args>

给我

E488: Trailing characters

任何一个都可以映射并工作,但它们两个都会产生错误。-bar我在我的地图上试过。我无法更改 Makeshift 来使用它。

以下作品:

function! s:BuildFun(what2build)
    execute 'Makeshift'
    execute 'MakeshiftBuild '.a:what2build
endfunction
command! -nargs=* Build :call s:BuildFun(<q-args>)

有人可以澄清一下,为什么单线不起作用或如何使它起作用。只是为了获得洞察力。

vim vimrc
  • 1 个回答
  • 161 Views
Martin Hope
Jack Thomson
Asked: 2019-05-28 22:06:30 +0800 CST

vim find 声称有很多文件,但事实并非如此

  • 1

如果我输入ls我的目录,我会得到:

README.md lib       sdf.t     t.t       t1.t      t2.t      tt.t

我在 vim 中,如果我输入: :find *.t,我会得到:too many file names

这是怎么回事?

如果我打印我的 vim 路径变量,我会得到:

.,/usr/include,,,**
vim vimrc
  • 1 个回答
  • 141 Views
Martin Hope
Joshua Spence
Asked: 2019-01-21 23:07:07 +0800 CST

验证`~/.vimrc`

  • 4

我想验证我的~/.vimrc文件是否正确,基本上只需启动vim并立即运行quit. 我几乎可以做到这一点vim -c quit,除了我必须按回车键。例如,

> cat ~/.vimrc
echoerr 'test'

> vim -c quit
Error detected while processing /home/josh/.vimrc:
line    1:
test
Press ENTER or type command to continue

有没有办法在不按回车的情况下做到这一点?我想我可以运行echo | vim -c quit,但我希望有一个更优雅的解决方案。

vim vimrc
  • 1 个回答
  • 379 Views
Martin Hope
CraigFe
Asked: 2018-09-02 10:41:07 +0800 CST

Urxvt 中的 Neovim 配色方案无法正确渲染

  • 2

我正在尝试在 Neovim 中使用 256 色主题(这个:https ://github.com/ayu-theme/ayu-vim ),但无法让它在 Urxvt 上正确呈现,即使它似乎支持256色:

Urxvt 支持 256 色

这是我的相关部分.vimrc:

Plugin 'ayu-theme/ayu-vim'
...
syntax enable
set termguicolors
let ayucolor="light"
colorscheme ayu

配色方案在 XTerm 和 的 Neovim 中有效gvim,让我怀疑这是 Urxvt 的问题。我已经在修改和不修改Xresources.

不同环境下的配色方案

我在 Ubuntu 上安装了rxvt-unicode和rxvt-unicode-256color包。

colors vimrc
  • 1 个回答
  • 2774 Views
Martin Hope
divramod
Asked: 2018-08-15 21:03:20 +0800 CST

vim:我如何从 autocmd 进行映射

  • 0

在我的 .vimrc 中,我有一个 autocmd 可以清理我的文件,但是我怎样才能从命令中映射出来呢?

autocmd BufWritePre *.test1 silent! :%s/\s\+$//e | silent! :%s/\(\n\n\)\n\+/\1/ | silent! :%s#\($\n\s*\)\+\%$## | :%s/;$
nnoremap ;; silent! :%s/\s\+$//e | silent! :%s/\(\n\n\)\n\+/\1/ | silent! :%s#\($\n\s*\)\+\%$## | :%s/;$<CR>

映射失败说

Error detected while processing ~/.vimrc:
line  966:
E486: Pattern not found: ;$<CR>
vim vimrc
  • 1 个回答
  • 262 Views
Martin Hope
Schiem
Asked: 2018-05-19 10:49:31 +0800 CST

在 Vim 8.1 中打开垂直终端

  • 38

Vim 8.1 添加了该:terminal命令,它打开一个新的 bash 终端作为拆分。但是,它似乎总是水平拆分,我更喜欢垂直拆分。有没有办法在不使用的情况下将终端打开为垂直拆分:

:vsp
:terminal
<c-w>j
:q

或者,有没有办法可以将它作为命令添加到我的.vimrc中,如下所示:

command Vterm :vsp | :terminal | <c-w>j | :q

上面的命令在尝试执行时阻塞<c-w>j,打开一个新的 vim 拆分,其中包含以下内容:

执行作业失败:没有这样的文件或目录

只是有:

command Vterm :vsp | :terminal

工作正常,但留下原来的分裂。

vim vimrc
  • 3 个回答
  • 29591 Views
Martin Hope
Danyang Su
Asked: 2018-02-20 12:40:27 +0800 CST

如何处理损坏的 vim 显示?

  • 1

在 vim 编辑器中处理残留文本的最佳方法是什么?我使用 Xquartz 连接到远程终端,并使用 vim 编辑我的代码。当我按回车键时,当前行中仍显示文本,即使它们实际上已移至下一行。它变得难以阅读,我不得不时不时地重新启动 vim。有没有解决这个问题的方法?

例如:如果我添加set cursorlinemy.vimrc然后移动光标,它将显示如下,并且:redraw!不会解决问题: 我的 xterm 截图

vim vimrc
  • 1 个回答
  • 2084 Views
Martin Hope
ka3ak
Asked: 2018-02-08 23:17:59 +0800 CST

:set nohlsearch 不起作用

  • 0

当我用 VIM 打开一个现有会话时,set nohlsearch最后的设置~/.vimrc无效。它只有在我手动运行时才有效。我还注意到,如果我打开一个不在会话中的文件,则设置~/.vimrc会生效。如果我切换到会话中的缓冲区并运行,该设置也有效:source $MYVIMRC。

我重新创建了会话,:mksession!但没有帮助。我正在使用 VIM 7.4。

以下是~/.vimrc:

" For pre-processing books
command! Book %s/\v([Tt])heyre/\1hey're/gec | %s/\v([Ww])ont/\1on't/gec | %s/\v([Yy])oud/\1ou'd/gec | %s/\v([Nn])eednt/\1eedn't/gec | %s/\v([Ss])houldnt/\1houldn't/gec | %s/\v([Hh])asnt/\1asn't/gec | %s/\v([Cc])ant/\1an't/gec | %s/\v([Tt])hats/\1hat's/gec | %s/\v([Yy])oull/\1ou'll/gec | %s/\v([Yy])oure/\1ou're/gec | %s/\v([Yy])ouve/\1ou've/gec | %s/\v([Ii])ts/\1t's/gec | %s/\v([Dd])ont/\1on't/gec | %s/\v([Aa])rent/\1ren't/gec | %s/\v([Dd])oesnt/\1oesn't/gec | %s/\v([Dd])idnt/\1idn't/gec | %s/\v([Ii])snt/\1sn't/gec | %s/\v([Hh])eres/\1ere's/gec | %s/IDEs\C/IDE's/gec | %s/\v([Nn])onfinal/\1on-final/gec | /\v\c^(chapter|item)|\[.+\]

" Write buffer and delete it afterwards
command! Wd write|bdelete
" Format current buffer that should be an XML document
"command! FormatXml %!xmllint --format -
" Format current selection that should be an XML document
command! -range FormatXml <line1>,<line2>!xmllint --format -

" Copy current buffer contents to the system clipboard (insertion with CTRL+v). Range can be used.
command! -range CopyToClipboard <line1>,<line2>w !xclip -selection clipboard
" Copy current buffer contents to the primary clipboard (insertion with mouse wheel click or with CTRL+SHIFT+INSERT). Range can be used.
command! -range CopyToPrimary <line1>,<line2>w !xclip

" Copy visual selection to the clipboard and pass it to 'eval'
command! -range Eval <line1>,<line2>w !xclip && eval "$(xclip -o)"

" Comment/uncomment shell script
command! -range CommentShellScript <line1>,<line2>s/^/#/g
command! -range UncommentShellScript <line1>,<line2>s/\v^\s*#(.*)/\1/g

" Creates a buffer containing the output of ':browse oldfiles' command at the top
" Move cursor to the path and press ENTER
" TODO: Doesn't open files with spaces in their paths
command! Browse new +setl\ buftype=nofile | 0put =v:oldfiles | nnoremap <buffer> <CR> :e <C-r>=getline('.')<CR><CR>

" If the current line contains a file path, the file will be opened in default program
command! OpenInDefaultProgram exec(":!xdg-open '".getline(".")."'")

" If the current line contains a URL, the URL will be opened in firefox
command! OpenUrlInFirefox exec(":!firefox '".getline(".")."'")

" Remove duplicate method calls. You just want to see which methods have been called and not interested in their call order
command! BtraceUniqMethodCalls %s/\v\(.*\)//g | %sort u | !%uniq 
" Remove duplicate classes. You just want to see which classes have been used during execution
command! BtraceUniqClasses %s/\v\.[^\.]{-}\(.*\)//ge | execute 'g/\v\$[0-9]+$/de' | %sort u | %!uniq
" Remove duplicate adjacent method calls. Methods call order is kept.
"command! BtraceRemoveAdjacentDuplicateMethods %s/\v\(.*\)//ge | %!uniq (no
"line numbers)
command! BtraceRemoveAdjacentDuplicateMethods %!awk 'BEGIN {method=""} match($0,/.*\(/) { if (length(method)) { if (index($0,method) == 0) { print $0 } } else { print $0 } method =substr($0, RSTART, RLENGTH-1) }'

set ignorecase
set smartcase
set hidden
set tabstop=2 "2 spaces will be inserted when pressing TAB in INSERT mode
"set softtabstop=0 noexpandtab
set shiftwidth=2 "2 spaces will be inserted when indenting
"set wildmode=longest,list
set history=200

"highlight normal ctermfg=white ctermbg=yellow

set nocompatible
filetype plugin on
filetype indent on

" 'matchit' plugin
"set nocompatible
"filetype plugin on
runtime macros/matchit.vim

" Disable arrow keys in NORMAL mode
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>

:map <F8> <C-E>:sleep 3500m<CR>j<F8>

function! GotoJump()
  jumps
  let j = input("Please select your jump: ")
  if j != ''
    let pattern = '\v\c^\+'
    if j =~ pattern
      let j = substitute(j, pattern, '', 'g')
      execute "normal " . j . "\<c-i>"
    else
      execute "normal " . j . "\<c-o>"
    endif
  endif
endfunction

"if $TERM_PROGRAM =~ "iTerm" works also for KDE "Konsole"
"    let &t_SI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in insert mode
"    let &t_EI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in normal mode
 "   let &t_SI = "\<Esc>]50;CursorShape=0\x7" " Block in insert mode
  "  let &t_EI = "\<Esc>]50;CursorShape=0\x7" " Block in normal mode
"endif

set nohlsearch
vim vimrc
  • 1 个回答
  • 312 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve