Destruí meu Vim

Olá pessoal, tudo bem?

Mês passado eu tive ajuda da comunidade a respeito do Node.js. Segui o tutorial de um de nossos colegas e meu Vim se tornou um super Vim! Ele ficou com um monte de plugins e tudo funcionava muito bem. Na verdade ele acabou funcionando e com um visual que eu nem imaginava que ele poderia ficar…

Porém acabei fazendo um pequeno erro… Eu não conseguia quebrar a linha de texto quando chegava ao fim da janela, ele simplesmente continuava escrevendo.

Eu entrei no .vimrc e coloquei set wrap. Apaguei o que havia lá de set nowrap. O problema persistia, o texto “atravessava” o tamanho da janela.

Fui novamente em .vimrc e mudei as duas primeiras linhas que estavam em no e off.
Agora meu Vim ficou todo emparalhado, não funciona, teclo uma coisa e sai outra. O aplicativo não salva os arquivos e agora mesmo tentei entrar no .vimrc para explicar com maiores detalhes mas minha permissão está negada :sweat: :sob:.

A cupla foi minha, o programa estava incrível só queria quebrar as linhas…

Por favor, alguém sabe se tem algum jeito de resolver? Pode ser apagando todo o Vim. Eu reinstalo, mas tenho receio de deixar alguma coisa sobrando do problema… Como faço para excluir o Vim, Vimrc e qualquer coisa mais relacionada a eles? (se não precisar apagar tudo, melhor).

Você consegue fazer um cat ou less no arquivo para poder ver o conteúdo? Algo como cat .vimrc ou less .vimrc.

Faça o seguinte. Faça um backup do seu .vimrc com cp .vimrc .vimrc.bak, depois exclua o arquivo .vimrc, execute o vim novamente e veja se o problema persiste. Se o problema não persistir, de certo o .vimrc está com algum problema.

5 curtidas

Olá @Ana_Paula tudo bem contigo?

Além da dica que o @Yofiel deu, você pode enviar seu vimrc para gente dar uma olhada, talvez consigamos encontrar o erro e dessa forma o aprendizado é maior.

O arquivo bloqueado para edição pode ocorrer quando o Vim é encerrado “à força” o que gera um arquivo “.swp” no mesmo diretório, apague/renomeie este arquivo e provavelmente tudo ficará bem.

:vulcan_salute:

3 curtidas

Olá @Yofiel , tudo bem?

Aeee, consegui com o comando “cat”. Este é o conteúdo do meu .vimrc. As duas primeiras linhas foram as que alterei colocando on na primeira e tirando o no da segunda.

Segue: [karenina@Arch ~]$ cat .vimrc
set compatible
filetype on

call plug#begin()
Plug ‘airblade/vim-gitgutter’ " Show git diff of lines edited
Plug ‘tpope/vim-fugitive’ " :Gblame
Plug ‘tpope/vim-obsession’
Plug ‘tpope/vim-commentary’
Plug ‘preservim/nerdtree’
Plug ‘sheerun/vim-polyglot’

"Search
Plug ‘junegunn/fzf’
Plug ‘junegunn/fzf.vim’

Plug ‘rstacruz/vim-hyperstyle’
Plug ‘jiangmiao/auto-pairs’
Plug ‘pearofducks/ansible-vim’
Plug ‘neoclide/coc.nvim’, {‘branch’: ‘release’}
Plug ‘vim-scripts/SyntaxComplete’,
Plug ‘HerringtonDarkholme/yats.vim’ " TypeScript syntax
Plug ‘othree/yajs.vim’, {‘for’: ‘javascript’}
Plug ‘othree/es.next.syntax.vim’, {‘for’: ‘javascript’}
Plug ‘maxmellon/vim-jsx-pretty’ " JS and JSX syntax
Plug ‘alvan/vim-closetag’

" Plug ‘leafgarland/typescript-vim’ " TypeScript syntax
" Plug ‘styled-components/vim-styled-components’
" Plug ‘editorconfig/editorconfig-vim’

" Vim Theme
" Plug ‘sainnhe/sonokai’
" Plug ‘mhartington/oceanic-next’
Plug ‘sonph/onehalf’, { ‘rtp’: ‘vim’ }
Plug ‘ryanoasis/vim-devicons’
Plug ‘vim-airline/vim-airline’ " Vim powerline
Plug ‘majutsushi/tagbar’

" All of your Plugins must be added before the following line
call plug#end() " required
filetype plugin indent on " required

" Leader key is SPACE, I find it the best
let mapleader = " "

" Look and Feel settings
syntax enable
set background=dark
set wildmenu " when opening a file with e.g. :e ~/.vim there is a graphical menu of all the matches
set ttyfast
set lazyredraw
set updatetime=300

" Display tabs and trailing spaces visually
set list listchars=tab:\ \ ,trail:·

set laststatus=2 " Always show the status line
set clipboard=unnamedplus " Allow copy and paste from system clipboard
set backspace=indent,eol,start " Delete characters outside of insert area
set wrap
set linebreak "Wrap lines at convenient points

