looking vim plugin like QT controlling '' "" {} [] <> ()? - vim-plugin

I am looking for a vim plugin is about controlling symbol ( '' "" {} [] <> () ) like QT-creator.
Insert mode when i press " , then "|" is available in the screen.
Insert mode when i press "" , then ""| is available in the screen.
Insert mode when i press ( , then (|) is availavle in the screen.
Insert mode when i press () , then ()| is availavle in the screen.
Something like that.
Anyone knows what i am talking about and know about that? Thanks .

Have a look at autopairs. It seems to do what you want.

Related

What improvements can I do to my .vimrc to improve my experience in NeoVim?

Here's my .vimrc
call plug#begin('~/.vim/plugged')
Plug 'dart-lang/dart-vim-plugin'
Plug 'natebosch/vim-lsc'
Plug 'natebosch/vim-lsc-dart'
Plug 'tpope/vim-sensible'
Plug 'vim-airline/vim-airline'
Plug 'w0rp/ale'
Plug 'pearofducks/ansible-vim', { 'do': './UltiSnips/generate.sh' }
Plug 'ncm2/ncm'
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-path'
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' }
Plug 'codota/tabnine-vim'
Plug 'Chiel92/vim-autoformat'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'jiangmiao/auto-pairs'
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\}
" Plug 'valloric/youcompleteme'
let g:lsc_server_commands = {'dart': 'dart_language_server'}
call plug#end()
let g:ale_fixers = {
\ 'javascript': ['eslint']
\}
let g:ale_sign_error = '❌'
let g:ale_sign_warning = '⚠️'
let g:lsc_enable_autocomplete = v:true
let g:lsc_auto_map = v:true
let g:ale_fix_on_save = 1
let g:ale_javascript_prettier_use_local_config = 1
let g:ale_javascript_eslint_options = '-c ~/.eslintrc'
let g:ale_lint_on_enter = 0
let g:ansible_unindent_after_newline = 1
autocmd BufEnter * call ncm2#enable_for_buffer()
set completeopt=noinsert,menuone,noselect
" set softtabstop=2
" set shiftwidth=2
" set expandtab
set expandtab
" show existing tab with 2 spaces width
set tabstop=2
set softtabstop=2
" when indenting with '>', use 2 spaces width
set shiftwidth=2
nnoremap <A-Down> :m .+1<CR>==
nnoremap <A-Up> :m .-2<CR>==
inoremap <A-Down> <Esc>:m .+1<CR>==gi
inoremap <A-Up> <Esc>:m .-2<CR>==gi
vnoremap <A-Down> :m '>+1<CR>gv=gv
vnoremap <A-Up> :m '<-2<CR>gv=gv
set statusline=%<%f\ %h%m%r%{kite#statusline()}%=%-14.(%l,%c%V%)\ %P
set laststatus=2
let g:python3_host_prog='/home/thebozzkg/anaconda3/bin/python3'
au BufWrite * :Autoformat
let g:airline#extensions#tabline#enabled = 1
let g:airline_detect_spell=1
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = '☰'
let g:airline_symbols.maxlinenr = ''
let g:airline_symbols.dirty='⚡'
nnoremap <ALT-Left> :tabprevious<CR>
nnoremap <ALT-Right> :tabnext<CR>
Some notes about me:
I don't use hjkl I use the arrow keys (pls don't insult me)
I write Javascript, Dart, Markdown, YAML, JSON, C, & C++ (so far) in neovim (I'm switching from VSCode)
Most of the stuff I have I literally copied from GitHub and some Vim wikis
I have Anaconda installed
I'm using Ubuntu Linux 20.04 (if that matters)
For some reason, I don't know which plugins are doing it but my autocompletion keeps messing up my files (editing YAML files and saving them are absolute torture, some indentation is lost with almost all files) and also crashing (TabNine)
Can someone help me with this mess?
Welcome to Vim!
I think most new vim users have been there. I certainly have! I wanted a
'vim as python IDE' and copied a whole bunch of stuff from every blog under the
sun into my vimrc almost immediately after installing vim.
After some time spent fighting with all the settings, plugins and remaps I
didn't understand, I decided to go through my vimrc, line by line and comment
out anything I didn't understand (nearly all of it).
Then I used this more minimal vim for a while and whenever I decided I had a
need for a certain feature, I checked the largely commented vimrc for anything
that looked related, and/or googled for that particular feature only. Often
you find that there is a built in method to do it with the core vim commands,
and if not, then there are a lot of solutions for the problem (and often, you
find that there is an even more powerful way that didn't occur to you - these
are good days).
But the key is to not try and coerce vim into a huge IDE overnight! Let it
happen gradually and things will make more sense, and you'll end up with a
vimrc that you understand and therefore be in a position to add to it and tweak
it.
The last thing I'll say is to recommend the following books:
'Learn VimScript the Hard Way' by Steve Losh
'Practical Vim' by Drew Neil, and his accompanying screencast series.
(Also there is The Primagean who does high quality youtube tutorials)
Having said all that, and acknowledging that an objective answer can't be given
for your question, here is a minimal vimrc which has a few plugins and settings
that do simple but very useful things (but do read up on them to understand how
they work!):
"==== PLUGINS =================================================================
set nocompatible " don't try to be compatible with Vi
filetype plugin indent on " use default plugins
call plug#begin('~/.vim/plugged')
" plugins I would put in a new vimrc
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'vim-scripts/ReplaceWithRegister'
Plug 'flazz/vim-colorschemes'
"==== CUSTOM CONFIGURATIONS ===================================================
"- general settings -----------------------------------------------------------
set encoding=utf-8
set linebreak " wrap long lines at char in 'breakat' (default " ^I!#*-+;:,./?")
set nowrap " don't wrap lines by default
set expandtab " expand tabs into spaces
set tabstop=4 " a tab is the same as 4 spaces
set softtabstop=4 " when I hit <tab> in insert mode, put 4 spaces
set shiftwidth=4 " when auto-indenting, use 4 spaces per tab
set autoindent " when creating a new line, copy indent from line above
set incsearch " show matches for patterns while they are being typed
set smartcase " with both on, searches with no capitals are case insensitive...
set ignorecase " ...while searches with capital characters are case sensitive.
set spell spelllang=en
set nospell " don't hightlight misspellings unles I say so
set lazyredraw " don't redraw screen during macros (let them complete faster)
set t_Co=256 " use full colours
syntax enable " highlight special words to aid readability
colorscheme zenburn
" THIS NEXT BIT I DEBATED INCLUDING - IT'S MY PERSONAL PREFERENCE AND BY
NO MEANS 'NECESSARY' AND COULD SAFELY BE EXCLUDED... BUT I JUST HATED THE
BLOCK CURSOR IN INSERT MODE SO MUCH...
"- cursor behaviour (make cursor blink for insert mode, block for normal mode)
augroup cursor_behaviour
autocmd!
" reset cursor on start:
autocmd VimEnter * silent !echo -ne "\e[2 q"
" cursor blinking bar on insert mode
let &t_SI = "\e[5 q"
" cursor steady block on command mode
let &t_EI = "\e[2 q"
" highlight current line when in insert mode
autocmd InsertEnter * set cursorline
" turn off current line hightlighting when leaving insert mode
autocmd InsertLeave * set nocursorline
augroup END
Good luck!

How to input a check mark into IDEA only by using keyboard instead copying from website? For example the check mark is ✓ or ✗

I get the ✓ and ✗ from website. I want to input them only by keyboard. How I deal with it?
You could just use Unicode hex value inside your println statement:
System.out.println(se.execute() == 1 +2 * (9 - 5) ? "\u2713" : "\u2717");
\u2713 is ✓
\u2717 is ✗
Also, It's possible to put such types of symbols by using keyboard shortcuts:
E.g. in Windows: Alt +2713 and Alt +2717

Unable to enter correct characters in IntelliJ

I want to start developing apps using IntelliJ IDE. I have downloaded and installed it with no problem.
Now, IntelliJ does the following when I enter on the keyboard:
; : button = $
ctrl + shift = ^
shift + "\' = #
, button = ?
. button = /
As a coder I will need a . (dot) and/or semicolon, in which IntelliJ does not respond correctly to what I am typing.

How do I stop SAPI.SpVoice reading "is." as "island"?

Can you configure the way SAPI.spVoice reads text?
In my situation I am reading the current clipboard using an AutoHotKey script.
The script makes a COM call to SAPI.spVoice passing the text from the clipboard.
;;;;;;;;;;;;;;;;;;;;TTS;;;;;;;;;;;;;;;;;;;;;;
#^!D:: ; Win + Ctrl + D + Alt
ClipSaved := ClipboardAll
clipboard = ; Start off empty to allow ClipWait to detect when the text has arrived.
Send ^c
ClipWait ; Wait for the clipboard to contain text.
ComObjCreate("SAPI.SpVoice").Speak(clipboard)
Clipboard := ClipSaved
ClipSaved = ; Free the memory
return
The problem is.. that SAPI reads some text incorrectly..
For Example:
"Yes it is. Ours is complex." reads "is." as island,
"Yes it is. This is complex." is read correctly.
You can experiment with this by doing the following:
If you are running windows 7.
Press the windows key and type "Change text to speech settings" and pick the option.
In this dialog enter "Yes it is. Ours is complex." in the "Use the following text to preview the voice:" field.
Press "Preview Voice"
Hear it read the "is." as island.
So... My question is...
Is it possible to change/configure the way "Microsoft Anna" reads text so it doesn't make these mistakes?
Is this a bug in the Anna voice only or all voices?
How can I make it read the text the way I want it read?
This is done by SAPI's text normalization code. Unfortunately, this is quite difficult to modify without building a custom voice, which is likely far more work than you probably want to implement.
"Every problem (except the problem of too many levels of indirection) can be solved with another level of indirection."
The SAPI.spVoice object can be passed text (as I was doing) or SSML.
By taking the text to be spoken, then converting it to SSML you gain control over how words are spoken. You have a chance to pre-process the text and replace miss-read words with the specific pronunciation you wish.
For example: "Yes it is. Ours is complex." becomes "Yes it <sub alias="is">is</sub>. Ours is complex."
sub and say_as seem to work. phoneme seem to be ignored.. but I may have something configured wrongly.
Note: If you want XML read aloud, XML escape the text before converting it to SSML, otherwise it will be assumed to be part of the SSML.
So.. in code:
;;;;;;;;;;;;;;;;;;;;TTS;;;;;;;;;;;;;;;;;;;;;;
#^D:: ; Win + Ctrl + D
ClipSaved := ClipboardAll
Clipboard = ; Start off empty to allow ClipWait to detect when the text has arrived.
Send ^c
ClipWait ; Wait for the clipboard to contain text.
FileDelete , c:\tmp\tmp_ahk_tts_clip.txt
FileAppend , %Clipboard% , c:\tmp\tmp_ahk_tts_clip.txt
RunWait, %comspec% /c ""F:\bin\tools\speakit.rb" c:\tmp\tmp_ahk_tts_clip.txt > c:\tmp\tmp_ahk_clip_tts_out.txt" ,,Hide
FileRead, Clipboard, c:\tmp\tmp_ahk_clip_tts_out.txt
ComObjCreate("SAPI.SpVoice").Speak(Clipboard)
Clipboard := ClipSaved
ClipSaved = ; Free the memory
return
and F:\bin\tools\speakit.rb is sometihng like this:
#!/usr/bin/env ruby
substitutions = [
[/[A-Z][A-Z][A-Z][A-Z]+((?=[^A-Za-z])|(?!.))/, lambda{|x|x.downcase}], #All caps becomes word
[/\.exe(?=[^a-z])/i, " executable "],
[/\.txt(?=[^a-z])/i, " text file "],
[/rebranded/, "re-branded"],
[/App(?=[\s\.])/, " application "],
['GUI' , " gooee "],
[/localhost/, "local host"],
[/(?<word>[A-Z][a-z]*)(?=[A-Z ,\.;:\t\/])/, "'\\k<word>' "], # CamelCaseWords should be split by spaces
['\\', '<sub alias="slash">\\</sub>'],
]
require 'cgi'
puts <<-eos
<?xml version="1.0"?>
<speak xmlns="http://www.w3.org/2001/10/synthesis" version="1.0" xml:lang="en-UK">
<voice xml:lang="en-UK">
#{substitutions.reduce(CGI::escapeHTML(ARGF.read)){|o, (r,s)| s.is_a?(Proc) ? o.gsub(r, &s) : o.gsub(r,s) }}
</voice>
</speak>
eos

Vim: Writing function skeleton

When writing new functions with Vim I always seem to have to do a bit of "manual" work.
x = Cursor position
If I start typing a function and insert a couple of curly braces and the end
function Apples() {x}
Then hit Enter, it obviously looks like this
function Apples() {
x}
Which results in me having to ESC,O in order to shift the closing curlybrace down.
While this may seem like a trivial matter, doing this over the last 5 months is getting bothersome, and I know there are plenty like me out there who knows there should be an elegant solution to this. I am open to plugin-suggestions.
You can use a simple mapping like this one (there are dozens of variants floating around SO and the web):
inoremap {} {<CR>}<C-o>O
You can also search www.vim.org for a dedicated plugin.
But I strongly recommend you to try a snippet-expansion plugin like Snipmate or UltiSnips. Both plugins follow the same model but they have slightly different snippet syntaxes and features. It works like that:
you type a trigger:
fun
you hit <Tab> and you get the following with function_name in select mode:
function [function_name]() {
}
you type your desired name:
function Apples|() {
}
you hit <Tab> to place the cursor between the parentheses:
function Apples(|) {
}
you hit <Tab> again to place the cursor on the line below with the correct indentation:
function Apples() {
|
}
With lh-bracket (in C or C++ mode), when you hit enter whilst in between two brackets, the newlines you are expecting are inserted.
The idea is to test for: getline(".")[col(".")-2:col(".")-1]=="{}" and execute/insert "\<cr>\<esc>O" when the condition is true, or "\<cr>" otherwise.
Within lh-bracket, I have the following into a C-ftplugin:
call lh#brackets#enrich_imap('<cr>',
\ {'condition': 'getline(".")[col(".")-2:col(".")-1]=="{}"',
\ 'action': 'Cpp_Add2NewLinesBetweenBrackets()'},
\ 1,
\ '\<cr\>'
\ )
function! Cpp_Add2NewLinesBetweenBrackets()
return "\<cr>\<esc>O"
endfunction
I guess (code not tested) it would (*) translate into:
" put it into ftplugin/{yourfiltetype, javascript?}.vim
inoremap <buffer> <silent> <expr> <cr> s:SmartCR()
function s:SmartCR()
return getline(".")[col(".")-2:col(".")-1]=="{}"
\ ? "\<cr>\<esc>O"
\ : "\<cr>"
endfunction
(*) Actually, lh#brackets#enrich_imap does a few other things (the mapping is compatible with LaTeXSuite's IMAP.vim presence ; the mapping can be toggled on/off along with all the other mappings from lh-brackets)