On Di, 24 Sep 2013, Gary Johnson wrote:

> On 2013-09-24, Christian Brabandt wrote:
> > 
> > I guess, the intention is, that in C code the defines need to be in the 
> > first column.
> 
> Thanks for checking that.
> 
[...]
> Vim's behavior looks to me like a mistake in someone's understanding
> of C.
> 
> I could see an indentation function moving lines beginning with # to
> the left, but preventing the user from executing a command to
> deliberately shift a line seems a little extreme.

Indeed, it looks strange. Especially, since left shifts are allowed, but 
once you reach column 1, you can't right shift anymore. Also note, that 
despite Vim's inability to right shift defines, the file will still be 
marked modified.

Here is a simple patch, allowing the user to right shift #defines.

regards,
Christian
-- 
Liebe ist die gesellschaftlich anerkannte Form des
Wahnsinns.
                -- Benjamin Stramke

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff --git a/src/ops.c b/src/ops.c
--- a/src/ops.c
+++ b/src/ops.c
@@ -258,7 +258,7 @@
 	    /* Move the line right if it doesn't start with '#', 'smartindent'
 	     * isn't set or 'cindent' isn't set or '#' isn't in 'cino'. */
 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
-	    if (first_char != '#' || !preprocs_left())
+	    if (first_char != '#' || !preprocs_left(TRUE))
 #endif
 	{
 	    shift_line(oap->op_type == OP_LSHIFT, p_sr, amount, FALSE);
@@ -3876,7 +3876,7 @@
 			if (cnt == count && i == y_size - 1)
 			    lendiff = (int)STRLEN(ptr);
 #if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
-			if (*ptr == '#' && preprocs_left())
+			if (*ptr == '#' && preprocs_left(FALSE))
 			    indent = 0;     /* Leave # lines at start */
 			else
 #endif
@@ -4011,7 +4011,8 @@
  * Return TRUE if lines starting with '#' should be left aligned.
  */
     int
-preprocs_left()
+preprocs_left(skip_check_hash)
+    int skip_check_hash; /* if false, check for # in first column */
 {
     return
 # ifdef FEAT_SMARTINDENT
@@ -4022,7 +4023,7 @@
 #  endif
 # endif
 # ifdef FEAT_CINDENT
-	(curbuf->b_p_cin && in_cinkeys('#', ' ', TRUE))
+	(curbuf->b_p_cin && in_cinkeys('#', ' ', TRUE) && !skip_check_hash)
 # endif
 	;
 }
diff --git a/src/proto/ops.pro b/src/proto/ops.pro
--- a/src/proto/ops.pro
+++ b/src/proto/ops.pro
@@ -34,7 +34,7 @@
 int op_yank __ARGS((oparg_T *oap, int deleting, int mess));
 void do_put __ARGS((int regname, int dir, long count, int flags));
 void adjust_cursor_eol __ARGS((void));
-int preprocs_left __ARGS((void));
+int preprocs_left __ARGS((int hash));
 int get_register_name __ARGS((int num));
 void ex_display __ARGS((exarg_T *eap));
 int do_join __ARGS((long count, int insert_space, int save_undo, int use_formatoptions));

Raspunde prin e-mail lui