" Enable line highlight
set cursorline
hi cursorline cterm=none term=none
autocmd WinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
highlight CursorLine guibg=#303000 ctermbg=234
highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=235 gui=NONE guifg=NONE guibg=NONE

" Indentation
set autoindent
set cindent
set smartindent

" Disable all bells and whistles
set noerrorbells visualbell t_vb=

" Tab Options
set shiftwidth=2
set tabstop=2
set softtabstop=2 " Number of spaces a tab counts when editing
set expandtab

" Terminal Settings
" set termwinsize=12x0 " Set terminal size
set splitbelow " Always split below
set mouse=a " Enable mouse drag on window splits

" autocmd BufNewFile,BufRead *.yaml.hbs set syntax=ansible

" Buffer Highlight
syntax sync fromstart
autocmd BufEnter *.{js,jsx,ts,tsx} :syntax sync fromstart
autocmd BufLeave *.{js,jsx,ts,tsx} :syntax sync clear

" Delete empty space from the end of lines on every save
autocmd BufWritePre * :%s/\s+$//e

" Set default encoding to utf-8
set encoding=utf-8
set termencoding=utf-8

" Disable backups and swap files
set nobackup
set nowritebackup
set noswapfile

set ignorecase " Ignore case when searching
set smartcase " When searching try to be smart about cases
set nohlsearch " Don’t highlight search term
set incsearch " Jumping search

" Download font JetBrainsMono with Nerd Font Patch
" https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/JetBrainsMono/Medium/complete
set guifont=“JetBrainsMono Nerd Font Mono 14”

" Numbers
set number
set numberwidth=4
set ruler

