My terminal's indentation is not working properly - vim

I am mac user. When I'm using Vim in the termianl autoindent does not work at all.
Indentation only works when I tab in manually, through next line.
I already apply autoindent, cindent like that. Here is my .vimrc code. I really need your help.
1 " 환경설정
2 syntax on
3
4 set nu
5 set hi=100
6 set ru
7 set mps+=<:>
8 set backup
9 syntax enable
10 colorscheme desert
11 set history=50
12 set visualbell
13 set noerrorbells
14 set loadplugins
15
16 set encoding=utf-8
17 set fileencodings=utf-8,cp949,default,latinl
18 set termencoding=utf-8
19 set printencoding=utf-8
20 set printmbcharset=ISO10646
21
22 " Editing
23 set paste
24 set tabstop=4
25 set softtabstop=4
26 set shiftwidth=4
27 set showmatch
28 set autowrite
29 set autoindent
30 set cursorline
31 set showcmd "show commandline
32 set title "show title
33 set statusline=\ %<%l:%v\ [%P]%=%a\ %h%m%r\ %F\ " 다중 문서 작업을 >>
위한 Status 줄
34 set km=startsel,stopsel "shift키로 선택 영역 만들기 허용
35 " 영역 상태에서 ctrl+f, b 로 이동하면 영역 해제
36
37 set smartindent
38 set expandtab
39 set cindent
40 set autoindent
41 set textwidth=80 " if it is over 80 char
42 set wrap " then it warped next line
43 set nobackup
44 set shiftwidth=4 "autoindent at 4 line
45 set ignorecase " no large-small character difference when it is searched
46 set laststatus=2
47
48 " window
49 set ruler "show cursor position
50
51 " macro
52 map <F2> :tabnew<CR>
53 map <F4> :w<CR>
54
55 " c 파일의 경우 Makefile이 없으면 gcc를 불러줌
56 au BufRead,BufNewFile *.c
57 \ if !filereadable("Makefile") && !filereadable("makefile") |
58 \ set makeprg=gcc\ %\ -o\ %< |
59 \ endif
60
61 " cpp 파일의 경우 Makefile 이 없으면 g++를 불러줌
62 au BufRead,BufNewFile *.cpp
63 \ if !filereadable("Makefile") && !filereadable("makefile") |
64 \ set makeprg=g++\ %\ -o\ %< |
65 \ endif
66
67 " java 파일의 경우 Makefile 이 없으면 javac를 불러줌
68 au BufRead,BufNewFile *.java
69 \ if !filereadable("Makefile") && !filereadable("makefile") |
70 \ set makeprg=javac\ % |
71 \ endif
72
73 " 지난번 편집했던 곳으로 Jump
74 au BufReadPost *
75 \ if line("'\"") > 0 && line("'\"") <= line("$") |
76 \ exe "normal g`\"" |
77 \ endif

Remove set paste. Paste mode will effectively disable indentation.

Related

I can't copy from neovim to android clipboard

every time I try to make a "yy" or a "dd" or a ":%y" to copy everything from neovim de termux to for example send my code by whatsapp I can't, I can only paste the last thing I copy by long pressing select the text and press copy, and you know that doing it in neovim or vim even the line numbers are copied, that's why I'm trying to do so that when copying I can paste it very quickly in another place on the slide
Example of the only way I can copy from there, and also there my init.vim or vimrc file:
"set directory
1 set runtimepath^=~/.vim runtimepath+=~/.vim/after
2 let &packpath = &runtimepath
3
4 "files
5 so ~\.vim/plugins.vim
6 so ~\.vim/plugin-config.vim
7 so ~\.vim/maps.vim
8
9 set list
10
11 syntax enable
12
13 "show line number and relative number
14 set nu-
15 set rnu
16 set numberwidth=1 "better show the numbers
17
18 "copy and paste with the mouse
19 set mouse=a
20
21 "enable copy and paste 'yy, p'
22 set clipboard=unnamed
23 "set clipboard+=unnamedplus
24
25 "shows the pressed
26 set showcmd
27
28 "Show current column
29 set ruler
30
31 "perform indent
32 set smartindent
33
34 "does not create external files
35 set noswapfile
36 set nobackup
37
38 "Seaching
39 "moves to result as you type
40 set incsearch
41 "distinguish between upper and lower case when searching
42 set smartcase
43 "Highlight matches
44 set hlsearch-
45 "Unless they contain at least one capital letter
46 set ignorecase-
47
48
49 "tab of 4 spaces
50 set noexpandtab
51 set tabstop=4 shiftwidth=4
52
53 "Scheme
54 colorscheme gruvbox
55 let g:gruvbox_contrast_dark = "hard"
56
57 "highlight Normal ctermbg=NONE
58 set laststatus=2
59 set noshowmode
60
61 "Fonts
62 set guifont=Hurmit_Nerd_Font_Mono:h12
63
64 "When a file is edited its indent file is loaded
65 filetype plugin indent on
I explain it in more detail, I can paste normally I do not need to use that line that tells me to use ctrl + v, when I press esc then p, I can perform a good and normal paste, however I cannot copy and paste anywhere else instead, in another application, etc.

