Wrong word boundaries in nginx files with vim - vim

I'm using the nginx syntax file with vim from here. Whenever I edit files of type nginx i get strange word boundaries. For example, if i have this line:
root /www/www.some-example.com/htdocs/www;
^ ^ ^
And press w, the cursor jumps to the positions indicated by ^. I would rather expect it to be
root /www/www.some-example.com/htdocs/www;
^ ^ ^ ^ ^ ^ ^ ^
which is what i get in non-nginx files.
My iskeyword is:
iskeyword=#,48-57,_,192-255,.,/,:
From the syntax file i could not find where this behavior would be changed. So how can this be fixed?

Your 'iskeyword' is changed in that syntax script on line 8, 9 and 10:
setlocal iskeyword+=.
setlocal iskeyword+=/
setlocal iskeyword+=:
Comment out these three lines to fix your issue.

Related

Syntax error near unexpected token 'newline'? [duplicate]

This question already has answers here:
error while running "source .vimrc"
(2 answers)
Closed 2 years ago.
I have the following written in my .vimrc file
set number
set hlsearch
set mouse=a
map F2 :bprev CR
Getting follwoing error while sourcing .vimrc file
-bash: .vimrc: line 4: syntax error near unexpected token `newline'
-bash: .vimrc: line 4: `map <F2> :bprev <CR>'
.vimrc isn't a shell script; it's a vim script. Both programs have a set command (though each does something very different than the other), which is how you get to line 4 at all. The problem here is that the shell sees the < and > as redirection operators, and the final > is followed by a newline, not a file name; hence, the syntax error.

Vim extension for VSCode : remap ^

I am looking to rebind the ^ shortcut in normal mode (goes to the first non-whitespace character of the line), to use q instead. However, I can't seem to find the name of the command that is appropriated for this : I have tried "commands": ['cursorLineStart'] but this goes to the beginning of the line, including whitespace characters, which is not what I want.
Does anyone know the exact name of the command associated with ^ ?
Not exactly what you are asking but would this suffice:
nnoremap q ^
Edit:
Adding an operator pending motion so OP can do things like dq as mentioned in the comments.
onoremap q ^

How to search special character ^ in Vim?

^ stands for start of a line in Vim. But what if I does want to search for the character ^ itself but not start of lines? I have tried \^ but it seemed not work.
In you vim session type /\^. It works see :)

How to run the shell command in the appointed line in vim?

I have a file edited in Vim with many lines. There is a specific line that contains a shell command, which I want to run.
How can I do this through Vim?
You can use this map:
:nmap ^ GI:!^V^[yy#"Xx
(Pick your favorite key command you don't use in place of ^ for the mapping;I like ^ because I always use 0 for its default function. Enter the ^V^[ with control-V control-V control-V Esc)
Then you can type 4^ to execute line 4, or just ^ to execute the last line in the file.
try Use
:exec '!'.getline('.')
This is like to copy the current line and run it.
You can also map this command to
map <F12> :exec '!'.getline('.')
getline receives the number of the line. if you will write 4 it will the line 4. The "." it run the current line.
so for run the command in line 4 you can write.
:exec '!'.getline(4)

vim augroup/autocmd: Unexpected EOF while looking for matching '

Here is the offending autogroup:
augroup EJB
autocmd! EJB
autocmd BufRead,BufNewFile Captain's.log,*.wiki setlocal expandtab shiftwidth=2 softtabstop=2 tabstop=2
autocmd BufRead,BufNewFile Captain's.log,*.wiki syn match Todo "\<\(TODO\|EJB\)"
"autocmd BufRead,BufNewFile Captain's.log,*.wiki setlocal commentstring=// %s
" Scroll to end of file on opening, then find the last non-blank line.
autocmd BufRead Captain's.log,*.wiki :normal! G{}
augroup END
If I now open Captain's.log in a console (openSuSE 13.2 KDE konsole/yakuake) vim session - but not a gvim window - then I get this artifact at the bottom of the vim buffer:
/bin/bash: -c: line 0: unexpected EOF while looking for matching `''
but it disappears as soon as I scroll to that line of the display.
If I add in (uncomment) the commentstring line, then bash gives me a full-on error:
"Captain's.log" 2185L, 157386C
Error detected while processing BufRead Auto commands for "Captain's.log":
/bin/bash: -c: line 0: unexpected EOF while looking for matching `''
/bin/bash: -c: line 1: syntax error: unexpected end of file
Line 2185 is just the end of the file.
I have tried escaping the apostrophe in the filename in the augroup with \' and '' (ie. double single-quotes), and have tried single-/double-quoting the filename, to no avail. The first two don't change the error, and the latter two make the pattern not match.
What am I missing here? Thanks.
UPDATE: As #FDinoff suggests, it appears that bash is trying to execute Captain's.log. But I figure that the problem has still got to be a bug in the parsing of vimrc - I just copied-and-renamed the file to Captains.log and updated the autogroup accordingly, and the error goes away.
So obviously I now have a workaround. But I would nonetheless be interested in a full explanation of and fix for the problem.

Resources