if exists(‘+termguicolors’)
let &t_8f = “<Esc>[38;2;%lu;%lu;%lum”
let &t_8b = “<Esc>[48;2;%lu;%lu;%lum”
set termguicolors
endif

" if has(‘termguicolors’)
" set termguicolors
" endif

" get rid of [ ] around icons in NerdTree
" NERDTree: square brackets around icon on sourcing vimrc · Issue #154 · ryanoasis/vim-devicons · GitHub
syntax enable
if exists(“g:loaded_webdevicons”)
call webdevicons#refresh()
endif

" ColorScheme
syntax on
set t_Co=256
set cursorline
colorscheme onehalfdark
let g:airline_theme=‘onehalfdark’
" lightline
let g:lightline = { ‘colorscheme’: ‘onehalfdark’ }

" colorscheme OceanicNext
" hi Normal guibg=NONE ctermbg=NONE
" hi LineNr guibg=NONE ctermbg=NONE
" hi SignColumn guibg=NONE ctermbg=NONE
" hi EndOfBuffer guibg=NONE ctermbg=NONE

" colorscheme sonokai
" let g:sonokai_style = ‘default’
" let g:sonokai_enable_italic_font = 1
" let g:sonokai_transparent_background = 1
" let g:enable_bold_font = 1

" Configure the Tabline
let g:airline_extensions = [‘tabline’, ‘tagbar’]
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = ‘unique_tail’
let g:airline#extensions#tabline#show_buffers = 1 " enable/disable displaying buffers with a single tab
let g:airline#extensions#tabline#show_splits = 1 “enable/disable displaying open splits per tab (only when tabs are opened). >
let g:airline#extensions#tabline#switch_buffers_and_tabs = 1
let g:airline#extensions#tabline#tab_nr_type = 1 " tab number
let g:airline#extensions#tagbar#enabled = 1
let g:airline_detect_modified=1
let g:airline#extensions#tmuxline#enabled = 0
let g:airline_section_b = '%{strftime(”%c")}’
let g:airline_section_z = airline#section#create([‘%l/%c’])

A segunda parte:

" +++ Shortcuts +++
" Open Buffer
nnoremap l :buffers
" Vertically split screen
nnoremap / :vs
" Split screen
nnoremap - :split
" Delete Current Buffer
nnoremap ’ :bd

" Buffers Navigation
map , :bp
map . :bn

" force reload current file
map r :e!

" Alternate between windows
map e w

“” Faster saving and exiting
nnoremap w :w!
nnoremap q :q!
nnoremap x :x

if has(‘nvim’)
" Source Vim configuration
nnoremap 1 :w! | :source ~/.config/nvim/init.vim

: " Open Vim configuration file for editing
nnoremap 2 :e ~/.config/nvim/init.vim

" Source Vim configuration file and install plugins
nnoremap 3 :source ~/.config/nvim/init.vim | :PlugInstall
else
" Source Vim configuration
nnoremap 1 :w! | :source ~/.vimrc

" Open Vim configuration file for editing
nnoremap 2 :e ~/.vimrc

" Source Vim configuration file and install plugins
nnoremap 3 :source ~/.vimrc | :PlugInstall

endif

" NERDTree Config
nnoremap F :NERDTreeFocus
nnoremap :NERDTree
nnoremap :NERDTreeToggle
nnoremap :NERDTreeFind

" Show hidden files on NERDTree
let NERDTreeShowHidden=1

" Start NERDTree when Vim starts with a directory argument.
" autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists(‘s:std_in’) |
\ execute ‘NERDTree’ argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif

" Exit Vim if NERDTree is the only window left.
" autocmd BufEnter * if tabpagenr(’$’) == 1 && winnr(’$’) == 1 && exists(‘b:NERDTree’) && b:NERDTree.isTabTree() |
" \ quit | endif

" AutoRefresh when NERDTreeFocus
autocmd BufEnter NERD_tree_* | execute ‘normal R’

" CoC extensions
let g:coc_global_extensions = [‘coc-tsserver’, ‘coc-json’]

" Add CoC Prettier if prettier is installed
if isdirectory(’./node_modules’) && isdirectory(’./node_modules/prettier’)
let g:coc_global_extensions += [‘coc-prettier’]
endif

" Add CoC ESLint if ESLint is installed
if isdirectory(’./node_modules’) && isdirectory(’./node_modules/eslint’)
let g:coc_global_extensions += [‘coc-eslint’]
endif

" Remap keys for applying codeAction to the current buffer.
nmap da (coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap qf (coc-fix-current)

" coc.vim config
set hidden
set cmdheight=2
set updatetime=300
set shortmess+=c
set signcolumn=yes
nmap gd (coc-definition)
nmap gy (coc-type-definition)
nmap gi (coc-implementation)
nmap gr (coc-references)

" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync(‘highlight’)

" Symbol renaming.
nmap rn (coc-rename)

" Use K to show documentation in preview window
nnoremap K :call show_documentation()

function! s:show_documentation()
if (index([‘vim’,‘help’], &filetype) >= 0)
execute ‘h ‘.expand(’’)
else
call CocAction(‘doHover’)
endif
endfunction

" end coc.vim config
let g:fugitive_pty = 0

" filenames like .xml, .html, .xhtml, …
" These are the file extensions where this plugin is enabled.
"
let g:closetag_filenames = '
.html,
.xhtml,
.phtml,*.js’

" filenames like .xml, .xhtml, …
" This will make the list of non-closing tags self-closing in the specified files.
"
let g:closetag_xhtml_filenames = '
.xhtml,
.jsx’

" filetypes like xml, html, xhtml, …
" These are the file types where this plugin is enabled.
"
let g:closetag_filetypes = ‘html,xhtml,phtml’

" filetypes like xml, xhtml, …
" This will make the list of non-closing tags self-closing in the specified files.
"
let g:closetag_xhtml_filetypes = ‘xhtml,jsx’

" integer value [0|1]
" This will make the list of non-closing tags case-sensitive (e.g. <Link> will be closed while <link> won’t.)
"
let g:closetag_emptyTags_caseSensitive = 1

" dict
" Disables auto-close if not in a “valid” region (based on filetype)
"
let g:closetag_regions = {
\ ‘typescript.tsx’: ‘jsxRegion,tsxRegion’,
\ ‘javascript.jsx’: ‘jsxRegion’,
\ ‘javascript.js’: ‘jsxRegion’,
\ ‘typescriptreact’: ‘jsxRegion,tsxRegion’,
\ ‘javascriptreact’: ‘jsxRegion’,
\ }

" Shortcut for closing tags, default is ‘>’
"
let g:closetag_shortcut = ‘>’

" Add > at current position without closing the current tag, default is ‘’
"
let g:closetag_close_shortcut = ‘>’
[karenina@Arch ~]$

Tentei e continuo com acesso bloqueado:

karenina@Arch ~]$ cp .vimrc .vimrc.back
[karenina@Arch ~]$ ~/.vimrc
bash: /home/karenina/.vimrc: Permissão negada
[karenina@Arch ~]$

Olá @eddiecsilva !

Olha, não localizei…:
[karenina@Arch ~]$ ~/.swp
bash: /home/karenina/.swp: Arquivo ou diretório inexistente
[karenina@Arch ~]$

Meninos Funcionou!!! Meu Super Vim voltou a vidaaa! Muito muito obrigada mesmo!

O “problema” agora é que usei todos os métodos que vcs recomendaram, não sei qual deles solucionou o problema para compartilhar aqui rsrsrs.

Além disso, entei em .vimrc sem ser pelo terminal, mas pela interface gráfica. Lá fui fazendo os comandos, eles funcionaram, mas estavam muito lentos. Por exemplo, ao digitar uma letra ou tentando apagar alguma das minhas alterações, o programa demorava a restponder, mas agora foi! Muito obrigada!

Dúvida: Agora tenho um arquivo .vimrc.back, tenho que manter ele ou posso apagar?

1 curtida

Um dica é sempre fazer backup do arquivo sempre que for mecher nele, caso ele quebre como nesse caso você tem o antigo e é só substituir

5 curtidas

Olá @Italo_Castro . Verdade, deveria ter pensado nisso antes. Obrigada!

1 curtida

Este tópico foi fechado automaticamente 3 dias depois da última resposta. Novas respostas não são mais permitidas.