How do I define x and y rows/colums from a csv?

I've got a file like this:
Date first second third
01-08 30 22 161
01-10 23 20 104
01-12 50 16 79
01-14 67 21 99
02-08 37 33 155
02-10 48 44 66
02-12 89 12 91
How do I use the date column as x-axis and the dates as x-ticks and the values of the columns of first, second and third as bars. Each of the three value of one date should be a group of 3 bars with one x-tick -> the date:
| | |
| | |
40 - | |
| | | |
20 - ||| |||
|___|||_______|||_____etc.
01-08 01-10
Thanks for any help!
# Histogram plot style using thin solid fill boxes
set style histogram cluster gap 3
set style data histogram
set style fill solid
set boxwidth 0.5
#Use column headers for title
set key autotitle columnhead
plot 'file.dat' using 2:xticlabel(1), 'file.dat' using 3, 'file.dat' using 4

How to delimit file with "\t\n" on a Mac

I have a document whose lines are separated by "\t\n". Records are separated either by "\t", OR by "\n".
Normally, this should be a straigtforward awk query:
BEGIN {
RS='\t\n';
}
{
print;
print "Next entry:";
}
However, on a Mac, regular expressions do not seem to be supported (maybe I'm not doing something right?) So I tried, RS="\t\n"; however, this is interpreted as RS='\t | \n'. Similar problems running awk from the command line:
awk 1 RS='\t\n' ORS='abc' input > output
replaces the \t's, but leaves the \n's be.
Next try: using tr. This obviously fails for sequence of more than one character-- since \t and \n are both used individually in the rows.
Next:
sed -e '/\t\n/s//NextEntry:/g' input > output
However, doesn't work. Entering any ASCII character sequence instead of \t\n works.
Read the manual. It says that \t is not supported in sed strings. Fair enough
sed -e '/\x9\xa/s//abc/' input > output
Still doesn't work. Idea: use tr to replace \t and \n by characters unused in the input file, use sed to change them to what I want, and then tr to change the remaining characters back to what they should be.
tr: Illegal byte sequence
Turns out, that f6 character makes tr just totally fail.
Went through the suggestions in Sed not recognizing \t instead it is treating it as 't' why? . That might work for replacing output strings (except the "Pasting tab into command prompt via CTRL+V" suggestion-- the shell just rejected that paste.), but did not seem to help in my case.
Maybe it's because it's a Mac? Maybe it's because that's the text I'm looking for, not replacing with? Maybe it's the combination with \n?
Any other suggestions?
UPDATE:
I found thread How can I replace a newline (\n) using sed? . Apparently, I am unable even to replace a \n by the string "abc" using the suggestions in that thread.
EDIT: Hex head of source file:
5a 20 4e 4f 09 0a 41 53 20 4f 46 20 30 31 2d 30
34 2d 30 35 20 45 4d 50 4c 4f 59 45 45 0a 47 52
4f 55 50 09 48 49 52 45 20 44 41 54 45 09 53 41
4c 41 52 59 09 4a 4f 42 20 54 49 54 4c 45 09 0a
4a 4f 42 20 4c 45 56 45 4c 0a 53 45 52 49 45 53
09 41 50 50 54 20 54 59 50 45 09 0a 50 41 59 20
53 54 41 54 55 53 0a f6
Unfortunately, BSD awk, as also used on macOS, doesn't support multi-character record separators (RS) altogether (in line with POSIX) - only a single, literal character is supported.
BSD sed, as also used on macOS, supports only \n in regexes - any other escapes, including hex ones (e.g., \x09) are not supported.
See this answer of mine for a comprehensive comparison of GNU and BSD sed.
Assuming that your sed command works in principle, you can use an ANSI C-quoted string
($'\t') to splice a literal tab char. into your sed script (assumes bash (the macOS default shell), ksh, or zsh),:
sed -e ':a' -e '$!{N;ba' -e '}' -e '/'$'\t''\n/s//NextEntry:/g'
Note that, in order to replace newlines, you must instruct sed to read the entire file into memory first, which is what -e ':a' -e '$!{N;ba' -e '}' does (the BSD Sed-compatible form of the common GNU sed idiom :a;$!{N;ba}).

Vim slow down in python mode after I type "=" (equal) or " "(while space).

It seems to happen after I installed YCM. I also have Python-mode plugin installed because I like the lint and "run inside vim" feature, but I turned off "rope". My YCM settings are like below.
31 " Use gcc syntastic checker
30 let g:ycm_show_diagnostics_ui = 0
29
28 " Skip checking of ycm config file at vim startup
27 let g:ycm_confirm_extra_conf=0
26
25 " Includes tags in completion
24 let g:ycm_collect_identifiers_from_tags_files=1
23
22 " Include text in comments and strings
21 let g:ycm_collect_identifiers_from_comments_and_strings = 0
20
19 " Start completion from second char
18 let g:ycm_min_num_of_chars_for_completion=2
17
16 " Disable chache, rebuild every time
15 let g:ycm_cache_omnifunc=1
14
13 " Enable syntax based completion
12 let g:ycm_seed_identifiers_with_syntax=1
11
10 " Enable completion while in comments
9 let g:ycm_complete_in_comments = 1
8
7 " Enable completion while in strings
6 let g:ycm_complete_in_strings = 1
I tried to profile vim, but I don't get a clue from the result. Below is my profiling report.
0 FUNCTIONS SORTED ON SELF TIME
1 count total (s) self (s) function
2 60 0.883352 0.782989 <SNR>93_GetCompletions()
3 2967 0.905869 0.579009 pymode#folding#expr()
4 1997 0.275032 <SNR>110_BlockStart()
5 302 0.168611 <SNR>93_Pyeval()
6 120 0.968933 0.066387 youcompleteme#Complete()
7 1997 0.051828 <SNR>110_BlockEnd()
8 76 0.030649 0.028957 <SNR>97_GetNearbyTag()
9 154 0.026513 <SNR>69_Highlight_Matching_Pair()
10 61 0.025747 <SNR>93_InsideCommentOrString()
11 61 0.057955 0.016587 <SNR>93_IdentifierFinishedOperations()
12 6 0.013762 0.013707 <SNR>93_OnFileReadyToParse()
13 60 0.012566 <SNR>93_OnCompleteDone()
14 4 0.011961 <SNR>143_SearchParensPair()
15 74 0.040687 0.010170 Powerline#Functions#fugitive#GetBranch()
16 76 0.114571 0.009806 <SNR>93_OnCursorMovedInsertMode()
17 2 0.006829 0.006792 SyntasticRefreshCursor()
18 61 0.040498 0.005477 <SNR>93_InvokeCompletion()
19 74 0.005211 308()
20 91 0.004580 Pl#Statusline()
21 74 0.005954 0.004241 <SNR>59_buffer_spec()
Vim doesn't stand asynchronous job control and is basically mono-thread, so he can only do one thing after the other.
You can't type text while YCM is working.
You should try NeoVim who stand it, it won't solve your problem but will minimize it.

Shell script printing contents of variable containing output of a command removes newline characters [duplicate]

This question already has answers here:
Capturing multiple line output into a Bash variable
(7 answers)
Closed 7 years ago.
I'm writing a shell script which will store the output of a command in a variable, process the output, and later echo the results. Here's what I've got:
stuff=$(diff -u pens tape)
# process the output
echo $stuff
The problem is, the output I get from running the script is this:
--- pens 2009-09-27 10:29:06.000000000 -0400 +++ tape 2009-09-18 16:45:08.000000000 -0400 ## -1,4 +1,2 ## -highlighter -marker -pencil -POSIX +masking +duct
Whereas I was expecting this:
--- pens 2009-09-27 10:29:06.000000000 -0400
+++ tape 2009-09-18 16:45:08.000000000 -0400
## -1,4 +1,2 ##
-highlighter
-marker
-pencil
-POSIX
+masking
+duct
It looks like the newline characters are being removed somehow. How do I get them to say in?
If you want to preserve the newlines, enclose the variable in double quotes:
echo "$stuff"
When you write it without the double quotes, the shell expands $stuff into a space-separated list of words (where 'words' are sequences of non-space characters, and the space characters are blanks and tabs and newlines; upon experimentation, it seems that form feeds, carriage returns and back-spaces are not counted as space).
Demonstrating interpretation of control characters as white space. ASCII 8 is backspace, 9 is tab, 10 is new line (LF), 11 is vertical tab, 12 is form feed, 13 is carriage return. The first command generates a sequence of characters separated by the various control characters. The second command echoes with the result with the original characters preserved - see the hex dump. The third command echoes the result with the shell splitting the words; you can see that the tab and newline were replaced by blank (0x20).
$ x=$(./ascii 64 65 8 66 67 9 68 69 10 70 71 11 72 73 12 74 75 13 76 77)
$ echo "$x" | odx
0x0000: 40 41 08 42 43 09 44 45 0A 46 47 0B 48 49 0C 4A #A.BC.DE.FG.HI.J
0x0010: 4B 0D 4C 4D 0A K.LM.
0x0015:
$ echo $x | odx
0x0000: 40 41 08 42 43 20 44 45 20 46 47 0B 48 49 0C 4A #A.BC DE FG.HI.J
0x0010: 4B 0D 4C 4D 0A K.LM.
0x0015:
$

Resources